Vector Drawing - Why image does not move?

Just starting out? Need help? Post your questions and find answers here.
acreis
Enthusiast
Enthusiast
Posts: 204
Joined: Fri Jun 01, 2012 12:20 am

Vector Drawing - Why image does not move?

Post by acreis »

Code: Select all

Procedure Draw(x, y)
  
  
    If StartVectorDrawing(CanvasVectorOutput(0))
      
      Debug x
      Debug y
  
      
      AddPathBox(x, y, ImageWidth(0), ImageHeight(0))
      VectorSourceImage(ImageID(0), 255, ImageWidth(0), ImageHeight(0))
      FillPath()
    
      StopVectorDrawing()
      
    EndIf
  
EndProcedure

If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0, 0, 0, 400, 200)
    
    LoadImage(0, #PB_Compiler_Home + "examples/Sources/Data/PureBasicLogo.bmp")

    AddWindowTimer(0, 1, 55)
  
    
    Repeat
      Event = WaitWindowEvent()
      
      Select event
          
        Case #PB_Event_Timer
          x+1
          y+1
          Draw(x, y)
          
      EndSelect
      
    Until Event = #PB_Event_CloseWindow
  EndIf

Hadrianus
User
User
Posts: 34
Joined: Wed Mar 27, 2013 11:31 pm

Re: Vector Drawing - Why image does not move?

Post by Hadrianus »

The image seems to be the problem. If you draw a simple line or a box, then you will see it's working just fine (don't forget to make the canvas empty before each new frame).
acreis
Enthusiast
Enthusiast
Posts: 204
Joined: Fri Jun 01, 2012 12:20 am

Re: Vector Drawing - Why image does not move?

Post by acreis »

This works!

Code: Select all

Procedure Draw(x, y)
  
    If StartVectorDrawing(CanvasVectorOutput(0))
    
      MovePathCursor(x, y)
      DrawVectorImage(ImageID(0))
      
      StopVectorDrawing()
    EndIf
  
EndProcedure

If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0, 0, 0, 400, 200)
    
    LoadImage(0, #PB_Compiler_Home + "examples/Sources/Data/PureBasicLogo.bmp")

    AddWindowTimer(0, 1, 55)
  
    
    Repeat
      Event = WaitWindowEvent()
      
      Select event
          
        Case #PB_Event_Timer
          x+1
          y+1
          Draw(x, y)
          
      EndSelect
      
    Until Event = #PB_Event_CloseWindow
  EndIf

Post Reply