Created
April 19, 2016 15:14
-
-
Save nick3499/6766e7f22f12bd17b62c8b7b6d1a8d27 to your computer and use it in GitHub Desktop.
Triangle.Using p5.js library.
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
| function setup() { | |
| createCanvas(720, 400); | |
| } | |
| function draw() { | |
| background(0, random(128, 255), random(128, 255)); | |
| noStroke(0); | |
| for (var i = 0; i < 20; i++) { | |
| // triangle a | |
| var x1 = random(0, 360); | |
| var y1 = random(0, 200); | |
| var x2 = random(360, 720); | |
| var y2 = random(200, 400); | |
| var x3 = random(0, 360); | |
| var y3 = random(0, 200); | |
| // triangle b | |
| var x4 = random(360, 720); | |
| var y4 = random(0, 200); | |
| var x5 = random(0, 360); | |
| var y5 = random(200, 400); | |
| var x6 = random(360, 720); | |
| var y6 = random(0, 200); | |
| fill(random(0, 128), random(128, 255), random(0, 128), random(50, 150)); | |
| triangle(x1, y1, x2, y2, x3, y3); | |
| triangle(x4, y4, x5, y5, x6, y6); | |
| } | |
| frameRate(1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment