Ist gelöst mit den Punkten.
Das Bild ist 64x64 Pixel. Rotate funktioniert jetzt.
Jetzt muss ich die Routinen von Rotate noch in XPIA umsetzen.
' Quellpunkte: AP(0) x--------x AP(1)
' | |
' | |
' ---------
' AP(2) x x [AP(3)] wird automatisch berechent
$MAKE CLE
$H Windows.ph
declare bpic&, bpic1&,ende&,winkel!,hintergrpic&,vordergrpic&,hDCBits&
declare x1!,y1!,dx!,dy!,pts#
Declare wh&,xc&,yc&,pi180!,dws!,gtest&
dim pts#,24
Pi180!=0.0174532925199433
dws!=1
wh&=100/dws!
xc&=32/dws!
yc&=32/dws!
ende&=1
bpic& = create("hPic",-1,"d:/freeprofan/test-xpia/data/auto.bmp")
Window 20,20-800,600
Cls RGB(220,220,220)
bpic1& = create("hNewPic", 100,100,rgb(255,0,255))
hintergrpic& = create("hNewPic", 500,500,rgb(255,255,0))
vordergrpic& = create("hNewPic", 500,500,rgb(255,255,0))
startpaint hintergrpic&
UsePen 0,1,Rgb(0,128,255)
usebrush 1,rgb(0,128,255)
ellipse 200,200-250,250
endpaint
dx!=60
dy!=60
startpaint bpic1&
drawhPicRotated
endpaint
zeichne
WHILE ende&
if isKey(83)
y1!=Sin(winkel!*Pi180!)*0.2
x1!=Cos(winkel!*Pi180!)*0.2
dx!=dx!-x1!
dy!=dy!-y1!
zeichne
endif
if isKey(87)
y1!=Sin(winkel!*Pi180!)*0.2
x1!=Cos(winkel!*Pi180!)*0.2
dx!=dx!+x1!
dy!=dy!+y1!
zeichne
endif
if isKey(81)
winkel!=winkel!-0.5
startpaint bpic1&
drawhPicRotated
EndPaint
zeichne
endif
if isKey(69)
winkel!=winkel!+0.5
startpaint bpic1&
drawhPicRotated
EndPaint
zeichne
EndIf
EndWhile
end
Proc zeichne
startpaint vordergrpic&
drawpic hintergrpic&,0,0;0
drawpic bpic1&,dx!,dy!;-1,$ff00ff
EndPaint
drawpic vordergrpic&,10,10;0
EndProc
Proc drawhPicRotated
hDCBits&=~createCompatibleDC(%hDC)
~selectObject(hDCBits&, bpic&)
long pts#,0=xc&+(0-xc&)*Cos(Pi180!*winkel!)-(0-yc&)*Sin(Pi180!*winkel!)
long pts#,4=yc&+(0-xc&)*Sin(Pi180!*winkel!)+(0-yc&)*Cos(Pi180!*winkel!)
long pts#,8=xc&+(wh&-xc&)*Cos(Pi180!*winkel!)-(0-yc&)*Sin(Pi180!*winkel!)
long pts#,12=yc&+(wh&-xc&)*Sin(Pi180!*winkel!)+(0-yc&)*Cos(Pi180!*winkel!)
long pts#,16=xc&+(0-xc&)*Cos(Pi180!*winkel!)-(wh&-yc&)*Sin(Pi180!*winkel!)
long pts#,20=yc&+(0-xc&)*Sin(Pi180!*winkel!)+(wh&-yc&)*Cos(Pi180!*winkel!)
~plgBlt(%hdc,pts#,hDCBits&,0,0,100,100,0,0,0)
~deleteDC(hDCBits&),wh&
endproc
Alles anzeigen