Rotate 3 graphics as group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
joran
Posts: 20
Joined: Fri May 13, 2016 1:00 pm

Rotate 3 graphics as group

Post by joran » Wed Jun 01, 2016 12:57 pm

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

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Rotate 3 graphics as group

Post by Klaus » Wed Jun 01, 2016 1:00 pm

Hi Joran,
joran wrote:Is it possible to rotate a group?
unfortunately no!

But you could take a screenshot of your group and rotate that image, if that is an option?


Best

Klaus

joran
Posts: 20
Joined: Fri May 13, 2016 1:00 pm

Re: Rotate 3 graphics as group

Post by joran » Wed Jun 01, 2016 1:08 pm

Ok, thought it might be so.

Thanks anyway :-)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Rotate 3 graphics as group

Post by dunbarx » Wed Jun 01, 2016 2:56 pm

Might this be a useful new feature to ask for?

Craig Newman

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: Rotate 3 graphics as group

Post by Fermin » Sun Jun 05, 2016 8:35 pm

... and also be great rotate a FIELD (with text, of course)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rotate 3 graphics as group

Post by richmond62 » Sun Jun 05, 2016 8:49 pm

Currently one can only do a 'set the angle' or a 'rotate' with an image.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Rotate 3 graphics as group

Post by [-hh] » Sun Jun 05, 2016 8:49 pm

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.
shiftLock happens

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rotate 3 graphics as group

Post by richmond62 » Sun Jun 05, 2016 8:58 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rotate 3 graphics as group

Post by richmond62 » Sun Jun 05, 2016 9:05 pm

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Rotate 3 graphics as group

Post by bn » Sun Jun 05, 2016 10:29 pm

@Fermin,
... and also be great rotate a FIELD (with text, of course)
not a whole field but text nevertheless:

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

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: Rotate 3 graphics as group

Post by Fermin » Mon Jun 06, 2016 2:47 pm

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.

:-)

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Rotate 3 graphics as group

Post by MaxV » Thu Jun 09, 2016 4:29 pm

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#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Rotate 3 graphics as group

Post by MaxV » Thu Jun 09, 2016 4:37 pm

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

Code: Select all

inkscape file_text.svg --export-text-to-path --export-plain-svg file_shapes.svg
Or convert directly a font file with http://xmlgraphics.apache.org/batik/too ... erter.html
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rotate 3 graphics as group

Post by richmond62 » Sat Sep 01, 2018 11:40 am

The following three basic rotation matrices
You seem to have forgotten to include the matrices.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”