Thanks team it is very close to Cairo and maybe more advanced
Cross platform(It should be)
Code: Select all
Procedure flipHal(img)
ww = ImageWidth(img)
hh = ImageHeight(img)
fimg = CreateImage(#PB_Any,ww,hh,32)
StartVectorDrawing(ImageVectorOutput(fimg))
ResetCoordinates()
MovePathCursor(ww,0)
FlipCoordinatesX(180)
DrawVectorImage(ImageID(img), 255)
StopVectorDrawing()
ProcedureReturn fimg
EndProcedure
Procedure flipVal(img)
ww = ImageWidth(img)
hh = ImageHeight(img)
fimg = CreateImage(#PB_Any,ww,hh,32)
StartVectorDrawing(ImageVectorOutput(fimg))
ResetCoordinates()
MovePathCursor(0,hh)
FlipCoordinatesY(180)
DrawVectorImage(ImageID(img), 255)
StopVectorDrawing()
ProcedureReturn fimg
EndProcedure
Procedure Rotimg(img,deg)
ww = ImageWidth(img)
hh = ImageHeight(img)
ang.f = Radian(deg)
nw = Abs(ww*Cos(ang)+hh*Sin(ang))
nh = Abs(ww*Sin(ang)+hh*Cos(ang))
fimg = CreateImage(#PB_Any,nw,nh,32);,#PB_Image_Transparent)
StartVectorDrawing(ImageVectorOutput(fimg))
MovePathCursor(Abs(hh*Sin(ang)),0)
RotateCoordinates(0,0,deg)
DrawVectorImage(ImageID(img), 255)
StopVectorDrawing()
ProcedureReturn fimg
EndProcedure
Procedure Rotate(img,deg)
If deg <= 90
fimg = Rotimg(0,deg)
ElseIf deg > 90 And deg <= 180
fimg = Rotimg(0,deg-90)
fimg = Rotimg(fimg,90)
ElseIf deg > 180 And deg <=270
fimg = Rotimg(0,deg-180)
fimg = Rotimg(fimg,90)
fimg = Rotimg(fimg,90)
Else
fimg = Rotimg(0,deg-270)
fimg = Rotimg(fimg,90)
fimg = Rotimg(fimg,90)
fimg = Rotimg(fimg,90)
EndIf
ProcedureReturn fimg
EndProcedure
If OpenWindow(0, 0, 0, 400, 540, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(0, 10, 10, 380,70 ,0)
ImageGadget(1, 10, 90, 380,70 ,0)
ImageGadget(2, 10, 170, 380,70 ,0)
ImageGadget(3, 10, 250, 380,280 ,0)
LoadImage(0, #PB_Compiler_Home + "examples/Sources/Data/PureBasicLogo.bmp")
SetGadgetState(0,ImageID(0))
fimg = flipHal(0)
SetGadgetState(1,ImageID(fimg))
fimg = flipVal(0)
SetGadgetState(2,ImageID(fimg))
fimg = Rotate(0,145)
SetGadgetState(3,ImageID(fimg))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Code indented
09.02.2016
RSBasic