How to rotate a graphic
Mark Wieder
mwieder at ahsoftware.net
Sat Nov 14 12:15:41 EST 2009
Claus-
Saturday, November 14, 2009, 8:45:18 AM, Jan wrote:
> Take a look at the 'fillGradient' property in the Dictionary. It
> is an array of different properties of the gradient which fills your
> graphic.
> Of particular interest are the 'from', 'to and 'via'
> sub-properties, as these designate where the gradient starts and
> ends, and at what angle.
...and nonintuitively, the "from" element is the center of rotation.
Here's a simple routine to turn the graphic gradient clockwise from
horizontal to vertical.
on mouseUp pMouseBtnNo
local tGradient
local tFrom, tTo, tVia
local tLength
put the fillgradient of graphic 1 into tGradient
put tGradient["from"] into tFrom
put tGradient["to"] into tTo
put tGradient["via"] into tVia
-- "from" is the fulcrum : we want to rotate around it
set the itemdelimiter to comma
put item 1 of tTo - item 1 of tFrom into tLength
put item 1 of tFrom into item 1 of tTo
put item 2 of tFrom + tLength into item 2 of tTo
put item 2 of tVia- item 2 of tFrom into tLength
put item 2 of tFrom into item 2 of tVia
put item 1 of tFrom - tLength into item 1 of tVia
put tFrom into tGradient["from"]
put tTo into tGradient["to"]
put tVia into tGradient["via"]
set the fillgradient of graphic 1 to tGradient
end mouseUp
--
-Mark Wieder
mwieder at ahsoftware.net
More information about the use-livecode
mailing list