Skip to content
Snippets Groups Projects
Commit b668cb15 authored by yuichitamiya's avatar yuichitamiya
Browse files

add tips embed p5.js

parent a7051191
No related branches found
No related tags found
No related merge requests found
Pipeline #301823 passed
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="../style.css">
<meta charset="utf-8" />
</head>
<body>
<main>
</main>
<script src="../sketch.js"></script>
</body>
</html>
/**
* Mouse 2D.
*
* Moving the mouse changes the position and size of each box.
*/
function setup() {
initializeFields();
createCanvas(640, 360);
noStroke();
rectMode(CENTER);
}
function draw() {
background(51);
fill(255, 204);
rect(mouseX, height / 2, mouseY / 2 + 10, mouseY / 2 + 10);
fill(255, 204);
var inverseX = width - mouseX;
var inverseY = height - mouseY;
rect(inverseX, height / 2, (inverseY / 2) + 10, (inverseY / 2) + 10);
}
function initializeFields() {
}
html, body {
margin: 0;
padding: 0;
}
canvas {
display: block;
}
...@@ -292,3 +292,138 @@ Ref.[Storing Input](https://processing.org/examples/storinginput.html) ...@@ -292,3 +292,138 @@ Ref.[Storing Input](https://processing.org/examples/storinginput.html)
function initializeFields() { function initializeFields() {
} }
``` ```
## embed p5.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css>
<meta charset="utf-8" />
<script>
/**
* Mouse 2D.
*
* Moving the mouse changes the position and size of each box.
*/
function setup() {
initializeFields();
createCanvas(640, 360);
noStroke();
rectMode(CENTER);
}
function draw() {
background(51);
fill(255, 204);
rect(mouseX, height / 2, mouseY / 2 + 10, mouseY / 2 + 10);
fill(255, 204);
var inverseX = width - mouseX;
var inverseY = height - mouseY;
rect(inverseX, height / 2, (inverseY / 2) + 10, (inverseY / 2) + 10);
}
function initializeFields() {
}
</script>
```
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css>
<meta charset="utf-8" />
<script>
/**
* Mouse 2D.
*
* Moving the mouse changes the position and size of each box.
*/
function setup() {
initializeFields();
createCanvas(640, 360);
noStroke();
rectMode(CENTER);
}
function draw() {
background(51);
fill(255, 204);
rect(mouseX, height / 2, mouseY / 2 + 10, mouseY / 2 + 10);
fill(255, 204);
var inverseX = width - mouseX;
var inverseY = height - mouseY;
rect(inverseX, height / 2, (inverseY / 2) + 10, (inverseY / 2) + 10);
}
function initializeFields() {
}
</script>
```
## Open in other page
```
├── p5_js
│ ├── p5_js.md
│ ├── sketch.js
│ └── style.css
```
<hr />
=== "p5_js.md"
```
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="../style.css">
<meta charset="utf-8" />
</head>
<body>
<main>
</main>
<script src="../sketch.js"></script>
</body>
</html>
```
=== "sketch.js"
```
/**
* Mouse 2D.
*
* Moving the mouse changes the position and size of each box.
*/
function setup() {
initializeFields();
createCanvas(640, 360);
noStroke();
rectMode(CENTER);
}
function draw() {
background(51);
fill(255, 204);
rect(mouseX, height / 2, mouseY / 2 + 10, mouseY / 2 + 10);
fill(255, 204);
var inverseX = width - mouseX;
var inverseY = height - mouseY;
rect(inverseX, height / 2, (inverseY / 2) + 10, (inverseY / 2) + 10);
}
function initializeFields() {
}
```
=== "style.css"
```
html, body {
margin: 0;
padding: 0;
}
canvas {
display: block;
}
```
Open in other page: [p5_js.md](./p5_js/p5_js.md)
html, body {
margin: 0;
padding: 0;
}
canvas {
display: block;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment