Okay. I got the image to rotate correctly the first time, but for some reason the image ends up with holes in it and when i try to rotate it a second time, it won't work. Help please? :\
I'm tryin to prevent from having to use 3 different images and just one image because with the program i'm making. A lot of images may be used and i don't want that to slow the performance.
Here's what i've got so far:
rem basic setup
sync on : sync rate 0 : cls
rem create rectangle to rotate
ink rgb(255,0,0),0
box 0,0,100,479
get image 1,0,0,101,480
cls
ink rgb(255,255,255),0
rem main loop
do
rem get rotation angle
input "Angle: ";rot
rem show original image
paste image 1,0,0
rotate image(1,rot)
rem paste new image
paste image 1,320,0
suspend for key
sync
cls
loop
function rotate image(id,ang)
rem if this is first time run, create arrays for usage
if first=0
first=1
dim pre(99999,4)
dim pos(4,2)
dim o(99999,4,2)
endif
rem get information of size of image
make memblock from image 1,id
if pre(id,2)=0 and pre(id,3)=0 and pre(id,4)=0
pre(id,2)=memblock dword(1,0)
pre(id,3)=memblock dword(1,4)
pre(id,4)=memblock dword(1,8)
o(id,2,1)=pre(id,2)
o(id,3,2)=pre(id,3)
o(id,4,1)=pre(id,2)
o(id,4,2)=pre(id,3)
endif
width=memblock dword(1,0)
height=memblock dword(1,4)
depth=memblock dword(1,8)
rem predict corner positions
pos(1,1)=(o(id,1,1)*cos(ang))-(o(id,1,2)*sin(ang)) : pos(1,2)=(o(id,1,1)*sin(ang))+(o(id,1,2)*cos(ang))
pos(2,1)=(o(id,2,1)*cos(ang))-(o(id,2,2)*sin(ang)) : pos(2,2)=(o(id,2,1)*sin(ang))+(o(id,2,2)*cos(ang))
pos(3,1)=(o(id,3,1)*cos(ang))-(o(id,3,2)*sin(ang)) : pos(3,2)=(o(id,3,1)*sin(ang))+(o(id,3,2)*cos(ang))
pos(4,1)=(o(id,4,1)*cos(ang))-(o(id,4,2)*sin(ang)) : pos(4,2)=(o(id,4,1)*sin(ang))+(o(id,4,2)*cos(ang))
o(id,1,1)=pos(1,1) : o(id,1,2)=pos(1,2)
o(id,2,1)=pos(2,1) : o(id,2,2)=pos(2,2)
o(id,3,1)=pos(3,1) : o(id,3,2)=pos(3,2)
o(id,4,1)=pos(4,1) : o(id,4,2)=pos(4,2)
lx=1 : ly=1 : gx=1 : gy=1
for p=2 to 4
if pos(p,1)<pos(lx,1) then lx=p
if pos(p,1)>pos(gx,1) then gx=p
if pos(p,2)<pos(ly,2) then ly=p
if pos(p,2)>pos(gy,2) then gy=p
next p
rem get width and height from predicted positions to get size
nwidth=pos(gx,1)-pos(lx,1)
nheight=pos(gy,2)-pos(ly,2)
size=((nwidth*nheight)*2)+12
rem make the new memblock and input the new images width and height
make memblock 2,size
write memblock dword 2,0,nwidth
write memblock dword 2,4,nheight
write memblock dword 2,8,depth
for y=0 to height-1
for x=0 to width-1
tx=x : ty=y
tx=(tx*cos(pre(id,1)))-(ty*sin(pre(id,1))) : ty=(tx*sin(pre(id,1)))+(ty*cos(pre(id,1)))
rem calculate where x and y will be
ix=((tx-(width/2))*cos(ang))-((ty-(height/2))*sin(ang)) : iy=((tx-(width/2))*sin(ang))+((ty-(height/2))*cos(ang))
ix=ix+(nwidth/2) : iy=iy+(nheight/2)
rem get new and old positions to transfer colors
npos=(ix*2)+(iy*(nwidth*2))+12
opos=(x*2)+(y*(width*2))+12
write memblock word 2,npos,memblock word(1,opos)
next x
next y
rem delete original image, make the new image, and delete memblock, and remember angle at which image was rotated
delete image id
make image from memblock id,2
delete memblock 1
delete memblock 2
pre(id,1)=wrapvalue(pre(id,1)+ang)
endfunction