2 summary:: A linear color fade between two colors
3 categories:: GUI>Accessories
4 related:: Classes/Color, Classes/HiliteGradient
8 note:: The use of Gradient is strong::not supported yet in Qt GUI::. When Gradient is used in place of Color, the average gradient color will be used instead. ::
14 An instance of link::Classes/Color::.
16 An instance of link::Classes/Color::.
18 code::\h:: or code::\v:: for horizontal and vertical respectively. Default value is code::\h::.
20 The resolution of the gradient. Default value is 64.
25 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::.
33 w.view.background = Gradient(Color.yellow,Color.white);
36 // change direction and resolution
39 w.view.background = Gradient(Color.red,Color.white,\v, 5);
42 // almost unnoticeable variations can be pleasant
45 v = CompositeView(w, Rect(50,50,300,300));
48 v.background = Gradient(c, d, \v);
53 var w, k, c, d, e, c1, c2, f, g;
55 k = Slider2D(w, Rect(50,50,300,300));
62 c1 = d.hueBlend(e, k.y).round(0.01);
63 c2 = c.hueBlend(e, k.x).round(0.01);
64 k.background = Gradient(c1, c2, \v)
68 k.mouseUpAction = { [c1, c2].postln };
69 k.keyDownAction = f; // hit any key for new color
72 // an example using gradient indirectly to update window colour
75 g = Gradient(Color.red,Color.green);
77 (0, 0.01 .. 1).do{|pos|
78 w.view.background = g.at(pos);