Skip to content

Commit b225b8b

Browse files
authored
reference: Add tranform reference items (#128)
* transform: Add example code and test cases Signed-off-by: Ce Gao <ce.gao@outlook.com> * coala: Format the code Signed-off-by: Ce Gao <ce.gao@outlook.com>
1 parent 37f7db3 commit b225b8b

Some content is hidden

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

49 files changed

+588
-1
lines changed
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/applyMatrix_.png
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
P3D <- "processing.opengl.PGraphics3D"
2+
PI <- pi
3+
4+
settings <- function() {
5+
size(100, 100, P3D)
6+
}
7+
8+
draw <- function() {
9+
noFill()
10+
translate(50, 50, 0)
11+
rotateY(PI/6)
12+
stroke(153)
13+
box(35)
14+
# Set rotation angles
15+
ct = cos(PI/9)
16+
st = sin(PI/9)
17+
# Matrix for rotation around the Y axis
18+
applyMatrix(ct, 0, st, 0, 0, 1, 0, 0, -st, 0, ct, 0, 0, 0, 0, 1)
19+
stroke(255)
20+
box(50)
21+
}
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/popMatrix_.png
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fill(255)
2+
rect(0, 0, 50, 50) # White rectangle
3+
4+
pushMatrix()
5+
translate(30, 20)
6+
fill(0)
7+
rect(0, 0, 50, 50) # Black rectangle
8+
popMatrix()
9+
10+
fill(100)
11+
rect(15, 10, 50, 50) # Gray rectangle
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/pushMatrix_.png
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fill(255)
2+
rect(0, 0, 50, 50) # White rectangle
3+
4+
pushMatrix()
5+
translate(30, 20)
6+
fill(0)
7+
rect(0, 0, 50, 50) # Black rectangle
8+
popMatrix()
9+
10+
fill(100)
11+
rect(15, 10, 50, 50) # Gray rectangle
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/rotate_.png
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PI <- pi
2+
3+
translate(width/2, height/2)
4+
rotate(PI/3)
5+
rect(-26, -26, 52, 52)
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_0.png
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
P3D <- "processing.opengl.PGraphics3D"
2+
PI <- pi
3+
4+
settings <- function() {
5+
size(100, 100, P3D)
6+
}
7+
8+
draw <- function() {
9+
translate(width/2, height/2)
10+
rotateX(PI/3)
11+
rect(-26, -26, 52, 52)
12+
}

0 commit comments

Comments
 (0)