How do you turn these Circles into Arrowheads ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

How do you turn these Circles into Arrowheads ?

Post by VB6_to_PBx »

How do you turn these Circles into Arrowheads :?:

AddPathCircle(PathCursorX(), PathCursorY(), 6) ;<<--- How do you turn these Circles into Arrowheads ???

Code: Select all

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    SetWindowColor(0,RGB(240,240,240))

  		CreateImage(0,400,400,32,#PB_Image_Transparent)
 
  If StartVectorDrawing(ImageVectorOutput(0))
   
    w = VectorOutputWidth()
    h = VectorOutputHeight()
   
    VectorSourceColor(RGBA(100, 0, 100, 255))
   
    RotateCoordinates(w/2, h/2, 45)

    For i=0 To 360 Step 45
      MovePathCursor(w/2, h-10)
      AddPathLine(w/2, h-55)
      SaveVectorState()
      MovePathCursor(w/2, h-60)
      RotateCoordinates(w/2, h/2, 360-i)
      AddPathCircle(PathCursorX(), PathCursorY(), 6)  ;<<--- How do you turn these Circles into Arrowheads ???
      RestoreVectorState()
      StrokePath(5)
      RotateCoordinates(w/2, h/2, 45)
    Next
         
    StopVectorDrawing()
  EndIf

  ImageGadget(12, 0, 0, 400, 400,ImageID(0),32)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf


 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: How do you turn these Circles into Arrowheads ?

Post by wilbert »

You can try AddPathSegments

Code: Select all

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowColor(0,RGB(240,240,240))
  
  CreateImage(0,400,400,32,#PB_Image_Transparent)
  
  If StartVectorDrawing(ImageVectorOutput(0))
    
    w = VectorOutputWidth()
    h = VectorOutputHeight()
    
    VectorSourceColor(RGBA(100, 0, 100, 255))
    
    For i=0 To 360 Step 45
      MovePathCursor(w/2, h-10)
      AddPathSegments("L 0 -45 L -3 -45 L 0 -48 L 3 -45 L 0 -45", #PB_Path_Relative)
      StrokePath(5)
      RotateCoordinates(w/2, h/2, 45)
    Next
    
    StopVectorDrawing()
  EndIf
  
  ImageGadget(12, 0, 0, 400, 400,ImageID(0),32)
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Windows (x64)
Raspberry Pi OS (Arm64)
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: How do you turn these Circles into Arrowheads ?

Post by #NULL »

Here is another way

Code: Select all

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    SetWindowColor(0,RGB(240,240,240))

        CreateImage(0,400,400,32,#PB_Image_Transparent)
 
  If StartVectorDrawing(ImageVectorOutput(0))
   
    w = VectorOutputWidth()
    h = VectorOutputHeight()
   
    VectorSourceColor(RGBA(100, 0, 100, 255))
   
    RotateCoordinates(w/2, h/2, 45)

    For i=0 To 360 Step 45
      MovePathCursor(w/2, h-10)
      AddPathLine(w/2, h-55)
      
      ;SaveVectorState()
      MovePathCursor(w/2, h-60)
      ;RotateCoordinates(w/2, h/2, 360-i)
      ;AddPathCircle(PathCursorX(), PathCursorY(), 6)  ;<<--- How do you turn these Circles into Arrowheads ???
      l = 15
      a.f = 45
      x.f = PathCursorX()
      y.f = PathCursorY()
      AddPathLine(l * Cos(Radian(a)), l * Sin(Radian(a)), #PB_Relative)
      MovePathCursor(x, y)
      AddPathLine(l * Cos(Radian(180-a)), l * Sin(Radian(180-a)), #PB_Relative)
      
      ;RestoreVectorState()
      StrokePath(5, #PB_Path_RoundEnd)
      RotateCoordinates(w/2, h/2, 45)
    Next
         
    StopVectorDrawing()
  EndIf

  ImageGadget(12, 0, 0, 400, 400,ImageID(0),32)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: How do you turn these Circles into Arrowheads ?

Post by VB6_to_PBx »

#NULL .... thanks very much !!! exactly the code i needed

PureBasic's VectorDrawing is awesome ... i just started learning it as you can tell :)

and Thanks wilbert ,

i'll use your Code when i can use PB5.71 version .

unfortunately i cannot use "AddPathSegments"
because i need Code compatible with PB5.41 to PB5.46
unless i can solve my Printing routine to work in PB5.71 ??

thats my next final task left after these ArrowHeads ,
is to solve Landscape Printing problem in PB5.71
with the code i now have , thats the only thing left
or stopping me from using PB5.61 to PB5.71 versions .
i'm pretty positive i can solve it 1 or 2 Days !

i'm finally able to quit programming in VB6.0 :)
what i thought was going to be a few weeks ,
turned out to be about 3 years ,
now i'm finally able to start programming in PureBasic again .


#NULL wrote:Here is another way

Code: Select all

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    SetWindowColor(0,RGB(240,240,240))

        CreateImage(0,400,400,32,#PB_Image_Transparent)
 
  If StartVectorDrawing(ImageVectorOutput(0))
   
    w = VectorOutputWidth()
    h = VectorOutputHeight()
   
    VectorSourceColor(RGBA(100, 0, 100, 255))
   
    RotateCoordinates(w/2, h/2, 45)

    For i=0 To 360 Step 45
      MovePathCursor(w/2, h-10)
      AddPathLine(w/2, h-55)
      
      ;SaveVectorState()
      MovePathCursor(w/2, h-60)
      ;RotateCoordinates(w/2, h/2, 360-i)
      ;AddPathCircle(PathCursorX(), PathCursorY(), 6)  ;<<--- How do you turn these Circles into Arrowheads ???
      l = 15
      a.f = 45
      x.f = PathCursorX()
      y.f = PathCursorY()
      AddPathLine(l * Cos(Radian(a)), l * Sin(Radian(a)), #PB_Relative)
      MovePathCursor(x, y)
      AddPathLine(l * Cos(Radian(180-a)), l * Sin(Radian(180-a)), #PB_Relative)
      
      ;RestoreVectorState()
      StrokePath(5, #PB_Path_RoundEnd)
      RotateCoordinates(w/2, h/2, 45)
    Next
         
    StopVectorDrawing()
  EndIf

  ImageGadget(12, 0, 0, 400, 400,ImageID(0),32)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4661
Joined: Sun Apr 12, 2009 6:27 am

Re: How do you turn these Circles into Arrowheads ?

Post by RASHAD »

Hi VB6_to_PBx
Sorry for late
I got some free time now so I will look at your code later
Next :
- Draw your arrow only once
- You can play with arrow shadow
- You can play with arrow Alpha to indicate the Wind Force too

Code: Select all

CreateImage(1,20,200,32,#PB_Image_Transparent)
If StartVectorDrawing(ImageVectorOutput(1))
  VectorSourceColor($FF0000FF)
  MovePathCursor(10, 10)
  AddPathLine(10, 40)
  StrokePath(5 ,#PB_Path_RoundEnd)
  MovePathCursor(10, 50)
  AddPathLine(0,30)
  AddPathLine(10,40)
  AddPathLine(20,30)
  ClosePath()  
  FillPath()
  StopVectorDrawing()
EndIf

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    SetWindowColor(0,RGB(240,240,240))

    CreateImage(0,400,400,32,#PB_Image_Transparent)
    alpha = 255
  If StartVectorDrawing(ImageVectorOutput(0))
   
    w = VectorOutputWidth()
    h = VectorOutputHeight()
   
    For i=45 To 360 Step 45
      ResetCoordinates()
      ResetPath()
      RotateCoordinates(w/2, h/2, i)
      MovePathCursor(192, 2)
      DrawVectorImage(ImageID(1),128)
      MovePathCursor(190, 0)
      DrawVectorImage(ImageID(1),alpha)      
      alpha = alpha - 25
    Next
         
    StopVectorDrawing()
  EndIf

  ImageGadget(12, 0, 0, 400, 400,ImageID(0),32)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Egypt my love
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: How do you turn these Circles into Arrowheads ?

Post by VB6_to_PBx »

RASHAD :
Hi VB6_to_PBx
Sorry for late
I got some free time now so I will look at your code later
Next :
- Draw your arrow only once
- You can play with arrow shadow
- You can play with arrow Alpha to indicate the Wind Force too
RASHAD ,
:D
thank you !

you have created the best ArrowHead shape !!!
and including the Arrow's "shadow effect" was another great effect !!! ... i definetly will be testing out different shade colors + arrows
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
Post Reply