Skip to content

Instantly share code, notes, and snippets.

@ndrhzn
Last active January 5, 2019 22:31
Show Gist options
  • Save ndrhzn/8cc7041a70ba029253d2fb107ce9a466 to your computer and use it in GitHub Desktop.
Save ndrhzn/8cc7041a70ba029253d2fb107ce9a466 to your computer and use it in GitHub Desktop.
P5 - Jittering Lines
<!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 Lines</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(5);
};
function draw() {
background(256);
strokeWeight(0.5);
for (i = 0; i < windowWidth; i+= random(1, 2)) {
for(l = 0; l < windowHeight; l+= random(39, 40)) {
push();
translate(0, random(5, 10));
stroke(color(0, 0, 255, random(0, 100)));
line(i, l, i + random(20, 25), l + random(20, 25));
stroke(color(0, 0, 255, random(0, 50)));
line(i + random(25, 20), l + 25, i, l + 25 + random(25, 20));
pop();
}
}
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment