forked from leebyron/streamgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomColorPicker.as
48 lines (42 loc) · 985 Bytes
/
RandomColorPicker.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package net.vis4.streamgraph.color
{
import math.Random;
import net.vis4.color.Color;
import net.vis4.streamgraph.Layer;
/**
* RandomColorPicker
* Chooses random colors within an acceptable HSB color spectrum
*
* @author Lee Byron
* @author Martin Wattenberg
*/
public class RandomColorPicker implements ColorPicker
{
protected var _minHue:Number;
protected var _maxHue:Number;
public function RandomColorPicker(seed:int = 2, minHue:Number = 215, maxHue:Number = 236)
{
_maxHue = maxHue;
_minHue = minHue;
Random.seed = 2;
}
public function getName():String
{
return "Random Colors";
}
public function colorize(layers:Vector.<Layer>):void
{
for (var i:int = 0; i < layers.length; i++) {
layers[i].rgb = Color.fromHSV(
Random.float(_minHue, _maxHue),
Random.float(0.2, 0.28),
Random.float(0.4, 0.95)
)._int;
}
}
public function load(callback:Function):void
{
callback();
}
}
}