Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Procedure RotateImage(lImage,lImageTarget,lAngle.f);
- Dim ImgArray(ImageWidth(lImage),ImageHeight(lImage));
- Dim ImgWritten(ImageWidth(lImage),ImageHeight(lImage));
- ;Save first image to array
- StartDrawing(ImageOutput(lImage));
- DrawingMode(#PB_2DDrawing_AlphaChannel );
- For y=0 To ImageHeight(lImage)-1;
- For x=0 To ImageWidth(lImage)-1;
- ImgArray(x,y) = Point(x,y);
- Next x;
- Next y;
- StopDrawing();
- ; Initialisations
- lTau.f = 6.28318531;
- lAngle = lAngle*10;
- s.f=Sin(lTau/3600*lAngle);
- c.f=Cos(lTau/3600*lAngle);
- mx=ImageWidth(lImage)/2;
- my=ImageHeight(lImage)/2;
- radius.f=Sqr(mx*mx + my*my)+1;
- ; Create target image if it doesn't exist
- If ImageWidth(lImageTarget)=0;
- CreateImage(lImageTarget,ImageWidth(lImage),ImageHeight(lImage),32);
- EndIf;
- max=ImageWidth(lImageTarget);
- may=ImageHeight(lImageTarget);
- ; Draw to target image
- StartDrawing(ImageOutput(lImageTarget));
- DrawingMode(#PB_2DDrawing_AlphaChannel );
- Box(0,0,ImageWidth(lImage),ImageHeight(lImage),RGB(91,92,90));
- DrawingMode(#PB_2DDrawing_AlphaBlend );
- For y=0 To ImageHeight(lImageTarget)-1;
- For x=0 To ImageWidth(lImageTarget)-1;
- RotateX.l = ((x - mx) * c - (y - my) * s) + mx;
- RotateY.l = ((x - mx) * s + (y - my) * c) + my;
- If RotateX>0 And RotateX<max-1 And RotateY>0 And RotateY<may-1;
- ImgWritten(RotateX,RotateY)=1;
- color=ImgArray(x,y);
- Plot(RotateX,RotateY,color);
- If lAngle<>0 And lAngle<>90 And lAngle<>1800 And lAngle<>2700 And lAngle<>3600;
- Plot(RotateX+1,RotateY,color);
- Plot(RotateX,RotateY+1,color);
- EndIf;
- EndIf;
- Next x;
- Next y;
- lUndrawn = 0;
- For y=1 To ImageHeight(lImage)-1;
- For x=0 To ImageWidth(lImage)-1;
- If ImgWritten(x,y) <> 1;
- lUndrawn+1;
- ImgWritten(x,y)=1;
- ;Plot(x,y,Point(x,y-1));
- EndIf;
- Next x;
- Next y;
- Debug lUndrawn;
- StopDrawing();
- ; Memory freeing
- FreeArray(ImgArray());
- FreeArray(ImgWritten());
- EndProcedure
- ; Drawing Procedures
- Procedure DrawClock();
- lHour.l = Hour(lDate);
- lMinute.l = Minute(lDate);
- lHour - 12;
- sTime.s = Str(lHour)+":"+Str(lMinute);
- lImageHour = CopyImage(#imgClockHour,#PB_Any);
- RotateImage(#imgClockHour,lImageHour,180);
- lImageMinute = CopyImage(#imgClockMinute,#PB_Any);
- RotateImage(#imgClockMinute,lImageMinute,lMinute*6);
- CreateImage(#imgSkin,ImageWidth(#imgClockBackground),ImageHeight(#imgClockBackground),32);
- StartDrawing(ImageOutput(#imgSkin));
- ; Set the background to be transparent
- DrawingMode(#PB_2DDrawing_AlphaChannel );
- Box(0,0,ImageWidth(#imgClockBackground),ImageHeight(#imgClockBackground)+35,RGBA(91,92,90,0));
- ; Start drawing
- DrawingMode(#PB_2DDrawing_AlphaBlend );
- ;DrawAlphaImage(ImageID(#imgClockBackground),0,0);
- ;DrawAlphaImage(ImageID(lImageHour),0,0);
- DrawAlphaImage(ImageID(lImageMinute),0,0);
- StopDrawing();
- EndProcedure;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement