2 summary:: A linear color fade between two colors
3 categories:: GUI>GUI-Tools
4 related:: Classes/Color, Classes/HiliteGradient
10 An instance of link::Classes/Color::.
12 An instance of link::Classes/Color::.
14 code::\h:: or code::\v:: for horizontal and vertical respectively. Default value is code::\h::.
16 The resolution of the gradient. Default value is 64.
21 Retrieve the colour at position code::pos::, typically a value between zero and one. code::at(0):: is code::color1::, and code::at(1):: is code::color2::.
29 w.view.background = Gradient(Color.yellow,Color.white);
32 // change direction and resolution
35 w.view.background = Gradient(Color.red,Color.white,\v, 5);
38 // almost unnoticeable variations can be pleasant
41 v = CompositeView(w, Rect(50,50,300,300));
44 v.background = Gradient(c, d, \v);
49 var w, k, c, d, e, c1, c2, f, g;
51 k = Slider2D(w, Rect(50,50,300,300));
58 c1 = d.hueBlend(e, k.y).round(0.01);
59 c2 = c.hueBlend(e, k.x).round(0.01);
60 k.background = Gradient(c1, c2, \v)
64 k.mouseUpAction = { [c1, c2].postln };
65 k.keyDownAction = f; // hit any key for new color
68 // an example using gradient indirectly to update window colour
71 g = Gradient(Color.red,Color.green);
73 (0, 0.01 .. 1).do{|pos|
74 w.view.background = g.at(pos);