jump to navigation

Get Color of Gradient. GradientUtil. May 17, 2009

Posted by samoiloff in Actionscript, Color, Drawing, Gradient, Samoiloff.
Tags: , , , , ,
trackback

Gradient data in Flash are defined with pairs {color, ratio}. Basic Adobe code that process gradients for drawing is hidden inside Graphics class. So it’s impossible to find color of gradient GradientUtil by basic Flash means.

For this reason I’ve recently wrote very simple GradientUtil class that process gradient data.

Here’s an example of usage:
var colorsArr:Array = [0x00ff00, 0xff0000, 0x0000ff];

var ratiosArr:Array = [0, .5, 1];

trace(GradientUtil.getColorByRatio(.25, colorsArr, ratiosArr));

One can find demo here and sources here.

Comments»

No comments yet — be the first.