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 & HelpSyntax Questions › how to define a beginshape as a name
Page Index Toggle Pages: 1
how to define a beginshape as a name (Read 607 times)
how to define a beginshape as a name
Jun 7th, 2007, 6:02pm
 
i have drawn a shape with beginshape
but for transform functions i want to define this shape as a name
and place this shape in the transform functions
how can i do that
thanks
Re: how to define a beginshape as a name
Reply #1 - Jun 7th, 2007, 8:23pm
 
i think what you want to do is pass arrays of shape coordinates (which will have names) to the transform functions. the beginShape(), vertex(), endShape() functions are for handling the drawing.

you could also encapsulate the process within a Shape class, including some transform methods.

there are also more complex approaches–using separate Shape, Transform, Matrix, etc classes.
Re: how to define a beginshape as a name
Reply #2 - Jun 7th, 2007, 9:52pm
 
what i want is defining a complex shape as a word

like defining

beginShape(LINES);
vertex(x, y);
...
endShape

such as complexshape and put the complexshape to a coordinate i like just by calling its shortcut

i did it without defining it that short way but this way it would be better
Re: how to define a beginshape as a name
Reply #3 - Jun 7th, 2007, 10:13pm
 
You can't define it as a word I'm afraid, but you can put it into a function to achieve the result:

Code:

void myShape()
{
beginShape(LINES);
// etc etc
endShape();
}

void draw()
{
pushMatrix();
translate(20,40,0);
myShape();
popMatrix();
pushMatrix();
rotateZ(0.524);
translate(-3,50,0);
myShape();
popMatrix();
//etc etc...
}
Re: how to define a beginshape as a name
Reply #4 - Jun 7th, 2007, 10:54pm
 
thanks for your answers they helped a lot
Page Index Toggle Pages: 1