Last active
October 6, 2017 18:16
-
-
Save zootsuitproductions/a28e8c12c5ebcced4fa9f78a69018e26 to your computer and use it in GitHub Desktop.
Daniel Santana Computing Textile Leaf pattern
This file contains 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
let canvasX = 2500 | |
let canvasY = 2500 | |
function setup() { | |
createCanvas(canvasX,canvasY); | |
translate(canvasX/2,canvasY/2); | |
//makes origin in the center of the canvas | |
angleMode(DEGREES) | |
noFill(); | |
makePlant(-800,0,400); | |
} | |
var plantProperties = { | |
curve1: [[0,50],[-15,50],[-50,50]], | |
curve2: [[0,45],[-50,50]], | |
vertex: [10,0], | |
rotation: 10, | |
originalRotation: 10, | |
separationOfLeaves: 10 | |
//these can be altered (except vertex y) to produe the desired leaves | |
} | |
function makeLeafSection() { | |
rotate(-90) | |
translate(-plantProperties.curve1[2][0],-plantProperties.curve1[2][1]) | |
beginShape() | |
vertex(plantProperties.vertex[0],plantProperties.vertex[1]) | |
bezierVertex(plantProperties.curve1[0][0],plantProperties.curve1[0][1],plantProperties.curve1[1][0],plantProperties.curve1[1][1],plantProperties.curve1[2][0],plantProperties.curve1[2][1]) | |
bezierVertex(plantProperties.curve2[0][0],plantProperties.curve2[0][1],plantProperties.curve2[1][0],plantProperties.curve2[1][1],plantProperties.vertex[0],plantProperties.vertex[1]) | |
endShape() | |
translate(plantProperties.separationOfLeaves,abs((plantProperties.vertex[1]-plantProperties.curve1[1][1])*2)) | |
//moves over by twice the width of the flower to draw before rotating | |
rotate(180) | |
beginShape() | |
vertex(-plantProperties.vertex[0],plantProperties.vertex[1]) | |
bezierVertex(plantProperties.curve1[0][0],plantProperties.curve1[0][1],-plantProperties.curve1[1][0],plantProperties.curve1[1][1],-plantProperties.curve1[2][0],plantProperties.curve1[2][1]) | |
bezierVertex(plantProperties.curve2[0][0],plantProperties.curve2[0][1],-plantProperties.curve2[1][0],plantProperties.curve2[1][1],-plantProperties.vertex[0],plantProperties.vertex[1]) | |
//makes the opposite of the first plant | |
endShape() | |
rotate(180) | |
translate(-plantProperties.separationOfLeaves,-abs((plantProperties.vertex[1]-plantProperties.curve1[1][1])*2)) | |
rotate(90) | |
translate(-plantProperties.curve1[2][0],plantProperties.curve1[2][1]) | |
//undos previous translations and rotations | |
translate(0,-abs((plantProperties.vertex[1]-plantProperties.curve1[1][1])/2)) | |
//makes next plant go up | |
} | |
function makePlant(x,y,height) { | |
translate(x,y) | |
strokeWeight(0.5) | |
for (var i = 1; i <= height; i ++) { | |
makeLeafSection() | |
//rotate(plantProperties.rotation) | |
if (i % 30 == 0 && i % 90 != 0) { | |
for (var x = 1; x <= 18; x ++) { | |
makeLeafSection() | |
rotate(5); | |
} | |
} | |
//makes a 1:3 width to height ratio rect with rounded corners | |
} | |
} | |
function draw() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
by changing these numbers
if (i % 30 == 0 && i % 120 != 0) {
I was able to get one rectangle that's 1:4, smaller. I'm not sure if it's making that before or after the other curves. But it's a start?