Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                
              
            
!

CSS

              
                body{margin:0;}
canvas{display: block;}
              
            
!

JS

              
                /* 
Birds - for Dress of Life
Vivian Wong
Professor Adam Tindale, Kate Hartman, Haru Ji
DIGF 2004 - Atelier I
Wednesday December 6, 2017

References:
https://www.openprocessing.org/sketch/156688 Wings by Michael Pin
https://p5js.org/reference/#/p5/smooth
*/

let len = 110;    // variable len at 110 for length of wings
let t;            // variable t to control speed

function setup() {
  canvas = createCanvas(windowWidth, windowHeight);
  stroke(200);    // white stroke colour
  smooth();       // anti-aliased edges
  t = 0;          // initialize variable t at 0
}

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

  // push and pop each bird with specified parameters
  push();
  birdy(width/2, height + 220 - t/1.4, 1);
  pop();
  
  push();
  birdy(width/2 + 20, height +400 - t, 1.5);
  pop();
  
  push();
  birdy(width/2 - 20, height + 360 - t, 1.5);
  pop();
  
  push();
  birdy(width/2 - 45, height + 550 - t*1.1, 2);
  pop();
  
  push();
  birdy(width/2 + 45, height + 525 - t, 2);
  pop();

  t += 2; // increment variable t by 2
}

// function to draw birds onto canvas, using variable w and h for translate parameters, and s for size parameters

function birdy(w, h, s) {
  translate(w, h);
  for (let q = 0; q < len; q += 1.99) {
    angle = cos(radians(len-q+frameCount*3)) * q;
    
    // set x and y positions for both wings according to angle
    // size of each wing is defined by q/s
    let x = sin(radians(-90-angle))*(q/s);
    let y = cos(radians(-90-angle))*(q/s);
    let x2 = cos(radians(-angle))*(q/s);
    let y2 = sin(radians(-angle))*(q/s);
    
    stroke(255);                  // white coloured stroke
    fill (50+q*2, 20+q, 30, 100); // orange-y brown fill colour
    
    // last two parameters of bezier function divided by 1.5 allows for overlay of orange fill colour
    // right wing
    bezier(-10, 0, x/2, y/2, x/2, y/2, x/1.5, y/1.5);
    // left wing
    bezier(10, 0, x2/2, y2/2, x2/2, y2/2, x2/1.5, y2/1.5);
  }
}
              
            
!
999px

Console