Skip to content

Instantly share code, notes, and snippets.

@zootsuitproductions
Last active October 10, 2017 04:34
Show Gist options
  • Save zootsuitproductions/e30f2a438c499cd65d115deea3003361 to your computer and use it in GitHub Desktop.
Save zootsuitproductions/e30f2a438c499cd65d115deea3003361 to your computer and use it in GitHub Desktop.
Danny Playing Card Pattern
let canvasX = 3000
let canvasY = 3000
var increasingRotation = 2
//Will be increased and used to rotate the cancas when creating the wing shape
var lastPoint = [0,0]
var y = -116;
var negative = false
var transX = 0
var transY= 200
var iteration = 0
var increasingRot = 0
var hasMadeTheShape = false
let rotation = 1
function setup() {
createCanvas(canvasX,canvasY);
translate(canvasX/2,canvasY/2);
//makes origin in the center of the canvas
angleMode(DEGREES)
noFill();
makeWing(0,0,60,2)
makePlant(-790,0,400);
}
var plantProperties = {
curve1: [[0,50],[-15,50],[-50,50]],
curve2: [[0,50],[-50,50]],
vertex: [0,-10],
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 makeFeather() {
strokeWeight(1);
rotate(-90)
translate(-plantProperties.curve1[2][0],-plantProperties.curve1[2][1])
fill(255)
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(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 makeWing(x,y,height,quantityOfWings) {
push();
translate(x,y);
for (var x = 1; x <= quantityOfWings; x ++) {
push();
for (var i = 1; i <= height; i ++) {
makeFeather();
translate(0,abs((plantProperties.vertex[1]-plantProperties.curve1[1][1])/2)-5);
rotate(increasingRotation);
plantProperties.vertex[0] += 10
increasingRotation = increasingRotation*1.03 -0.12
}
pop()
//resets canvas
rotate(360/quantityOfWings);
//rotates for future iterations of pattern
increasingRotation = 2
plantProperties.vertex[0] = 0
//resets the values of these variables
}
pop()
}
function makePlant(x,y,height) {
push()
translate(x,y);
//translate((x-abs((plantProperties.vertex[1]-plantProperties.curve1[1][1])/2)*50)/2,y)
strokeWeight(1);
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
}
pop()
}
function draw() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment