Skip to content

Commit e8577e8

Browse files
committed
docs: Update
Signed-off-by: Ce Gao <ce.gao@outlook.com>
1 parent 1c3aa2f commit e8577e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+356
-5
lines changed

docs/alpha.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@
3838
<td><h3>alpha</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/alpha1.png"/>
43+
<pre class='margin'>noStroke()
44+
c = color(0, 126, 255, 102)
45+
fill(c)
46+
rect(15, 15, 35, 70)
47+
value = alpha(c) # Sets &#39;value&#39; to 102
48+
fill(value)
49+
rect(50, 15, 35, 70)
50+
</pre>
51+
</div>
52+
</tr>
4153

4254
<tr class="">
4355
<th scope="row">Description</th>

docs/background.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@
3838
<td><h3>background</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/background1.png"/>
43+
<pre class='margin'>background(51)
44+
</pre>
45+
</div>
46+
<div class="example"> <img src="img/background2.png"/>
47+
<pre class='margin'>background(255, 204, 0)
48+
</pre>
49+
</div>
50+
<div class="example"> <pre>img = loadImage(&#34;laDefense.jpg&#34;)
51+
background(img)
52+
</pre>
53+
</div>
54+
</tr>
4155

4256
<tr class="">
4357
<th scope="row">Description</th>

docs/blue.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
<td><h3>blue</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/blue1.png"/>
43+
<pre class='margin'>c = color(175, 100, 220) # Define color &#39;c&#39;
44+
fill(c) # Use color variable &#39;c&#39; as fill color
45+
rect(15, 20, 35, 60) # Draw left rectangle
46+
47+
blueValue = blue(c) # Get blue in &#39;c&#39;
48+
println(blueValue) # Prints &#39;220.0&#39;
49+
fill(0, 0, blueValue) # Use &#39;blueValue&#39; in new fill
50+
rect(50, 20, 35, 60) # Draw right rectangle
51+
</pre>
52+
</div>
53+
</tr>
4154

4255
<tr class="">
4356
<th scope="row">Description</th>

docs/brightness.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
<td><h3>brightness</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/brightness1.png"/>
43+
<pre class='margin'>noStroke()
44+
colorMode(HSB, 255)
45+
c = color(0, 126, 255)
46+
fill(c)
47+
rect(15, 20, 35, 60)
48+
value = brightness(c) # Sets &#39;value&#39; to 255
49+
fill(value)
50+
rect(50, 20, 35, 60)
51+
</pre>
52+
</div>
53+
</tr>
4154

4255
<tr class="">
4356
<th scope="row">Description</th>

docs/clear.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,35 @@
3838
<td><h3>clear</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <pre>pg &lt;- NULL
43+
44+
settings &lt;- function() {
45+
size(200, 200)
46+
}
47+
48+
setup &lt;- function() {
49+
pg &lt;- createGraphics(100, 100)
50+
}
51+
52+
draw &lt;- function() {
53+
background(204)
54+
pg$beginDraw()
55+
pg$stroke(0, 102, 153)
56+
pg$line(0, 0, mouseX, mouseY)
57+
pg$endDraw()
58+
image(pg, 50, 50)
59+
}
60+
61+
# Click to clear the PGraphics object
62+
mousePressed &lt;- function() {
63+
pg$beginDraw()
64+
pg$clear()
65+
pg$endDraw()
66+
}
67+
</pre>
68+
</div>
69+
</tr>
4170

4271
<tr class="">
4372
<th scope="row">Description</th>

docs/color.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,42 @@
3838
<td><h3>color</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/color1.png"/>
43+
<pre class='margin'>c = color(255, 204, 0) # Define color &#39;c&#39;
44+
fill(c) # Use color variable &#39;c&#39; as fill color
45+
noStroke() # Don&#39;t draw a stroke around shapes
46+
rect(30, 20, 55, 55) # Draw rectangle
47+
</pre>
48+
</div>
49+
<div class="example"> <img src="img/color2.png"/>
50+
<pre class='margin'>c = color(255, 204, 0) # Define color &#39;c&#39;
51+
fill(c) # Use color variable &#39;c&#39; as fill color
52+
noStroke() # Don&#39;t draw a stroke around shapes
53+
ellipse(25, 25, 80, 80) # Draw left circle
54+
55+
# Using only one value with color() generates a grayscale value.
56+
c = color(65) # Update &#39;c&#39; with grayscale value
57+
fill(c) # Use updated &#39;c&#39; as fill color
58+
ellipse(75, 75, 80, 80) # Draw right circle
59+
</pre>
60+
</div>
61+
<div class="example"> <img src="img/color3.png"/>
62+
<pre class='margin'>noStroke() # Don&#39;t draw a stroke around shapes
63+
64+
# If no colorMode is specified, then the default of RGB with scale of 0-255 is
65+
# used.
66+
c = color(50, 55, 100) # Create a color for &#39;c&#39;
67+
fill(c) # Use color variable &#39;c&#39; as fill color
68+
rect(0, 10, 45, 80) # Draw left rect
69+
70+
colorMode(HSB, 100) # Use HSB with scale of 0-100
71+
c = color(50, 55, 100) # Update &#39;c&#39; with new color
72+
fill(c) # Use updated &#39;c&#39; as fill color
73+
rect(55, 10, 45, 80) # Draw right rect
74+
</pre>
75+
</div>
76+
</tr>
4177

4278
<tr class="">
4379
<th scope="row">Description</th>

docs/colorMode.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,48 @@
3838
<td><h3>colorMode</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/colorMode1.png"/>
43+
<pre class='margin'>noStroke()
44+
colorMode(RGB, 100)
45+
for (i in 0:100) {
46+
for (j in 0:100) {
47+
stroke(i, j, 0)
48+
point(i, j)
49+
}
50+
}
51+
</pre>
52+
</div>
53+
<div class="example"> <img src="img/colorMode3.png"/>
54+
<pre class='margin'># If the color is defined here, it won&#39;t be affected by the colorMode() in
55+
# setup(). Instead, just declare the variable here and assign the value after
56+
# the colorMode() in setup() color bg = color(180, 50, 50); # No
57+
58+
bg &lt;- NULL
59+
60+
setup &lt;- function() {
61+
size(100, 100)
62+
colorMode(HSB, 360, 100, 100)
63+
bg = color(180, 50, 50)
64+
}
65+
66+
draw &lt;- function() {
67+
background(bg)
68+
}
69+
</pre>
70+
</div>
71+
<div class="example"> <img src="img/colorMode2.png"/>
72+
<pre class='margin'>noStroke()
73+
colorMode(HSB, 100)
74+
for (i in 0:100) {
75+
for (j in 0:100) {
76+
stroke(i, j, 100)
77+
point(i, j)
78+
}
79+
}
80+
</pre>
81+
</div>
82+
</tr>
4183

4284
<tr class="">
4385
<th scope="row">Description</th>

docs/controlflow.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
</tr>
4040

4141
<tr class=""><th scope="row">Examples</th><td>
42-
<div class="example"> <pre>for(i in 1:5) print(1:i)
43-
for(n in c(2,5,10,20,50)) {
44-
x &lt;- stats::rnorm(n)
45-
cat(n, &#34;: &#34;, sum(x^2), &#34;\n&#34;, sep = &#34;&#34;)
42+
<div class="example"> <pre>for (i in 1:5) print(1:i)
43+
for (n in c(2, 5, 10, 20, 50)) {
44+
x &lt;- stats::rnorm(n)
45+
cat(n, &#34;: &#34;, sum(x^2), &#34;\n&#34;, sep = &#34;&#34;)
4646
}
4747
f &lt;- factor(sample(letters[1:5], 10, replace = TRUE))
48-
for(i in unique(f)) print(i)
48+
for (i in unique(f)) print(i)
4949
</pre>
5050
</div>
5151
</tr>

docs/day.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
<td><h3>day</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <pre>d = day() # Values from 1 - 31
43+
m = month() # Values from 1 - 12
44+
y = year() # 2003, 2004, 2005, etc.
45+
46+
text(toString(d), 10, 28)
47+
text(toString(m), 10, 56)
48+
text(toString(y), 10, 84)
49+
</pre>
50+
</div>
51+
</tr>
4152

4253
<tr class="">
4354
<th scope="row">Description</th>

docs/fill.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@
3838
<td><h3>fill</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/fill1.png"/>
43+
<pre class='margin'>fill(153)
44+
rect(30, 20, 55, 55)
45+
</pre>
46+
</div>
47+
<div class="example"> <img src="img/fill2.png"/>
48+
<pre class='margin'>fill(204, 102, 0)
49+
rect(30, 20, 55, 55)
50+
</pre>
51+
</div>
52+
</tr>
4153

4254
<tr class="">
4355
<th scope="row">Description</th>

docs/green.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
<td><h3>green</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/green1.png"/>
43+
<pre class='margin'>c = color(20, 75, 200) # Define color &#39;c&#39;
44+
fill(c) # Use color variable &#39;c&#39; as fill color
45+
rect(15, 20, 35, 60) # Draw left rectangle
46+
47+
greenValue = green(c) # Get green in &#39;c&#39;
48+
print(greenValue) # Print &#39;75.0&#39;
49+
fill(0, greenValue, 0) # Use &#39;greenValue&#39; in new fill
50+
rect(50, 20, 35, 60) # Draw right rectangle
51+
</pre>
52+
</div>
53+
</tr>
4154

4255
<tr class="">
4356
<th scope="row">Description</th>

docs/hour.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
<td><h3>hour</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <pre>draw &lt;- function() {
43+
background(204)
44+
s = second() # Values from 0 - 59
45+
m = minute() # Values from 0 - 59
46+
h = hour() # Values from 0 - 23
47+
line(s, 0, s, 33)
48+
line(m, 33, m, 66)
49+
line(h, 66, h, 100)
50+
}
51+
</pre>
52+
</div>
53+
</tr>
4154

4255
<tr class="">
4356
<th scope="row">Description</th>

docs/hue.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
<td><h3>hue</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/hue1.png"/>
43+
<pre class='margin'>noStroke()
44+
colorMode(HSB, 255)
45+
c = color(0, 126, 255)
46+
fill(c)
47+
rect(15, 20, 35, 60)
48+
value = hue(c) # Sets &#39;value&#39; to &#39;0&#39;
49+
fill(value)
50+
rect(50, 20, 35, 60)
51+
</pre>
52+
</div>
53+
</tr>
4154

4255
<tr class="">
4356
<th scope="row">Description</th>

docs/img/alpha1.png

229 Bytes
Loading

docs/img/background1.png

215 Bytes
Loading

docs/img/background2.png

203 Bytes
Loading

docs/img/blue1.png

235 Bytes
Loading

docs/img/brightness1.png

223 Bytes
Loading

docs/img/color1.png

220 Bytes
Loading

docs/img/color2.png

955 Bytes
Loading

docs/img/color3.png

240 Bytes
Loading

docs/img/colorMode1.png

19.6 KB
Loading

docs/img/colorMode2.png

18.7 KB
Loading

docs/img/colorMode3.png

217 Bytes
Loading

docs/img/fill1.png

226 Bytes
Loading

docs/img/fill2.png

226 Bytes
Loading

docs/img/green1.png

236 Bytes
Loading

docs/img/hue1.png

224 Bytes
Loading

docs/img/lerpColor1.png

252 Bytes
Loading

docs/img/noFill1.png

247 Bytes
Loading

docs/img/noStroke1.png

216 Bytes
Loading

docs/img/red1.png

231 Bytes
Loading

docs/img/saturation1.png

226 Bytes
Loading

docs/img/stroke1.png

226 Bytes
Loading

docs/img/stroke2.png

226 Bytes
Loading

docs/lerpColor.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@
3838
<td><h3>lerpColor</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <img src="img/lerpColor1.png"/>
43+
<pre class='margin'>stroke(255)
44+
background(51)
45+
from = color(204, 102, 0)
46+
to = color(0, 102, 153)
47+
interA = lerpColor(from, to, 0.33)
48+
interB = lerpColor(from, to, 0.66)
49+
fill(from)
50+
rect(10, 20, 20, 60)
51+
fill(interA)
52+
rect(30, 20, 20, 60)
53+
fill(interB)
54+
rect(50, 20, 20, 60)
55+
fill(to)
56+
rect(70, 20, 20, 60)
57+
</pre>
58+
</div>
59+
</tr>
4160

4261
<tr class="">
4362
<th scope="row">Description</th>

docs/millis.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
<td><h3>millis</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <pre>draw &lt;- function() {
43+
m = millis()
44+
noStroke()
45+
fill(m%%255)
46+
rect(25, 25, 50, 50)
47+
}
48+
</pre>
49+
</div>
50+
</tr>
4151

4252
<tr class="">
4353
<th scope="row">Description</th>

docs/minute.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
<td><h3>minute</h3></td>
3939
</tr>
4040

41+
<tr class=""><th scope="row">Examples</th><td>
42+
<div class="example"> <pre>draw &lt;- function() {
43+
background(204)
44+
s = second() # Values from 0 - 59
45+
m = minute() # Values from 0 - 59
46+
h = hour() # Values from 0 - 23
47+
line(s, 0, s, 33)
48+
line(m, 33, m, 66)
49+
line(h, 66, h, 100)
50+
}
51+
</pre>
52+
</div>
53+
</tr>
4154

4255
<tr class="">
4356
<th scope="row">Description</th>

0 commit comments

Comments
 (0)