Changes

Jump to navigation Jump to search

image.rotate

1,355 bytes added, 22:17, 6 June 2012
Created page with "__NOTOC__ image.'''rotate''' is a function that is part of the image library. Returns a copy of the input image rotated counterclockwise by the amount of d..."
__NOTOC__
image.'''rotate''' is a function that is part of the [[:Category: image|image]] library.


Returns a copy of the input image rotated counterclockwise by the amount of degrees given.

{{Since|3.2}}

== Syntax ==
image.'''rotate'''(yourImage, angle) ( ''or'' yourImage:rotate(angle) )

{| class="wikitable"
|-
! Parameter !! Type !! Description
|-
| <u><center>yourImage</center></u> || [[TI.Image]] || Image you want to rotate, created with [[image.new]]()
|-
| <u><center>angle</center></u> || number || the angle in degrees you want to rotate your image by.
|-
|}

== Example ==
<syntaxhighlight>local imw = earth:width()
local imh = earth:height()
local im = earth:copy(sc*imw, sc*imh)
im = im:rotate(-tilt)
local midx = im:width()/2 -- this is the important bit for having the right coordinates
local midy = im:height()/2
local x = w/4 - midx
local y = h/2 - midy
gc:drawImage(im, x, y) -- we must be in a gc-passed function (like [[on.paint]](gc))
imw, imh = im:width(), im:height()</syntaxhighlight>

== Good to know ==

The image changes size when you rotate it. So you need to figure where to draw it based on the middle of its rotated size. By experimenting with it, you'll quickly notice that need ;)

== See also ==
*[[image.new]]
*[[image.width]]
*[[image.height]]

<br />

[[Category:image]]

Navigation menu