Created
July 11, 2017 05:14
-
-
Save gregoriobenatti/58a348b84ca6f2267059adbb1bae97c8 to your computer and use it in GitHub Desktop.
html for p5js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, body { | |
height: 100%; | |
} | |
body { | |
margin: 0; | |
display: flex; | |
/* This centers our sketch horizontally. */ | |
justify-content: center; | |
/* This centers our sketch vertically. */ | |
align-items: center; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<style> | |
html, body { | |
height: 100%; | |
} | |
body { | |
margin: 0; | |
display: flex; | |
/* This centers our sketch horizontally. */ | |
justify-content: center; | |
/* This centers our sketch vertically. */ | |
align-items: center; | |
} | |
</style> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.sound.min.js"></script> | |
<script src="sketch.js"></script> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<style> body {padding: 0; margin: 0;} </style> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var value = 0; | |
function setup() { | |
createCanvas(640, 480); | |
background(51); | |
} | |
function draw() { | |
fill(value); | |
noStroke(); | |
translate(200, 130); | |
for (var i = 0; i < 10; i++) { | |
for (var j = 0; j < 10; j++) { | |
if (mouseIsPressed) { | |
ellipse(23*i, 23*j, 20, 20); | |
} | |
else { | |
rect(23*i, 23*j, 20, 20); | |
} | |
} | |
} | |
} | |
function mouseMoved() { | |
value = value + 5; | |
if (value > 255) { | |
value = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment