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 › Question about PShape and rotation
Pages: 1 2 
Question about PShape and rotation (Read 2148 times)
Re: Question about PShape and rotation
Reply #15 - Feb 24th, 2009, 10:13pm
 
may be it's just a bug?

after changing pshape mode to center, it's drawing center in the center of shape, but rotating center is still left top corner...
Re: Question about PShape and rotation
Reply #16 - Feb 25th, 2009, 6:58am
 
here is a way to do it:
www.kubrusly.com/vicente/rotating_shape/
is this what you need?
Quote:
PShape s;
int x;
void setup(){
 s = loadShape("teste400.svg");// a shape with original size 400x400 pixels!
 size(400,400);
 background(150,80,80);
 smooth();
}
void draw(){
 shape(s, -200, -200);// this shape BEFORE pushMarix() is not afected by
 //translate rotate etc. also this is behind
 // it has it center in point x=0, y=0

   x++;
 pushMatrix();
 scale(0.5);
 translate(mouseX*2,mouseY*2);//move shape arround with the axis attached  
 rotate(radians(x));//rotate as your will
 shape(s, -200, -200);// place shape with center at point 0,0
 popMatrix();

 shape(s, 200, 200);// this shape AFTER popMarix() is not afected
 //by translate rotate etc. and this in front of
}


Re: Question about PShape and rotation
Reply #17 - Feb 25th, 2009, 1:05pm
 
vicente, I already shown this way in this thread, but for some reason sonomute doesn't want to use it.
He wants to use PShape's built in transform methods. Why not.
I haven't tried them yet, I will soon to test a bit and help.
But I suspect these are cumulative transforms, ie. once a rotate have been made, the shape remains rotated.
Re: Question about PShape and rotation
Reply #18 - Feb 26th, 2009, 12:02am
 
Hey guys! Thank you very much for you helping stupid sound artist to get his head into something he understand less and less Smiley))

My reasons are simple- it just looks much more "natural" and straightforward when you can manipulate with objects like in real world(i think this is some of the main points of OO programming), where to rotate object you...rotating it, not it's matrix or something:)))

This is answer from Fry:

no, your code is incorrect. bot.rotate() will affect the rotation matrix of
the shape itself, while shapeMode() is acting on the graphics context (not
the shape). your code should be:

float r;

void draw() {
background(200);
shapeMode(CENTER);
rotate(r);
shape(bot, width/2, height/2);
r += radians(1);
}

confusing...looks like all those creative coding tools still not so high-level as i was hoping...

I just need something to create good-looking graphical interfaces for my sound software pieces and generate visuals for my music may be...and don't really want to use flash(unless somebody will give me a free license Smiley)

Re: Question about PShape and rotation
Reply #19 - Feb 26th, 2009, 12:59am
 
I may have missed this somewhere in the thread, but has sonomute checked how the shape itself is defined relative to the SVG file's internal coordinate system?

If PShape.rotate() always rotates around the top left corner--which implies that this location is (0,0) for the SVG file itself--then the obvious solution is to make sure that the shape is itself centered on 0,0.

If the shape isn't centered on its own coordinate system, then duh, getting it to rotate around its own center is going to involve an extra translation.

If Sonomute doesn't want to use the pushMatrix/popMatrix combination, then verifying how the SVG files are constructed is probably necessary here.
Re: Question about PShape and rotation
Reply #20 - Feb 27th, 2009, 5:09am
 
I found solution, with help of cloister of course!

Thing really was in structure of svg file...

i've added this line of code: <g transform="translate(-35,-35)"> to my file, editing it in texteditor, and it works!

here the link to web page where i found about transformations inside of svg format:
http://www.w3.org/TR/SVG/coords.html

Thank you very much, guys!
Re: Question about PShape and rotation
Reply #21 - Feb 27th, 2009, 8:39am
 
Good solution. Better than asking Processing to rotate around center, because it might not be appropriate to the task: you might want to rotate a spaceship, a clock hand, etc. around some arbitrary point, not necessarily the center.
Re: Question about PShape and rotation
Reply #22 - Feb 27th, 2009, 2:17pm
 
Now i'm wondering, if it is possible to communicate between processing and svg  getting some data from inside or send parameters to svg script...it will be awesome! must check reference...Thanx again!
Re: Question about PShape and rotation
Reply #23 - Feb 27th, 2009, 5:12pm
 
it looks like this trick works only with basic shape... as soon i trying to do same with svg containing two child elements in it this transform method not helping...digging into svg scripting...
Re: Question about PShape and rotation
Reply #24 - Feb 27th, 2009, 5:25pm
 
The answer was too simple..Smiley))

just edited my svg in illustrator, moved both elements so their center now at 0,0...now rotating around center! haha
Pages: 1 2