It is currently Fri Jan 15, 2021 6:25 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: IsInsideStroke() and coordinate systems
PostPosted: Thu Apr 30, 2020 7:20 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Sep 20, 2004 7:12 am
Posts: 622
Location: Hell
I don't seem to get any dev-attendance here, so sorry for that clone, but I need some answers otherwise my current project is frozen.
Feel free to move it back to coding questions, or delete it and anwer in the original post, no problem.

Code:

#TEST_ME = 0
; IsInsideStroke seems to always return 1, even if the point to check is far away from the path.
; Looks like IsInlineStroke() has problems working with numbers smaller than 1?
;#TEST_ME = 1
; Due to the manual the device coordinates (#PB_Coordinate_Device) should be fixed/unchangable
; no matter how much you extend/shrink the user coordinates via ScaleCoordinates/Translatecoordinates
; Why is the IsInsideStroke then not working with the mouse coordinates?
;#TEST_ME = 2
; Adding a simple ResetCoordinates() will make the Cursor selection work again
; Why is it like this, shouldn't the device coordinates be indepenant of any squeezing/extracting of the user coordinates and always work with the mouse coordinates??




Procedure draw()
   Protected x, y
   Static Once
   
   If StartVectorDrawing(CanvasVectorOutput(0))
      VectorSourceColor($FFFFFFFF)
      FillVectorOutput()
      ResetCoordinates()
      ScaleCoordinates(10, 100000)
      TranslateCoordinates(0.1, 0.0013)
      AddPathSegments("M 10 0.0001 L 20 0.003 L 30 0.0001 L 40 0.003")
      CompilerIf #TEST_ME = 0
         Debug "Testing (in User Coordinate system) if point 20 / 0.003 is on path (should be, see AddPathSegments)"
         Debug IsInsideStroke(20, 0.003, 0.01, #PB_Path_Default, #PB_Coordinate_User)
         Debug "Now testing (in User Coordinate system) if point 20 / 0.1 is on path (for sure not, I even used a ridiculous small width to test!)"
         Debug IsInsideStroke(20, 0.100, 0.000001, #PB_Path_Default, #PB_Coordinate_User)
         Debug "???"
         VectorSourceColor(RGBA(255, 0, 0, 255))
      CompilerElse
         x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
         y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
         If Once = 0
            Once = 1
            Debug "Move cursor and when you are above the path, the color should switch to blue"
         EndIf
         CompilerIf #TEST_ME = 2
            ResetCoordinates()
         CompilerEndIf
         If IsInsideStroke(x, y, 8, #PB_Path_Default, #PB_Coordinate_Device)
            VectorSourceColor(RGBA(0, 0, 255, 255))
         Else
            VectorSourceColor(RGBA(255, 0, 0, 255))
         EndIf
      CompilerEndIf
      StrokePath(0.01)
      StopVectorDrawing()
   EndIf
EndProcedure

If OpenWindow(0, 0, 0, 1000, 500, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   CanvasGadget(0, 0, 0, 1000, 500)
   draw()
   
   Repeat
      Select WaitWindowEvent()
         Case #PB_Event_CloseWindow
            Break
         Case #PB_Event_Gadget
            CompilerIf #TEST_ME > 0
               If EventGadget() = 0 And EventType() = #PB_EventType_MouseMove
                  draw()
               EndIf
            CompilerEndIf
      EndSelect
   ForEver
EndIf

_________________
Link dead?
Change h3x0r.ath.cx into hex0rs.coderbu.de and all will be fine.


Top
 Profile  
Reply with quote  
 Post subject: Re: IsInsideStroke() and coordinate systems
PostPosted: Tue Oct 13, 2020 8:03 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Sep 20, 2004 7:12 am
Posts: 622
Location: Hell
I need to know if this will be fixed (or at least explained) in 5.73, otherwise I have to cancel that whole project or move to something else.

It's quite frustrating to get no single response from the devs for half a year, I still have no idea if I'm doing something wrong or it is a wrong behaviour.

_________________
Link dead?
Change h3x0r.ath.cx into hex0rs.coderbu.de and all will be fine.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye