Posts

0005-JS-P5E-CreateGraphics

Image
  let  pg; /* Use this class if you need to draw into an off-screen graphics buffer.  The two parameters define the width and height in pixels. */ function  setup() {   createCanvas( 710 ,  400 );   pg = createGraphics( 400 ,  250 ); } function  draw() {   fill( 0 ,  12 );   rect( 0 ,  0 , width, height);   fill( 255 );   noStroke();   ellipse(mouseX, mouseY,  60 ,  60 );   pg.background( 51 );   pg.noFill();   pg.stroke( 255 );   pg.ellipse(mouseX -  150 , mouseY -  75 ,  60 ,  60 );    //Draw the offscreen buffer to the screen with image()   image(pg,  150 ,  75 ); }

0004-JS-P5E-Recursion

Image
  function  setup() {   createCanvas( 720 ,  560 );   noStroke();   noLoop(); } function  draw() {   inputParamsEllipse( 360 ,  280 ,  6 ); } function  inputParamsEllipse(xPos, radius, level) {    const  tt = ( 126  * level) /  4.0 ;   fill(tt);   ellipse(xPos, height /  2 , radius *  2 , radius *  2 );    if  (level >  1 ) {     level = level -  1 ;     inputParamsEllipse(xPos - radius /  2 , radius /  2 , level);     inputParamsEllipse(xPos + radius /  2 , radius /  2 , level);      // xPos = 360; radius = 280;level=6    ...

0003-JS-P5E-Function

Image
  function  setup() {   createCanvas( 720 ,  400 );   background( 51 );   noStroke();   noLoop(); } function  draw() {    // ellipse(x, y, w, [h])    /*     Parameters     x Number: x-coordinate of the center of ellipse.     y Number: y-coordinate of the center of ellipse.     w Number: width of the ellipse.     h Number: height of the ellipse. (Optional)   */   drawTarget(width *  0.25 , height *  0.4 ,  200 ,  4 );  // Draw 4 Ellipses,width 50   drawTarget(width *  0.5 , height *  0.5 ,  300 ,  10 );  // Draw 10 E...