Not much of a change for this one – I’ve just added the ability to specify the caps style for the drawing of the BezierChains. Also, I added a new drawing mode that splits the curve into 2 quadratic beziers and draws them out using curveTo. This is loads faster than drawing a bunch of little lines, but does mean you don’t get to make nice gradiented colours. I had a look at the lineGradientStyle property, but it doesn’t follow the curve of the line. Maybe there’s a way to split up the gradient style and make it work? Will have to have a look at that one. You’ll also notice that the quad bezier doesn’t exactly follow the correct path, but that’s the price you pay for speed!
experiment #14 – caps/quad
The second thing is an update to the Gradient class from my colour package. Before it was a little bit lame, but now it rocks! The set up is the same as before, but now it allows much greater control of the elements, and you can actually get some useful readings from it.
The following methods are available:
validateRGB: checks that a specifed rgb value is within range, return t/f
step: increments/decrements the currentColourRatio value by amount
setColour: sets a colour at the specified index in the colours array
clone: returns a copy of the Gradient class
There are all of the parameters of a gradient (have a look at beginGradientFill in the Graphics class docs) that can be accessed as properties and some extra ones:
currentColourRatio: this is an integer (0 – 255) that represents a position in the gradient – this is equivalent to a possible value in the ratios array in the gradient fill.
rgb: the colour at the current colour ratio position(ccr), if you set this, it will either change one of the colours in the colour array (if the ccr is equal to a value in the ratios array) or add a new value at the ccr.
argb: as above, but takes/returns an object {alpha:Number, colour:int} and allows getting/setting of the alpha value
There’s a little more work to do – it’d be nice to be able to adjust the ratios and alpha values already in the array and delete values, so that’s on the cards for the next update.
Get it here.