arrggg
Joined: 29 Sep 2005 Posts: 11
|
Posted: Fri Oct 07, 2005 5:25 am Post subject: [Lua Functions] Image Rotate & Image Scale |
|
|
Here's some functions I came up with; I hope someone finds them useful.
| Code: |
function rotateImage(theImage)
newImage = Image.createEmpty(theImage:height(), theImage:width())
for x = 1, theImage:width() do
for y = 1, theImage:height() do
newImage:blit(y, x, theImage, x, y, 1, 1)
end
end
return newImage
end -- rotateImage
function scaleImage(newX, newY, theImage)
newImage = Image.createEmpty(newX, newY)
for x = 1, newX do
for y = 1, newY do
newImage:blit(x,y , theImage, math.floor(x*(theImage:width()/newX)),math.floor(y*(theI mage:height()/newY)), 1, 1)
end
end
return newImage
end --scaleImage
--main program
smile = Image.load("smiley.png")
screen:blit(0, 0, smile)
screen:blit(100, 0, rotateImage(smile))
screen:blit(0,100, scaleImage(100,150, smile))
screen:flip()
screen.waitVblankStart(600)
|
|
|