We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Objects from primitive shape.
Page Index Toggle Pages: 1
Objects from primitive shape. (Read 692 times)
Objects from primitive shape.
May 13th, 2009, 6:15am
 
It is possible to create object from primitive shapes? What I want to achieve is something link this:

Code:

class MyClass {
Shape square;

MyClass(int size) {
square = new rect(size, size);
}

void draw() {
// draw....
square.draw();
}
}

MyClass class;

void setup() {
class = new MyClass(5);
}

void draw() {
class.draw();
}


For what I understood if I call rect(x, x) in draw() method it will paint a rect in the screen. But how can I create object composed by rect()? Do I build basic shape from scratch?

Thanks.
Re: Objects from primitive shape.
Reply #1 - May 13th, 2009, 6:59am
 
Indeed, the idea is to draw each base shape in the draw() method of your class.
Re: Objects from primitive shape.
Reply #2 - May 13th, 2009, 12:57pm
 
PhiLho  wrote on May 13th, 2009, 6:59am:
Indeed, the idea is to draw each base shape in the draw() method of your class.


Right. But if i.e. I apply a rotate(angle) into one draw method it will rotate all shapes in all classes...
Re: Objects from primitive shape.
Reply #3 - May 13th, 2009, 1:48pm
 
See:

http://processing.org/reference/pushMatrix_.html
and
http://processing.org/reference/popMatrix_.html
Page Index Toggle Pages: 1