möchte die Linie mit LCLK Zeichnen ...
Code: Alles auswählen
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnableExplicit
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-- [IMG] DE/ENCODER
; ++++++++++++++++++++++++++++++
UseTGAImageDecoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseTIFFImageDecoder()
;}
;- ++++++++++++++++++++++++++++++
Global hwnd
Global x1,y1,x2,y2
Global Rotstift_ShowLine.i
Global Rotstift_Deleter
Global DeltaX
Global DeltaY
Global Start.Point
Global RotstiftStart_X
Global RotstiftStart_Y
Global RotstiftEnde_X
Global RotstiftEnde_Y
Global RotstiftStaerke = 20
Global Rotstift_Color = $01FFFE
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnableExplicit
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Enumeration
#ImageGadget
#ImageZeichnen
#Img_Rotstift_Bild
EndEnumeration
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Rotstift_ThickLineXY(X1.i, Y1.i, X2.i, Y2.i, Rotstift_Color.i, Thickness.i)
Protected Length.i = Sqr((X2-X1)*(X2-X1)+(Y2-Y1)*(Y2-Y1))
Protected I, DeltaX.i, DeltaY.i
If Length = 0
Circle(X1, Y1, Thickness/2, Rotstift_Color)
Else
For I = 0 To Length
DeltaX = (X2-X1)*I/Length
DeltaY = (Y2-Y1)*I/Length
Circle(X1+DeltaX, Y1+DeltaY, Thickness/2, Rotstift_Color)
Next
EndIf
EndProcedure
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure DashDotL(x1.i, y1.i, x2.i, y2.i, Color.i,Thick.f,Lstep.f)
Protected Length.i = Sqr((X2-X1)*(X2-X1)+(Y2-Y1)*(Y2-Y1))
Protected scale.f
Protected i
scale.f = (y2-y1)/(x2-x1)
; For i = 0 To 10
For i = 0 To Length
; macht Linie
Rotstift_ThickLineXY(x1,y1,x1+Lstep,y1 + Lstep * scale, Color, Thick)
If Thick = 1
; Punkt machen
Circle(x1+Lstep + Lstep/2,y1+1.5 * Lstep * scale,Thick,Color)
Else
; Macht Punkte
Circle(x1+Lstep + Lstep/2,y1+1.5 * Lstep * scale,Thick/2,Color)
EndIf
; aufschaltung
x1 = x1+Lstep + Lstep
y1 = y1+2*Lstep*scale
Next
EndProcedure
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Rotstift_MouseDown()
Rotstift_ShowLine = #True
Debug "Rotstift_MouseDown" + Rotstift_ShowLine
Debug "WindowMouseX(hwnd) ="+WindowMouseX(hwnd)
Debug "WindowMouseY(hwnd) ="+WindowMouseY(hwnd)
Debug "Start\X ="+Start\X
Debug "Start\Y ="+Start\Y
RotstiftStart_X = WindowMouseX(hwnd)
RotstiftStart_Y = WindowMouseY(hwnd)
EndProcedure
Procedure Rotstift_MouseMove()
Debug "Rotstift_MouseMove" + Rotstift_ShowLine
If Rotstift_ShowLine = #True
RotstiftEnde_X = WindowMouseX(hwnd)
RotstiftEnde_Y = WindowMouseY(hwnd)
DeltaX = Start\X - WindowMouseX(hwnd)
DeltaY = Start\Y - WindowMouseY(hwnd)
Debug "DeltaX =" + DeltaX
Debug "DeltaY =" + DeltaY
StartDrawing(ImageOutput(#ImageZeichnen))
DrawImage(ImageID(#Img_Rotstift_Bild), 0, 0)
DrawingMode(#PB_2DDrawing_Default)
DashDotL(RotstiftEnde_X, RotstiftEnde_Y, RotstiftStart_X, RotstiftStart_Y,$01FFFE,4,20)
StopDrawing()
SetGadgetState(#ImageGadget,ImageID(#ImageZeichnen))
EndIf
EndProcedure
Procedure Rotstift_MouseUp ()
Debug "Rotstift_MouseUp" + Rotstift_ShowLine
DeltaX = Start\X - WindowMouseX(hwnd)
DeltaY = Start\Y - WindowMouseY(hwnd)
Debug "DeltaX =" + DeltaX
Debug "DeltaY =" + DeltaY
StartDrawing(ImageOutput(#Img_Rotstift_Bild))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawImage(ImageID(#ImageZeichnen), 0, 0)
DrawingMode(#PB_2DDrawing_Default)
DashDotL(RotstiftEnde_X, RotstiftEnde_Y, RotstiftStart_X, RotstiftStart_Y,$01FFFE,4,20)
StopDrawing()
; CopyImage(#ImageZeichnen,#Img_Rotstift_Bild)
SetGadgetState(#ImageGadget,ImageID(#Img_Rotstift_Bild))
Rotstift_ShowLine = #False
EndProcedure
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Rotstift_RechteMouseDown ()
Debug "Rotstift_RechteMouseDown"
Rotstift_Deleter = #True
EndProcedure
Procedure Rotstift_RechteMouseUp()
Debug "Rotstift_RechteMouseUp"
Rotstift_Deleter = #False
EndProcedure
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure Rotstift_CallBack(WindowID, uMsg, wParam, lParam)
Protected Result
Result = #PB_ProcessPureBasicEvents
;LINKE Maustaste
Select uMsg
Case #WM_LBUTTONDOWN
Rotstift_MouseDown()
Case #WM_MOUSEMOVE
Rotstift_MouseMove()
Case #WM_LBUTTONUP
Rotstift_MouseUp ()
Case #WM_RBUTTONDOWN
Rotstift_RechteMouseDown ()
Case #WM_RBUTTONUP
Rotstift_RechteMouseUp()
EndSelect
ProcedureReturn Result
EndProcedure
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; -----------------------------
hwnd = OpenWindow(#PB_Any, 0, 0, 667, 687, "DrawWindows DashDotL", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
; -----------------------------
CreateImage(#ImageZeichnen, 667, 667,24,$FFFFFF)
CreateImage(#Img_Rotstift_Bild, 667, 667,24,RGB(210, 105, 30))
; -----------------------------
ImageGadget(#ImageGadget, 0, 0, 667, 667,ImageID(#Img_Rotstift_Bild))
; -----------------------------
DisableGadget(#ImageGadget,1)
; -----------------------------
SetWindowCallback(@Rotstift_CallBack(),hwnd)
; -----------------------------
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Define WindowNr ,event ,Key.l
;- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
Gruss ... Velindos