So I had some new ideas for patterns and effects on the MatrixClock.

So I had some new ideas for patterns and effects on the MatrixClock. I’m just not sure how to implement them. I remember a while back there was a mention of doing alpha blending. So my thought was to have three “layers”, each rotating at a different speed, and doing neat interactions with the colors. I was looking at using my Object3D class for this, as it makes it pretty simple to do rotations and movements of shapes - make a single face, rotate/translate it as I like.

I just have no idea how to get a proper blending working. Suggestions?
http://www.youtube.com/watch?v=3uaOZtB2V4Y

It’s not FastLED, but there’s a branch of the SmartMatrix Library that supports alpha blending. I admit I haven’t tried it.

Some context:
http://dangerousprototypes.com/forum/viewtopic.php?t=6125&p=58759#p58796

FastLED has some HSV blend functions which may come in handy. A warning though, don’t try to use FastLED functions within the SmartMatrix Library, you will have dependency problems.

what kinds of dependency problems? The library should, in theory (and last time I was poking at it) play nicely with the smartmatrix library in a number of configurations.

Just adding #include <FastLED.h> to SmartMatrix.h is enough to cause a number of errors.

I’ll check the latest version of both libraries then, because I put a fair bit of work into making it possible to use the two together.

Oh - wait, you mean to smartmatrix library itself - yeah, some of that is general library idiocies in arduino. However a sketch can include both smart matrix and FastLED together.

I am actually using both libraries together, with no problems.

Unless there is something I’m missing… The patterns above both use the blur functions in fastled.

Yeah, sorry if that wasn’t clear. The examples using FastLED inside SmartMatrix work just fine.

So I can see I’m going to have to write all new primitive functions to use the blend functions. I think I want to use blend() instead of nblend(), right?

I should be able to do something like this, I hope (in psuedocode)

for each pixel:
existing = leds[XY(X,Y)]; // grab the CHSV for that pixel
overlay = CHSV(H,S,V); // overlay color
new = blend(existing, overlay, .5); // blend by 50%, adjust to suit
drawPixel(X,Y,new);
end

Edit: Or maybe do something like add an overload that if I put in a float at the end, it blends that pixel. I can see this will be a whole lot of overhead though, since it’d be checking each pixel it draws.

What I sometimes do is to render different animations in different arrays. For a crossfade between 2 layers I do the following for each pixel:

layer1 %= scalevalue
layer2 %= 255-scalevalue
leds = layer1 + layer2

scalevalue represents a byte which controls the balance of the blending. That method can be applied to more than 2 layers, too. Just make sure that the sum of all the scaling values is <256 to avoid a white out.

Btw. have you published your 3D class somewhere?

edit: %= is the short version of nscale.

Sure have. It’s at https://github.com/TwystNeko/Object3D - let me know if you have any questions about it.