Last active
September 16, 2021 11:38
-
-
Save autf/65ec7dbbaca6a478a7fd829df40dbf25 to your computer and use it in GitHub Desktop.
Exercise 6.1 < 6.3 Translation < edX NYUx DMEDX6063 Creative Coding
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(500, 500) | |
background('lightgray') | |
} | |
function draw() { | |
let side = 300 | |
let third = side / 3 | |
noStroke() | |
translate(100, 100) | |
apply(0, 0, tag, third) | |
apply(0, 2 * third, tag, third) | |
apply(2 * third, third, tag, third) | |
} | |
const tag = (side) => | |
triangle(0, 0, 0, side, side, side / 2) | |
function apply(x0, y0, fn, ...args) { | |
push() | |
translate(x0, y0) | |
fn.apply(null, args) | |
pop() | |
} |
Author
autf
commented
Sep 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment