
2d shapes using Processing
Hi folks,
– here is my first attempt at 2d shapes using Processing 🙂
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;
//Methods
void setup()
{
size(500,500); //center = 250,250
background(255);
}//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
strokeWeight(1);
//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
fill(#EA9D0C);
ellipse(250,250,150,150);
triangle1(); //method call
// save your drawing when you press keyboard ‘s’
if (keyPressed == true && key==’s’) {
saveFrame(“yourName.jpg”);
}
// 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
//noStroke();
fill(#0E9D27);
triangle(250,250,450,350,50,350);
fill(215,223,35);
}