// set (x,y) at the stage center
var x = width/2;    // width is predefined (default=400)
var y = height/2;   // height is predefined (default=400)
// draw guides
stroke(0, 0, 255);   // blue
line(0, y, width, y);  // horizontal line (x position changes)
line(x, 0, x, height);  // vertical line (y position changes)Draw guides to help visualize the shape position
Type the code below into a [new program]
stroke() and line() are function calls to the Processing Library
Code gets complex very quickly
Organize early and keep it organized
// set (x,y) at the stage center
var x = width/2;    // width is predefined (default=400)
var y = height/2;   // height is predefined (default=400)
var drawGuides = function (x, y) {
    stroke(0, 0, 255);   // blue
    line(0, y, width, y);  // horizontal line (x position changes)
    line(x, 0, x, height);  // vertical line (y position changes)
};
drawGuides(x,y);            // center 
drawGuides(x/2, y/2);       // top left
drawGuides(x*3/2, y*3/2);   // bottom rightNote open and closing curly braces with semicon { ... };
Set variables x, y to be at the stage center
Define function drawGuides
Type drawing commands inside the function body
Call function drawGuides() with different arguments and notice the resulting grid
Define function drawCar 
before calling it
var drawGuides = function (x, y) { ... };
var drawCar = function (x, y) {
    // set draw modes
    noStroke();         // fill only, no shape outlines
    rectMode(RADIUS);
    ellipseMode(RADIUS);
    fill(255, 0, 0); // red
    ellipse(x, y, 100, 40); // car body
    
    fill(0, 0, 0); // black
    ellipse(x - 45, y + 30, 30, 30); // left tire
    ellipse(x + 45, y + 30, 30, 30); // right tire
    
    fill(255, 255, 0); // yellow
    ellipse(x - 45, y + 30, 20, 20); // left wheel
    ellipse(x + 45, y + 30, 20, 20); // right wheel
};
drawCar(x,y);     
drawGuides(x,y);   // must be drawn lastDo not define drawGuides() again. "..." means code previously shown is now hidden to save space
Call drawGuides() before calling drawCar() so that the guides are shown on top of the car. Try reversing the order.
var drawCar = function (x, y) {
    // set draw modes
    // draw car body
    // draw tires and wheels
    // draw car top and windows
    //   (x1,y1) is position of car top, relative to car body
    var x1 = x - 60; 
    var y1 = y - 30;
    
    fill(255, 0, 0);  // red car top
    quad(x1, y1, x1+120, y1, x1+100, y1-50, x1+20, y1-50);
    
    fill(0,255,255); // aqua windows
    quad(x1+10, y1, x1+50, y1, x1+50, y1-45, x1+25, y1-45);
    quad(x1+60, y1, x1+110, y1, x1+93, y1-45, x1+60, y1-45); 
};These comments represent code previously shown
Change the argument values and see how the shape changes
Draw a quadrilateral* with arguments relative to (x1,y1); [*quad]
You have learned
Please enter Cool Red Car for Exercise Name