Created
April 19, 2016 15:02
-
-
Save nick3499/5ea2ee976997c8b9a928b17ecfd40e75 to your computer and use it in GitHub Desktop.
Begin Shape Quads. 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
| var x = 100; | |
| var y = 50; | |
| function setup() { | |
| // decreased resolution = increased performance | |
| createCanvas(896, 504); | |
| } | |
| function draw() { | |
| background(0); | |
| // locations extend beyond canvas | |
| for (i = 0; i < 300; i++) { | |
| trapezoid(random(-50, 950), random(-50, 600)); | |
| } | |
| // decreased frame rate = increased performance | |
| frameRate(10); | |
| } | |
| // constructor with axis attributes | |
| function trapezoid(x, y) { | |
| noStroke(); | |
| // random shades of green | |
| fill(0, random(255), 0, 100); | |
| // create quadrangles/trapezoids | |
| beginShape(QUADS); | |
| vertex(x - 0, y - 0); | |
| vertex(x + 100, y - 0); | |
| vertex(x + 150, y - 150); | |
| vertex(x - 50, y - 150); | |
| endShape(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment