I was still exploring other commands in this language and decided to go old-school and decided to draw a simple house with easy shapes..which turns out was’nt that easy and I had to really brush my mathematical skills a little but that was just the beginning of it :P
The first image above shows the final output and I will now share some progress images and some of my experiences while doing it.
I started off with a base line which I decided to place at 3/4th point on the canvas and began to draw a rectangle defining the coordinates of the same.
I then studied function of triangle and quads and worked on some math to place them correctly... after a few of trial and errors I came up with the triangle in the second picture (struggled a little bit to set the angles of triangles and Quad right)
The thing that really helped me in staying focused is that I knew what my end product was.. it was then just a matter of understanding the math and logic behind it.
I began to first understand the concept of how functions like triangle, Quad, Line works and then figuring out the coordinates and that saved a lot of time of trial and errors. As much as fun it is to review the trial and error stages I feel like if the concept is clear it is easier to navigate and try more options.
Also i felt that understanding the canvas size and then coding in relative to the size of canvas was helpful.
I thought drawing a line must not be that hard, but turns out it actually is a little hard to get it right in the first go!
So.. here it is my First house in the Java.! Hope you guys like my experience! :)
Here is the code for those who are interested:
void setup() {
size(800, 600);
}
void draw() {
fill(#8D5725);
//firstdoor
rect(width/3, height/2, 80, 120);
fill(#FFE745);
rect((width/2)-120, (height/3)+160, 40, 60);
fill(#8D5725);
//roof
triangle(width/3, height/2, (width/3)+40, height/3, (width/3)+80, height/2);
fill(#8D5725);
rect((width/3) + 80, height/2, 250, 120);
fill(#CD6A0F);
quad((width/3)+40, height/3, (width/3)+290, height/3, (width/3)+330, height/2, (width/3)+80, (height/2));
fill(#000000);
textAlign(CENTER);
textSize(50);
text("The House", width/2, 500);
fill(#FFE745);
ellipse(width/4, height/6, 100, 100);
line(0, 420, width, 420);
}