createGradientBox Explorer

I ran across a need to rotate a gradient drawn with the drawing API. It wasn’t obvious how to go about it. I tried rotating the Sprite that it was drawn on but that presented issues and I know it wasn’t the right way to do it.  I expect that lots of people need to create gradients that are vertical so it shouldn’t be too difficult.

Since the beginGradientFill expects a matrix as the 5th parameter I figured that was the obvious place to change the orientation of the gradient. Now the question becomes what sort of matrix do I need to create the effect I’m looking for? After toying around for a while I was able to change the gradient but not in the way I expected. Changing values and the publishing again really isn’t a good way to figure out how something works. So I created an explorer for the createGradientBox method so that I could see it change and better understand how it works. Which reminds me of one of my favorite quotes from DUNE.

A process cannot be understood by stopping it. Understanding must move with the flow of the process, must join it and flow with it.
-First Law of Mentat, DUNE

Now you can explore the createGradientBox to your hearts content.

view source