Last active
January 5, 2019 22:50
-
-
Save ndrhzn/ae2653cec50194caa881cd5d75bd2170 to your computer and use it in GitHub Desktop.
P5 - Jittering Rectangles
This file contains hidden or 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 lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script> | |
<title>Jittering Rectangles</title> | |
</head> | |
<style media="screen"> | |
body { | |
margin: 0; | |
padding: 0; | |
overflow: hidden; | |
} | |
</style> | |
<body> | |
</body> | |
<script type="text/javascript"> | |
function setup() { | |
createCanvas(windowWidth, windowHeight); | |
frameRate(12); | |
}; | |
function draw() { | |
background('#FFFFFD'); | |
noStroke(); | |
rectMode(CENTER); | |
for(let i = (windowWidth/10)/1.5; i < windowWidth - (windowWidth/10)/1.5; i += (windowWidth/10)/1.5) { | |
for(let l = (windowHeight/5)/1.5; l < windowHeight - (windowHeight/5)/1.5; l+= (windowHeight/5)/1.5) { | |
fill('#F1F1F1'); | |
rect(i-random(-1, 1), l-random(-1, 1), (windowWidth/10)/2, (windowHeight/5)/2); | |
fill('#D6D1CD'); | |
rect(i-random(2, 3.5), l-random(2, 3.5), (windowWidth/10)/2, (windowHeight/5)/2); | |
} | |
} | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment