2D Shapes

2d shapes using Processing

Hi folks,


– here is my first attempt at 2d shapes using Processing 🙂

2D Shapes

2D Shapes


Here is the code that generated the above:

//Author: Brenda O’Neill
//Date: Friday 15th August, 2015
//Experimentation with graphics primitives and drawings

//variable declarations
float angle;
float inc;

void setup()

size(500,500); //center = 250,250

}//end of setup()

void draw()

//draw rectangle from center point
rectMode(CENTER);// rectangles drawn from the centre
rect(250,250,400,200); //starting from center position, width 400, height 200
fill(214, 223,35); //yellow
strokeWeight(2); //width of stroke around rectangle

//drawing a line
//line(x1, y1, x2, y2);
line(250,250, 450, 150);//middle to top rh corner

line(250,250,50,350); //middle to bottom lh corner

line(50,150,450,350);//Diagonal from top left hand corner to bottom right hand corner

line(250,150, 250,350);//half way line

//Draw a circle from center
triangle1(); //method call

// save your drawing when you press keyboard ‘s’
if (keyPressed == true && key==’s’) {

// erase your drawing when you press keyboard ‘r’
if (keyPressed == true && key == ‘r’) {
background(255); //set background back to blue again
}//end of drawing()

//start of triangle1()
void triangle1()
//Draw a triangle from center