Rotate 3 graphics as group
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Rotate 3 graphics as group
Hi
Is it possible to rotate a group?
I'm having 3 graphic object joined together as one, but I can't figure out how to make the group (of graphic objects) to rotate.
// Joran
Is it possible to rotate a group?
I'm having 3 graphic object joined together as one, but I can't figure out how to make the group (of graphic objects) to rotate.
// Joran
Re: Rotate 3 graphics as group
Hi Joran,
But you could take a screenshot of your group and rotate that image, if that is an option?
Best
Klaus
unfortunately no!joran wrote:Is it possible to rotate a group?
But you could take a screenshot of your group and rotate that image, if that is an option?
Best
Klaus
Re: Rotate 3 graphics as group
Ok, thought it might be so.
Thanks anyway
Thanks anyway
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Rotate 3 graphics as group
Might this be a useful new feature to ask for?
Craig Newman
Craig Newman
Re: Rotate 3 graphics as group
... and also be great rotate a FIELD (with text, of course)
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Rotate 3 graphics as group
Currently one can only do a 'set the angle' or a 'rotate' with an image.
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Rotate 3 graphics as group
It is possible to rotate a group, that containes "rotatable" objects (images, graphics).
Requires some scripting, not too hard.
For example look into Malte's Animation Engine, which is available on github now:
https://github.com/derbrill/animationEngine
There is code for groups containing graphics that you can use also for images (alike rectangle graphics).
It's not the same as rotating each object in the group by the same angle, but you'll get nice 'unusual' effects with the latter.
Requires some scripting, not too hard.
For example look into Malte's Animation Engine, which is available on github now:
https://github.com/derbrill/animationEngine
There is code for groups containing graphics that you can use also for images (alike rectangle graphics).
It's not the same as rotating each object in the group by the same angle, but you'll get nice 'unusual' effects with the latter.
shiftLock happens
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Rotate 3 graphics as group
Probably not that difficult to ungroup the group, rotate the objects round a point, and then regroup them.
??? http://forums.livecode.com/viewtopic.ph ... 793#p21326
??? http://forums.livecode.com/viewtopic.ph ... 793#p21326
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Rotate 3 graphics as group
Hey: why slave away to do something that somebody has already done?
http://lists.runrev.com/pipermail/use-l ... 66416.html
The script below will allow you to rotate an image about any predefined point.
Create a button.
Create an image.
Place the button at any point relative to the image. (Perhaps use a grab me in a mousedown handler.)
Click the button.
The image will rotate about the center of the button.
(For your application you would replace the center of rotation with the center of mass.)
on mouseUp
set the angle of img 1 to 0
put the loc of me into myLoc
--Set the coor of the rotation Pt
put item 1 of myLoc into x0
put item 2 of myLoc into y0
--Get the loc of the image
put the loc of img 1 into tLoc
put item 1 of tLoc into xC
put item 2 of tLoc into yC
--Get the distance between the roation pt and the image center
put sqrt ( (xC - x0 )^2 + (yC - y0)^2 ) into L
--Get the angle of the line from the rotation center to the image center
put atan2(yC-y0, xC-x0) *180/pi into phi0
put 0 into tAngle
repeat 360 times
lock screen
set the angle of img 1 to -tAngle
put phi0 + tAngle into phi
set the loc of img 1 to (x0 + L * cos(phi*pi/180)), (y0 + L * sin(phi*pi/180))
unlock screen
add 1 to tAngle
wait 10 millisec --or whatever
end repeat
end mouseUp
on mouseDown
grab me --So that you can relocate the rotation center.
end mouseDown
http://lists.runrev.com/pipermail/use-l ... 66416.html
The script below will allow you to rotate an image about any predefined point.
Create a button.
Create an image.
Place the button at any point relative to the image. (Perhaps use a grab me in a mousedown handler.)
Click the button.
The image will rotate about the center of the button.
(For your application you would replace the center of rotation with the center of mass.)
on mouseUp
set the angle of img 1 to 0
put the loc of me into myLoc
--Set the coor of the rotation Pt
put item 1 of myLoc into x0
put item 2 of myLoc into y0
--Get the loc of the image
put the loc of img 1 into tLoc
put item 1 of tLoc into xC
put item 2 of tLoc into yC
--Get the distance between the roation pt and the image center
put sqrt ( (xC - x0 )^2 + (yC - y0)^2 ) into L
--Get the angle of the line from the rotation center to the image center
put atan2(yC-y0, xC-x0) *180/pi into phi0
put 0 into tAngle
repeat 360 times
lock screen
set the angle of img 1 to -tAngle
put phi0 + tAngle into phi
set the loc of img 1 to (x0 + L * cos(phi*pi/180)), (y0 + L * sin(phi*pi/180))
unlock screen
add 1 to tAngle
wait 10 millisec --or whatever
end repeat
end mouseUp
on mouseDown
grab me --So that you can relocate the rotation center.
end mouseDown
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Rotate 3 graphics as group
@Fermin,
http://forums.livecode.com/viewtopic.ph ... it=+rotate
2 stacks to show how to rotate text using a snapshot of the text.
Here rotate text (one line) horizontally as a widget i.e. use LC 8.0 and above:
http://runtime-revolution.278305.n4.nab ... 05279.html
Kind regards
Bernd
not a whole field but text nevertheless:... and also be great rotate a FIELD (with text, of course)
http://forums.livecode.com/viewtopic.ph ... it=+rotate
2 stacks to show how to rotate text using a snapshot of the text.
Here rotate text (one line) horizontally as a widget i.e. use LC 8.0 and above:
http://runtime-revolution.278305.n4.nab ... 05279.html
Kind regards
Bernd
Re: Rotate 3 graphics as group
Thank you very much, Bernd for your advice and links.
Yes, I'm afraid the method to rotate text is related to the snapshot of fields with the text and then manipulate the images. Well, it's going to be hard work because I am working on an application to help me to build video lyrics (an image for each line of text ... and even for every word!)
but... I'm not giving up. We'll see.
Yes, I'm afraid the method to rotate text is related to the snapshot of fields with the text and then manipulate the images. Well, it's going to be hard work because I am working on an application to help me to build video lyrics (an image for each line of text ... and even for every word!)
but... I'm not giving up. We'll see.
Re: Rotate 3 graphics as group
To do this (rotating object at once), video: https://www.youtube.com/watch?v=lG2Kavvqnyc
this is the code:
########CODE#######
on ruotafigura
if the label of me is "START" then
exit ruotafigura
end if
put the thumbpos of scrollbar "angolo" into Dangolo
lock screen
put the angle of graphic 1 into curangolo
put dangolo + curangolo into curangolo
set the angle of graphic 1 to curangolo
set the angle of graphic 2 to curangolo
#loc = 152,118
#w x h = 100,100
set the loc of graphic 2 to (152 + 100 * cos(pi/180 * curangolo), 118 + 100 * sin(pi/180 * curangolo) )
unlock screen
send ruotafigura to me in 0.017 sec #non ha senso scendere sotto questo valore
end ruotafigura
#####END OF CODE#####
this is the code:
########CODE#######
on ruotafigura
if the label of me is "START" then
exit ruotafigura
end if
put the thumbpos of scrollbar "angolo" into Dangolo
lock screen
put the angle of graphic 1 into curangolo
put dangolo + curangolo into curangolo
set the angle of graphic 1 to curangolo
set the angle of graphic 2 to curangolo
#loc = 152,118
#w x h = 100,100
set the loc of graphic 2 to (152 + 100 * cos(pi/180 * curangolo), 118 + 100 * sin(pi/180 * curangolo) )
unlock screen
send ruotafigura to me in 0.017 sec #non ha senso scendere sotto questo valore
end ruotafigura
#####END OF CODE#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Rotate 3 graphics as group
to rotate text use livecode 8 and the SVG widget, set the the iconPath property to the path to render the letter. This widget has rotation.
You can use inkscape to create the letters path and livecode add paths one after another.
https://inkscape.org
Or convert directly a font file with http://xmlgraphics.apache.org/batik/too ... erter.html
You can use inkscape to create the letters path and livecode add paths one after another.
https://inkscape.org
Code: Select all
inkscape file_text.svg --export-text-to-path --export-plain-svg file_shapes.svg
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Rotate 3 graphics as group
You seem to have forgotten to include the matrices.The following three basic rotation matrices