nick34992
4/20/2016 - 5:28 AM

Dot Notation. Using p5.js library.

Dot Notation. Using p5.js library.

// global variables for ellipse and colors
var e = { x: 0, y: 360, d: 100 };
var c1 = { r: 0, g: 255, b: 255 };
var c2 = { r: 255, g: 255, b: 0 };

function setup() {
  createCanvas( 1280, 720 );
}

function draw() {
  // dot notation
  background( c1.r, c1.g, c1.b );
  fill( c2.r, c2.g, c2.b );
  noStroke();
  ellipse( e.x, e.y, e.d, e.d );
  // ellipse velocity algorithm
  e.x = e.x + 0.125;
  fill(0);
  textSize(36);
  text( 'dot notation accesses properties:', 25, 50 );
  text( 'background color, ellipse location/fill and velocity algorithm.', 25, 100 );
  text( 'background(c1.r, c1.g, c1.b);', 150, 150 );
  text( 'fill(c2.r, c2.g, c2.b);', 150, 200 );
  text( 'ellipse(e.x, e.y, e.d, e.d);', 150, 250 );
  text( 'e.x = e.x + 0.125;', 150, 300 );
}