1.4
This commit is contained in:
parent
1bdaf3e2fd
commit
b019030676
40
1.Basics.md
40
1.Basics.md
@ -23,3 +23,43 @@ function draw() {
|
||||
print("Hello World"); // see the console below ↓
|
||||
}
|
||||
```
|
||||
|
||||
## Sketch: 1.0 Key Events
|
||||
|
||||
```javascript
|
||||
// Key Events!
|
||||
|
||||
function setup() {
|
||||
createCanvas(400, 400);
|
||||
}
|
||||
|
||||
function draw() {
|
||||
background(220);
|
||||
// Only when keyIsPressed?
|
||||
print("Hello World");
|
||||
}
|
||||
|
||||
// Reference: https://p5js.org/reference/
|
||||
```
|
||||
## Sketch: 1.1 Mouse Events
|
||||
|
||||
```javascript
|
||||
// Mouse Events!
|
||||
|
||||
function setup() {
|
||||
createCanvas(400, 400);
|
||||
}
|
||||
|
||||
function draw() {
|
||||
background(220);
|
||||
if(mouseIsPressed) {
|
||||
print("Pressed: " + mouseX + " - " + mouseY) ; // see the console below ↓
|
||||
}
|
||||
}
|
||||
|
||||
// this is a special p5 function
|
||||
function mouseMoved() {
|
||||
print("Moved: " + mouseX + " - " + mouseY) ; // see the console below ↓
|
||||
}
|
||||
|
||||
// Reference: https://p5js.org/reference/```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user