Skip to content

Commit 7296520

Browse files
authored
reference: Add the missing images (#205)
* reference: Add test Signed-off-by: Ce Gao <[email protected]> * reference: Add height Signed-off-by: Ce Gao <[email protected]> * reference: Add cursor code Signed-off-by: Ce Gao <[email protected]> * reference: Add frameRate code Signed-off-by: Ce Gao <[email protected]> * reference: Fix the stntax in height Signed-off-by: Ce Gao <[email protected]> * reference: Add example Signed-off-by: Ce Gao <[email protected]> * reference: Add createShape example Signed-off-by: Ce Gao <[email protected]>
1 parent 35b2372 commit 7296520

File tree

18 files changed

+272
-1
lines changed

18 files changed

+272
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
settings <- function() {
2+
size(100, 100)
3+
}
4+
5+
setup <- function() {
6+
# Creating the PShape as a square. The numeric arguments are similar to rect().
7+
square = createShape(RECT, 0, 0, 50, 50)
8+
square$setFill(color(0, 0, 255))
9+
square$setStroke(FALSE)
10+
}
11+
12+
draw <- function() {
13+
shape(square, 25, 25)
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
settings <- function() {
2+
size(100, 100)
3+
}
4+
5+
setup <- function() {
6+
# Creating the PShape as a square. The numeric arguments are similar to rect().
7+
s = createShape()
8+
s$beginShape()
9+
s$fill(0, 0, 255)
10+
s$noStroke()
11+
s$vertex(0, 0)
12+
s$vertex(0, 50)
13+
s$vertex(50, 50)
14+
s$vertex(50, 0)
15+
s$endShape(CLOSE)
16+
}
17+
18+
draw <- function() {
19+
shape(s, 25, 25)
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
settings <- function() {
2+
size(100, 100)
3+
}
4+
5+
setup <- function() {
6+
# Creating the PShape as a square. The numeric arguments are similar to rect().
7+
s = createShape()
8+
s$beginShape(TRIANGLE_STRIP)
9+
s$vertex(30, 75)
10+
s$vertex(40, 20)
11+
s$vertex(50, 75)
12+
s$vertex(60, 20)
13+
s$vertex(70, 75)
14+
s$vertex(80, 20)
15+
s$vertex(90, 75)
16+
s$endShape()
17+
}
18+
19+
draw <- function() {
20+
shape(s, 0, 0)
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
settings <- function() {
2+
size(1000, 1000)
3+
}
4+
5+
setup <- function() {
6+
# Create the shape group
7+
alien = createShape(GROUP)
8+
9+
# Make two shapes
10+
head = createShape(ELLIPSE, -25, 0, 50, 50)
11+
head$setFill(color(255))
12+
body = createShape(RECT, -25, 45, 50, 40)
13+
body$setFill(color(0))
14+
15+
# Add the two 'child' shapes to the parent group
16+
alien$addChild(body)
17+
alien$addChild(head)
18+
}
19+
20+
draw <- function() {
21+
background(204)
22+
translate(50, 15)
23+
shape(alien)
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Move the mouse left and right across the image to see the cursor change from a
2+
# cross to a hand
3+
4+
draw <- function() {
5+
if (mouseX < 50) {
6+
cursor(CROSS)
7+
} else {
8+
cursor(HAND)
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
setup <- function() {
2+
frameRate(30)
3+
}
4+
5+
draw <- function() {
6+
line(0, 0, width, height)
7+
println(frameCount)
8+
}

examples/reference/height/.property.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ subcategory:
33
description: "
44
System variable that stores the height of the display window. This value is set by the second parameter of the <b>size()</b> function. For example, the function call <b>size(320, 240)</b> sets the <b>height</b> variable to the value 240. The value of <b>height</b> defaults to 100 if <b>size()</b> is not used in a program.
55
"
6-
syntax: " rect(40, 0, 20, height)"
6+
syntax: "rect(40, 0, 20, height)"
77
related:
88
- width
99
- size
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test:
2+
reference: https://processing.org/reference/images/height.png
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
noStroke()
2+
background(0)
3+
rect(40, 0, 20, height)
4+
rect(60, 0, 20, height/2)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test:
2+
reference: https://processing.org/reference/images/rotateX_1.png

0 commit comments

Comments
 (0)