j'ai essayé de dessiner la même chose pour une sprite et une image normale, je n'ai obtenu la même chose, le code entre les deux StartDrawing() et StopDrawing() est exactement le même.
où est_ce le problème?
Merci d'avance
Code : Tout sélectionner
UsePNGImageEncoder()
UsePNGImageDecoder()
Define.l Event, WindowID, GadgetID, EventType, EventMenu, dc, tet.f
Global Font.l,Font1.l,hdc,n.u, Dim bufrx.a(100), ang.f=-215
Global comport.s, i.a, r.u, teta.f, Pen.l
Declare drawlinepol(cx.u, cy.u, r.u, tet.f, len.f, pen.l)
Declare set_pen(color.l, width.l)
Declare set_font(font.s, size.l)
Global lBrush1.LOGBRUSH
With lBrush1
\lbStyle = #BS_SOLID
\lbColor = #Yellow
EndWith
Pen=0
Font=LoadFont(0, "Arial", 18)
Font1=LoadFont(0, "Arial", 12,#PB_Font_Bold)
InitSprite()
OpenWindow(0,400,200,700,400,"TEST")
TrackBarGadget(0,0,310,200,30,0,255)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CreateImage(1, 300, 300)
hdc=StartDrawing(ImageOutput(1))
FillArea(150, 150, -1, $5FB354)
set_pen( $828282,7)
;DrawingMode(#PB_2DDrawing_Outlined )
Ellipse_(hdc, 5,5,295,295)
FillArea(150, 150, -1, $7FEE6F)
set_pen( 0,1)
For i=1 To 10*5
;Declare drawlinepol(cx.u, cy.u, r.u, tet.f, len.f, color.u)
drawlinepol(150,150,142,(i-1)*5,0.95,Pen)
Next
set_pen( 0,5)
DrawingFont(Font1)
For i=1 To 11
;Declare drawlinepol(cx.u, cy.u, r.u, tet.f, len.f, color.u)
drawlinepol(150,150,146,(i-1)*25,0.94,Pen)
tet=(215-(i-1)*25)*#PI/180
DrawText(140+115*Cos(tet),140-115*Sin(tet), Str(10*(i-1)),$02FFFF,$7FEE6F)
Next
;Circle(150,150,10,0)
DrawingFont(Font)
DrawText(0+115,250, "VOLTS",$02FFFF,$7FEE6F)
;DrawText(0+115,220, " 123.56 ",$02FFFF)
StopDrawing()
ImageGadget(1,0,0,300,300,ImageID(1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
OpenWindowedScreen(WindowID(0),400,0,300,300)
CreateSprite(1, 300, 300)
hdc=StartDrawing(SpriteOutput(1))
FillArea(150, 150, -1, $5FB354)
set_pen( $828282,7)
;DrawingMode(#PB_2DDrawing_Outlined )
Ellipse_(hdc, 5,5,295,295)
FillArea(150, 150, -1, $7FEE6F)
set_pen( 0,1)
For i=1 To 10*5
;Declare drawlinepol(cx.u, cy.u, r.u, tet.f, len.f, color.u)
drawlinepol(150,150,142,(i-1)*5,0.95,Pen)
Next
set_pen( 0,5)
DrawingFont(Font1)
For i=1 To 11
;Declare drawlinepol(cx.u, cy.u, r.u, tet.f, len.f, color.u)
drawlinepol(150,150,146,(i-1)*25,0.94,Pen)
tet=(215-(i-1)*25)*#PI/180
DrawText(140+115*Cos(tet),140-115*Sin(tet), Str(10*(i-1)),$02FFFF,$7FEE6F)
Next
;Circle(150,150,10,0)
DrawingFont(Font)
DrawText(0+115,250, "VOLTS",$02FFFF,$7FEE6F)
;DrawText(0+115,220, " 123.56 ",$02FFFF)
StopDrawing()
DisplaySprite(1,0,0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Repeat
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
FlipBuffers()
ClearScreen(0)
DisplaySprite(1,0,0)
Until Event = #PB_Event_CloseWindow ; End of the event loop
FreeFont(0)
End
Procedure drawlinepol(cx.u, cy.u, r.u, tet.f, len.f, pen.l)
Define x1.u, x2.u, y1.u, y2.u, wid.w,hei.w
SelectObject_(hdc, pen)
tet=(215-tet)*#PI/180
x1=Int(r*Cos(tet)) + cx
y1=-Int(r*Sin(tet))+ cy
x2=Int(len*r*Cos(tet)) + cx
y2=-Int(len*r*Sin(tet))+ cy
wid=x2-x1
If wid=0: wid=1: EndIf
hei=y2-y1
If hei=0: hei=1: EndIf
;Line(x1,y1,wid,hei,color)
MoveToEx_(hdc,x1,y1,0)
LineTo_(hdc,x2,y2)
EndProcedure
Procedure set_pen(color.l, width.l)
With lBrush1
\lbStyle = #BS_SOLID
\lbColor = color
EndWith
If Pen <> 0
DeleteObject_(Pen)
EndIf
Pen = ExtCreatePen_(#PS_GEOMETRIC|#PS_ENDCAP_ROUND|#PS_JOIN_MITER|#PS_SOLID, width, lBrush1, 0, 0)
SelectObject_(hdc, Pen)
EndProcedure
Procedure set_font(font.s, size.l)
;FreeFont(0)
LoadFont(0, font, size)
DrawingFont(FontID(0))
EndProcedure