 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Julu Julu
Joined: 01 Nov 2005 Posts: 9 Location: Germany
|
Posted: Thu Nov 10, 2005 10:02 am Post subject: rotateImage ? |
|
|
Hi.
I found this function here.
| 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
|
I do not understand this function.
The picture turns always 90 degrees.
How can I turn the picture differently?
For example 50 degrees. |
|
| Back to top |
|
 |
Zenurb
Joined: 30 Sep 2005 Posts: 106 Location: United Kingdom
|
Posted: Thu Nov 10, 2005 11:24 am Post subject: Re: rotateImage ? |
|
|
| Julu Julu wrote: | Hi.
I found this function here.
| 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
|
I do not understand this function.
The picture turns always 90 degrees.
How can I turn the picture differently?
For example 50 degrees. |
You can use sin/cos functions to work out the position of each new pixel. _________________ Proud Dvorak User
US 1.5 PSP (Original) |
|
| Back to top |
|
 |
Julu Julu
Joined: 01 Nov 2005 Posts: 9 Location: Germany
|
Posted: Thu Nov 10, 2005 1:01 pm Post subject: |
|
|
Where I must set sin/cos ?
| 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( here -> ??? cos , here -> ??? sin x, theImage, x, y, 1, 1)
end
end
return newImage
end -- rotateImage
|
|
|
| Back to top |
|
 |
Zenurb
Joined: 30 Sep 2005 Posts: 106 Location: United Kingdom
|
Posted: Thu Nov 10, 2005 1:16 pm Post subject: |
|
|
sin and cos are mathematic functions which describe a wave pattern, sine and cosine. cosine is at a 90 degree angle to sine.
here is some code for making something move in a circle (i don't know lua very well)
| Code: | x = 130
y = 130
aimage = Image.createEmpty(100, 100)
aimage:print("lol")
while(true)
screen.clear()
a = a + 1
x = x + (sin(a) * 10)
y = y + (cos(a) * 10)
screen:blit(x, y, aimage, 0, 0, 100, 100)
end |
I think that works but probably not =)
the basic maths will work if you can fix it, to move something in a circle.
the radians value (a) goes from 0 to pi/2+pi (i think) pi=3.14152..etc and you can just divide the highest radian value by 360 then times by the angle you want to find the new position of a singular pixel. _________________ Proud Dvorak User
US 1.5 PSP (Original) |
|
| Back to top |
|
 |
Julu Julu
Joined: 01 Nov 2005 Posts: 9 Location: Germany
|
Posted: Thu Nov 10, 2005 5:03 pm Post subject: |
|
|
| Thanks :) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|