forked from processing/processing-web-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorMode.xml
More file actions
executable file
·116 lines (92 loc) · 3.04 KB
/
Copy pathcolorMode.xml
File metadata and controls
executable file
·116 lines (92 loc) · 3.04 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>colorMode()</name>
<category>Color</category>
<subcategory>Setting</subcategory>
<usage>Web & Application</usage>
<example>
<image>colorMode_.jpg</image>
<code><![CDATA[
noStroke();
colorMode(RGB, 100);
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
stroke(i, j, 0);
point(i, j);
}
}
]]></code>
</example>
<example>
<image>colorMode_2.jpg</image>
<code><![CDATA[
noStroke();
colorMode(HSB, 100);
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
stroke(i, j, 100);
point(i, j);
}
}
]]></code>
</example>
<example>
<image>colorMode_3.gif</image>
<code><![CDATA[
// If the color is defined here, it won't be
// affected by the colorMode() in setup().
// Instead, just declare the variable here and
// assign the value after the colorMode() in setup()
//color bg = color(180, 50, 50); // No
color bg; // Yes, but assign it in setup()
void setup() {
size(100, 100);
colorMode(HSB, 360, 100, 100);
bg = color(180, 50, 50);
}
void draw() {
background(bg);
}
]]></code>
</example>
<description><![CDATA[Changes the way Processing interprets color data. By default, the parameters for <b>fill()</b>, <b>stroke()</b>, <b>background()</b>, and <b>color()</b> are defined by values between 0 and 255 using the RGB color model. The <b>colorMode()</b> function is used to change the numerical range used for specifying colors and to switch color systems. For example, calling <b>colorMode(RGB, 1.0)</b> will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the parameters range1, range2, range3, and range 4. ]]></description>
<syntax><![CDATA[
colorMode(<kbd>mode</kbd>);
colorMode(<kbd>mode</kbd>, <kbd>range</kbd>);
colorMode(<kbd>mode</kbd>, <kbd>range1</kbd>, <kbd>range2</kbd>, <kbd>range3</kbd>);
colorMode(<kbd>mode</kbd>, <kbd>range1</kbd>, <kbd>range2</kbd>, <kbd>range3</kbd>, <kbd>range4</kbd>);
]]></syntax>
<parameter>
<label>mode</label>
<description><![CDATA[Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness]]></description>
</parameter>
<parameter>
<label>range</label>
<description><![CDATA[int or float: range for all color elements]]></description>
</parameter>
<parameter>
<label>range1</label>
<description><![CDATA[int or float: range for the red or hue depending on the current color mode]]></description>
</parameter>
<parameter>
<label>range2</label>
<description><![CDATA[int or float: range for the green or saturation depending on the current color mode]]></description>
</parameter>
<parameter>
<label>range3</label>
<description><![CDATA[int or float: range for the blue or brightness depending on the current color mode]]></description>
</parameter>
<parameter>
<label>range4</label>
<description><![CDATA[int or float: range for the alpha]]></description>
</parameter>
<returns>None</returns>
<related>
background()
fill()
stroke()
</related>
<availability>1.0</availability>
<type>Function</type>
<partof>Core</partof>
</root>