Rotating a StringShape around its centerpoint (REALbasic getting started Mailinglist archive)
Back to the thread list
Previous thread: sudden crash
Next thread: Sven E Olsson
| Rotating a StringShape around its centerpoint |
| Date: 13.05.06 06:55 (Sat, 13 May 2006 07:55:21 +0200) |
| From: FreeFL |
|
Hello!
In a canvas subclass, I draw a stringshape after setting some of its properties, including Rotation. How do I set the rotation parameters to be around the xcenter-ycenter-point of the stringshape instead of its xcenter-ybaseline-point ? Thank you! _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Rotating a StringShape around its centerpoint |
| Date: 13.05.06 19:44 (Sat, 13 May 2006 11:44:13 -0700 (PDT)) |
| From: D Prowse |
|
This will give you the centre point:
(x,y) middle point >(x initial + x final)/2, (y initial + y final)/2) Not sure if this was the question. Derek FreeFL <<email address removed>> wrote: Hello! In a canvas subclass, I draw a stringshape after setting some of its properties, including Rotation. How do I set the rotation parameters to be around the xcenter-ycenter-point of the stringshape instead of its xcenter-ybaseline-point ? Thank you! _______________________________________________ Unsubscribe or switch delivery mode: Search the archives of this list here: --------------------------------- Yahoo! Mail goes everywhere you do. Get it on your phone. _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Rotating a StringShape around its centerpoint |
| Date: 13.05.06 22:47 (Sat, 13 May 2006 23:47:04 +0200) |
| From: FreeFL |
|
| 13/05/06 ~ 11:44 -0700 :
| D Prowse, | " Re: Rotating a StringShape around its centerpoint " > (x,y) middle point (x initial + x final)/2, (y initial + y final)/2) > > Not sure if this was the question. Well, this will give me the middle point of a translation, but not what I seek. When I rotate a stringshape, for example "*----_----o", it turns around a point somewhere in the underscore character, which is in the middle of the string and at the baseline height. But I want to rotate around the first * character, at the leftmost of the string and at middle height. There should be a way to set this, but I can't figure it... _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Rotating a StringShape around its centerpoint |
| Date: 14.05.06 12:37 (Sun, 14 May 2006 04:37:52 -0700) |
| From: CV |
|
On May 13, 2006, at 2:47 PM, FreeFL wrote: > | > But I want to rotate around the first * character, at the leftmost > of the string and at middle height. > There should be a way to set this, but I can't figure it... That seems to be a different rotation point than indicated in the earlier post upon which my example is based, so the math will be different. But the principal is the same: before you draw, set the Rotation and add increments to the current X, Y coords of the stringshape which relocate the stringshape so that when it is rotated about its Rb anchor point the final position will be as you want it, ie., as if the rotation had occurred around your desired rotation point. Then draw the object. I don't e-mail draw very well, but this may help to visualize things for a simple 90-degree rotation. oooo_oooo (location of string shape, s.X, s.Y) oooo_oooo (set X + deltaX, Y + deltaY, to postion stringshape here before rotation) Now draw. The displayed result of Rb's clockwise rotation about Rb's anchor will be as if the stringshape had rotated about the first character at middle height if you have computed deltaX and deltaY correctly. Best, Jack _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Rotating a StringShape around its centerpoint |
| Date: 14.05.06 23:40 (Mon, 15 May 2006 00:40:37 +0200) |
| From: FreeFL |
|
| 14/05/06 ~ 4:37 -0700 :
| CV, | " Re: Rotating a StringShape around its centerpoint " >I don't e-mail draw very well, but this may help to visualize things >for a simple 90-degree rotation. Fine, thanks! _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Rotating a StringShape around its centerpoint |
| Date: 14.05.06 23:49 (Mon, 15 May 2006 00:49:20 +0200) |
| From: FreeFL |
|
Hello!
I designed a window, MyWindow. Can I turn it into a class, so to create new windows inheriting from it and having different properties (frame) ? I would then write : class FloaterVersion with MyWindow as super, frame ' class PlainVersion with MyWindow as super, frame w dim wf as new FloaterVersion dim wp as new PlainVersion is this possible ? Thanks! _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Rotating a StringShape around its centerpoint |
| Date: 14.05.06 04:08 (Sat, 13 May 2006 20:08:55 -0700) |
| From: CV |
|
If drawn with rotation, the xcenter-ybaseline point will be the
center of rotation. So before you draw you must increment the X, Y values to new values which define the location of a stringshape of the given height rotated about its center, then draw the stringshape. I think the incrementation of the X,Y coordinates is something like this: DeltaX t*Sin(Rotation) DeltaY n*(1 - Cos(Rotation)) L is the distance from the basepoint center to the "midpoint" of the stringshape when rotated. There really isn't a definitive property for L that applies in general, so some experimentation is needed to get acceptable asthetics with the fonts, sizes, and angles that you plan to work with. Here's an example that seems half-way decent for starters on the Mac. I'm sure it can be improved: dim s as StringShape vew StringShape s.Text rAnyStringforTesting" 'whatever s.TextFont -Monoco" 'whatever s.TextSize s2 'whatever s.Rotation #.1415926535897931/4 'whatever s.X -.Width/2 - (s.TextSize/3)*sin(s.Rotation) s.Y d.Height/2 - (s.TextSize/3)*(1 - cos(s.Rotation)) + 5 g.DrawObject s //draw some reference lines for evaluation if you wish g.DrawLine g.Width/2, 0, g.Width/2, g.Height 'vertical line at initial x-center g.DrawLine 0, g.Height/2, g.Width, g.Height/2 Best regards, Jack On May 12, 2006, at 10:55 PM, FreeFL wrote: > Hello! > > In a canvas subclass, I draw a stringshape after setting some of > its properties, including Rotation. > How do I set the rotation parameters to be around the xcenter- > ycenter-point of the stringshape instead of its xcenter-ybaseline- > point ? > _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
Links
MBS Realbasic PDF Plugins - Nachhilfe in Andernach