Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.




canvas{display: block;}


Glow Flower - for Dress of Life
Vivian Wong, Anran Zhou
Professor Adam Tindale, Kate Hartman, Haru Ji
DIGF 2004 - Atelier I
Wednesday December 6, 2017


Algorithm of creating the flower adapted from Dancing Flame by aadebdeb

Modified the form and colour/behaviour of the flower. Flower size had to be
small to fit dress mask shape.

let offset1;        // init variable offset1 for layers
let offset2;        // init variable offset2 for layers
let scale = 0.01;   // init variable scale to change shape of flower
let size = 0.0001;  // init variable size to manipulate flower shape
let c1;             // init variable c1 for inner colour
let c2;             // init variable c2 for outer colour

let t;              // variable t used to manipulate noise functions

function setup() {
  canvas = createCanvas(windowWidth, windowHeight); // set up canvas
  background(128);  // start with grey background
  noStroke();       // remove stroke
  t = 0;            // set initial t value as 0
  //generate random offset value for vertexes of the flower
  offset1 = new createVector(random(10000), random(10000));
  offset2 = new createVector(random(10000), random(10000));
  // set intial colours
  c1 = color(4, 13, 190);
  c2 = color(21, 121, 194);

function draw(){
  background(0);    // set background colour to black

  // set c1 and c2 colours to change
  c1 = color(150, 350*noise(t), 400*noise(205+t)); 
  c2 = color (30, 300*noise(151+t),500*noise(204+t)); 

  // put flower at center of canvas
  translate(width / 2, height / 2);
  // use for loop to set up coloured layers on the flower
  for(var radius = 250; radius > 0; radius -= 10){
    // set fill colour mapped according to each RGB value of c1 and c2
    fill(map(radius, 0, 250, red(c1), red(c2)),
         map(radius, 0, 250, green(c1), green(c2)),
         map(radius, 0, 250, blue(c1), blue(c2))
    beginShape(); // start drawing each shape
    // double for loop to create shape of flower according to angle and radius
    for(var angle = 0; angle < 360; angle += 0.5){
      var radian = radians(angle);  
      //set the x and y position of the vertex
      var x = radius * cos(radian);
      var y = radius * sin(radian);
      //set nx, ny as the original position plus the offset generated randomly to create more natural but random value
      var nx = x + map(noise(x * scale + offset1.x, y * scale + offset1.y, frameCount * 0.015), 0, 1, -200, 200);
      var ny = y + map(noise(x * scale + offset2.x, y * scale + offset2.y, frameCount * 0.015), 0, 1, -200, 200);
      vertex(nx/4, ny/4);    // changing vertex parameters modifies size of flower
    scaleTo();    // call scaleTo function to gradually change flower shape
   t += 0.01;     // increment t variable by 0.01 to change colour in noise function

// this function allows animation to start off as an organic shaped flower and become more geometric by manipulating the scale value

function scaleTo(){
  // if the scale of the geometric pattern is bigger than 0.05, start getting smaller
  scale += size;
  if (scale >= 5){
    size * -1;
  // if the flower is getting too small too much, then stop the shrink function
  if (scale <= 0.01) {
    size * -1;

// // can uncomment to use mousePressed function to manually change flower colour
// function mousePressed(){
//   c1 = color(noise(255), random(255), random(255));
//   c2 = color(random(255), random(255), random(255));
// }