Skip to content

Commit 8b1833d

Browse files
authored
reference: Add all items in mouse (#193)
* reference: Add mouseClicked Signed-off-by: Ce Gao <ce.gao@outlook.com> * reference: Add mouseDragged Signed-off-by: Ce Gao <ce.gao@outlook.com> * reference: Add mouseMoved Signed-off-by: Ce Gao <ce.gao@outlook.com> * reference: Add mousePressed Signed-off-by: Ce Gao <ce.gao@outlook.com> * reference: Add inputmouse related items Signed-off-by: Ce Gao <ce.gao@outlook.com> * reference: Add mouseY Signed-off-by: Ce Gao <ce.gao@outlook.com> * reference: Add pmouseX Signed-off-by: Ce Gao <ce.gao@outlook.com> * reference: Add pmouseY Signed-off-by: Ce Gao <ce.gao@outlook.com> * RLangPApplet: Remove code for debug purpose Signed-off-by: Ce Gao <ce.gao@outlook.com>
1 parent 6ebd7ba commit 8b1833d

File tree

12 files changed

+132
-18
lines changed

12 files changed

+132
-18
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Click within the image to change the value of the rectangle after after the
2+
# mouse has been clicked
3+
4+
value <- 0
5+
6+
draw <- function() {
7+
fill(value)
8+
rect(25, 25, 50, 50)
9+
}
10+
11+
mouseClicked <- function() {
12+
if (value == 0) {
13+
value = 255
14+
} else {
15+
value = 0
16+
}
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Drag (click and hold) your mouse across the image to change the value of the
2+
# rectangle
3+
4+
value <- 0
5+
6+
draw <- function() {
7+
fill(value)
8+
rect(25, 25, 50, 50)
9+
}
10+
11+
mouseDragged <- function() {
12+
value = value + 5
13+
if (value > 255) {
14+
value = 0
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Move the mouse across the image to change its value
2+
3+
value <- 0
4+
5+
draw <- function() {
6+
fill(value)
7+
rect(25, 25, 50, 50)
8+
}
9+
10+
mouseMoved <- function() {
11+
value = value + 5
12+
if (value > 255) {
13+
value = 0
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Click within the image to change the value of the rectangle
2+
3+
draw <- function() {
4+
if (mousePressed == TRUE) {
5+
fill(0)
6+
} else {
7+
fill(255)
8+
}
9+
rect(25, 25, 50, 50)
10+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Click within the image to change the value of the rectangle
2+
3+
value <- 0
4+
5+
draw <- function() {
6+
fill(value)
7+
rect(25, 25, 50, 50)
8+
}
9+
10+
mousePressed <- function() {
11+
if (value == 0) {
12+
value <- 255
13+
} else {
14+
value <- 0
15+
}
16+
}

examples/reference/mousePressed_var/.property.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Click within the image to change the value of the rectangle
2+
3+
value <- 0
4+
5+
draw <- function() {
6+
fill(value)
7+
rect(25, 25, 50, 50)
8+
}
9+
10+
mouseReleased <- function() {
11+
if (value == 0) {
12+
value = 255
13+
} else {
14+
value = 0
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Not Supported Now!
2+
3+
setup <- function() {
4+
size(100, 100)
5+
}
6+
7+
draw <- function() {
8+
}
9+
10+
mouseWheel <- function(event) {
11+
e = event$getCount()
12+
println(e)
13+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
draw <- function() {
2+
background(204)
3+
line(mouseX, 20, mouseX, 80)
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
draw <- function() {
2+
background(204)
3+
line(20, mouseY, 80, mouseY)
4+
}

0 commit comments

Comments
 (0)