How to rotate a graphic line freely?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

How to rotate a graphic line freely?

Post by alex298 » Tue May 29, 2007 7:01 am

Hello,

I draw a grapic line on a graph. The line need to be able to move and rotate freely on the graph for data analysis.

Move
=======
I can use the following to achieve the result:

on mousedown
grab me
end mousedown

However I have no any idea how to rotate the graphic line. Can RR do that?

Thanks and best regards
Alex
Nice to meet all of you.

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Tue May 29, 2007 11:01 am

Hi,

I found that I could layout a button and allowed user to the draw and drag lines freely:

on mouseUp
choose graphic line tool
end mouseUp

When using the Graphic tool, the cursor is a crosshairs. But how to reset the cursor to normal after drawing a line?
Alex
Nice to meet all of you.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue May 29, 2007 11:16 am

Hi Alex,

You can use the revRotatePoly command to rotate line graphics:

revrotatepoly the long id of grc id 1003,45

The easiest way to create an interface for rotating objects probably is to use a slider.

I have noticed that rotating line graphics may make the graphic object smaller in size. Also, resetting the rect of the graphic to the original values distorts the rotation. Rotating a graphic is therefore probably not what you want. Try creating a transparent image with equal height and width and a line drawn over it instead. Import the image and use the rotate command to well... rotate it.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Tue May 29, 2007 3:12 pm

Hi Mark,

Thanks for your information. I need more time to study your suggested method.

However I found the "choose graphic line tool" quite suitable for my project. The users can draw, move and adjust the line angle freely and easily. The only problem is that I don't know how to reset the cursor to normal after drawing and adjust a line?

Thanks and best regards
Alex
Nice to meet all of you.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Tue May 29, 2007 3:21 pm

Code: Select all

choose browse tool
if it doesn't work (rev is a bit finicky about tools), use a send in time structure:

Code: Select all

--before the end of your handler:
send "changeback" to me in 0.1 seconds

--additional handler:
on changeback
  choose browse tool
end changeback
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Wed May 30, 2007 4:44 am

Hi BvG,

Thanks for your help. But I don't know where to add the codes.

There is a button "Line Tool" and a graphic "Graph" on the card. When I click on the button "Line Tool", the mouse cursor change to a crosshair. Then I draw a new line on the graphic "Graph". I need to change the cursor to browse cursor when I satisfy with location and position of the new line.

Thanks and best regards
Alex
Nice to meet all of you.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed May 30, 2007 7:40 am

Hi Alex,

Why don't you make a tools palette, just like Revolution? A palette will allow you to click buttons to choose a different tool, regardless of what the currently chosen tool is.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Wed May 30, 2007 7:53 am

Hi Mark,

This is a very good idea. Any project examples of Tool Palette that can download to my computer and study?
Alex
Nice to meet all of you.

Post Reply