Rotating an image?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Rotating an image?

Post by JorDy »

i would like to be able to rotate an image to certain degrees with the pad. i have came across a function which will do that but it also blits an image in the top left which cant be gotten rid of other wise the rotated image is not shown
this is the code i found:

Code: Select all

--Rotate image
function rotateImage(theImage, angle)
screen:blit(0, 0,theImage)
angle = angle*(6 + (1/3))/360
	for x = 1, theImage:width() do
		for y = 1, theImage:height() do
			tX = math.cos(angle)*(x-theImage:width() / 2) - math.sin(angle) * (y-theImage:height() / 2)
			tY = math.sin(angle)*(x-theImage:width() / 2) + math.cos(angle) * (y-theImage:height() / 2)
			screen:fillRect(tX + 480, tY + 0, 2, 2, screen:pixel(x, y))
		end
	end
end

rotateImage(MyImage, angle)
screen.flip()
DiabloTerrorGF
Posts: 64
Joined: Fri Jul 15, 2005 11:44 pm

Post by DiabloTerrorGF »

try settings:
screen:blit(-100, -100,theImage)

or more till the pic is off screen.
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post by JorDy »

ive tried that it just moves my image aswell
Post Reply