Last active
May 4, 2017 03:00
-
-
Save GoSubRoutine/367742ecc1a78c303dc100cefc3e20cd to your computer and use it in GitHub Desktop.
Daisy Flower
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
height: 650 |
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
<script async src=http://CDN.JSDelivr.net/p5.js/latest/mainfile></script> | |
<script defer src=sketch.js></script> |
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
/** | |
* Daisy Flower (v2.0.3) | |
* by EdHebert (2017-Feb-18) | |
* mod GoToLoop | |
* | |
* forum.Processing.org/two/discussion/20864/ | |
* why-is-this-stem-drawing-on-top-of-the-petals-line-fill-question#Item_1 | |
* | |
* CodePen.io/GoSubRoutine/pen/BpevPE/right?editors=001 | |
* CodePen.io/edhebert/pen/GraYLZ/right?editors=001 | |
* | |
* Bl.ocks.org/GoSubRoutine/367742ecc1a78c303dc100cefc3e20cd | |
*/ | |
"use strict"; | |
const Petal = Object.freeze({ X: 120, Y: 0, W: 150, H: 75, A: .25*Math.PI }), | |
BUD_DIAM = 130, STEM_OFFSET = 15, STEM_BOLD = 20; | |
let Color, cx, cy; | |
function setup() { | |
createCanvas(400, 650); | |
noLoop(); | |
if (frameElement) { | |
frameElement.width = document.body.scrollWidth; | |
frameElement.height = document.body.scrollHeight; | |
} | |
strokeWeight(STEM_BOLD).strokeCap(PROJECT); | |
ellipseMode(CENTER)//.blendMode(REPLACE); | |
Color = Object.freeze({ | |
BG: Object.freeze(color(0)), | |
STEM: Object.freeze(color('green')), | |
PETAL: Object.freeze(color('#8DF')), | |
BUD: Object.freeze(color('yellow')) | |
}); | |
cx = width>>1, cy = height>>1; | |
} | |
function draw() { | |
background(Color.BG).translate(cx, cy); | |
stroke(Color.STEM).line(0, 0, 0, cy - STEM_OFFSET); | |
fill(Color.PETAL).noStroke().push(); | |
for (let a = 0; a < TAU; a += Petal.A) | |
rotate(Petal.A).ellipse(Petal.X, Petal.Y, Petal.W, Petal.H); | |
pop(); | |
fill(Color.BUD).ellipse(0, 0, BUD_DIAM); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment