1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0021e7}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
23 span
.s1
{font: 18.0px Helvetica
}
24 span
.s2
{color: #1141e0}
25 span
.s3
{color: #000000}
26 span
.s4
{text-decoration: underline
}
27 span
.s5
{color: #001bb9}
28 span
.s6
{color: #2c7014}
29 span
.s7
{color: #0000bf}
30 span
.s8
{color: #007300}
31 span
.Apple-tab-span
{white-space:pre
}
35 <p class=
"p1"><span class=
"s1"><b>HiliteGradient
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>a linear color fade between an outside and an inside color
</b><span class=
"s1"><b><span class=
"Apple-tab-span"> </span></b></span></p>
36 <p class=
"p2"><br></p>
37 <p class=
"p1"><b>Inherits from:
</b><a href=
"../../Core/Object.html"><span class=
"s2"><b>Object
</b></span></a></p>
38 <p class=
"p2"><br></p>
39 <p class=
"p3"><span class=
"s3"><b>See also:
</b> <a href=
"Color.html"><span class=
"s4">Color
</span></a>,
<a href=
"Gradient.html"><span class=
"s4">Gradient
</span></a></span></p>
40 <p class=
"p2"><br></p>
41 <p class=
"p4"><b>Creation / Class Methods
</b></p>
42 <p class=
"p5"><br></p>
43 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*new (color1, color2, direction, steps)
</b></p>
44 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
45 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>color1
</b>- An instance of Color.
</p>
46 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>color2
</b>- An instance of Color.
</p>
47 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>direction
</b>- \h or \v for horizontal and vertical respectively. Default value is \v.
</p>
48 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>steps
</b>- The resolution of the gradient. Default value is
64.
</p>
49 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>frac
</b>- The center of the gradient. Default value is
0.33, i.e. off center toward the top on a vertical gradient.
</p>
50 <p class=
"p5"><br></p>
51 <p class=
"p9"><b>Examples
</b></p>
52 <p class=
"p10"><br></p>
53 <p class=
"p11">// basic usage
</p>
55 <p class=
"p12">w=
<span class=
"s5">Window
</span>.new.front;
</p>
56 <p class=
"p12">v=
<span class=
"s5">CompositeView
</span>(w,
<span class=
"s5">Rect
</span>(
50,
50,
200,
50));
</p>
57 <p class=
"p12">v.background=
<span class=
"s5">HiliteGradient
</span>(
<span class=
"s5">Color
</span>.gray,
<span class=
"s5">Color
</span>.white);
</p>
59 <p class=
"p10"><br></p>
60 <p class=
"p11">// change direction and resolution
</p>
62 <p class=
"p12">w=
<span class=
"s5">Window
</span>.new.front;
</p>
63 <p class=
"p12">w.view.background=
<span class=
"s5">HiliteGradient
</span>(
<span class=
"s5">Color
</span>.red,
<span class=
"s5">Color
</span>.white,
<span class=
"s6">\h
</span>,
12,
0.5);
</p>
65 <p class=
"p10"><br></p>
66 <p class=
"p13">// almost unnoticeable variations can be pleasant
</p>
68 <p class=
"p12">w =
<span class=
"s7">Window
</span>.new.front;
</p>
69 <p class=
"p12">v =
<span class=
"s7">CompositeView
</span>(w,
<span class=
"s7">Rect
</span>(
50,
50,
300,
300));
</p>
70 <p class=
"p12">c =
<span class=
"s7">Color
</span>.rand;
</p>
71 <p class=
"p12">d = c.vary(
0.15);
</p>
72 <p class=
"p12">v.background =
<span class=
"s5">HiliteGradient
</span>(c, d,
<span class=
"s8">\v
</span>);
</p>
73 <p class=
"p12">[c, d].postln
</p>
75 <p class=
"p10"><br></p>
77 <p class=
"p12"><span class=
"s7">var
</span> w, k, c, d, e, c1, c2, f, g;
</p>
78 <p class=
"p12">w =
<span class=
"s7">Window
</span>.new.front;
</p>
79 <p class=
"p12">k =
<span class=
"s7">Slider2D
</span>(w,
<span class=
"s7">Rect
</span>(
50,
50,
300,
300));
</p>
80 <p class=
"p12">f = {
</p>
81 <p class=
"p12"><span class=
"Apple-tab-span"> </span>c =
<span class=
"s7">Color
</span>.rand;
</p>
82 <p class=
"p12"><span class=
"Apple-tab-span"> </span>d = c.vary(
0.5);
</p>
83 <p class=
"p12"><span class=
"Apple-tab-span"> </span>e = d.vary(
0.5);
</p>
85 <p class=
"p12">g = {
<span class=
"Apple-converted-space"> </span></p>
86 <p class=
"p12"><span class=
"Apple-tab-span"> </span>c1 = d.hueBlend(e, k.y).round(
0.01);
<span class=
"Apple-converted-space"> </span></p>
87 <p class=
"p12"><span class=
"Apple-tab-span"> </span>c2 = c.hueBlend(e, k.x).round(
0.01);
<span class=
"Apple-converted-space"> </span></p>
88 <p class=
"p12"><span class=
"Apple-tab-span"> </span>k.background =
<span class=
"s5">HiliteGradient
</span>(c1, c2,
<span class=
"s8">\v
</span>)
<span class=
"Apple-converted-space"> </span></p>
90 <p class=
"p12">f.value; g.value;
</p>
91 <p class=
"p12">k.action = g;
</p>
92 <p class=
"p12">k.mouseUpAction = { [c1, c2].postln };
</p>
93 <p class=
"p13"><span class=
"s3">k.keyDownAction = f;
</span>// hit any key for new color
</p>