[PB 5.40]Lib Vector - Coordonées - Pas tout compris ou bug ?

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Torp
Messages : 360
Inscription : lun. 22/nov./2004 13:05

[PB 5.40]Lib Vector - Coordonées - Pas tout compris ou bug ?

Message par Torp »

Hello,
J'ai un peu bricolé un exemple tiré de la doc, et je ne comprends pas pourquoi le premier click de souris dessine les 2 box à 2 endroits différents alors que les click suivant dessinent les 2 box aux même coordonnées. Je pense que le premier comportement est le bon... enfin je crois :)

Code : Tout sélectionner

If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 400, 200)   
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Gadget And EventGadget() = 0 And EventType() = #PB_EventType_LeftButtonDown
      
      If StartVectorDrawing(CanvasVectorOutput(0, #PB_Unit_Point))
        
        CanvasX = GetGadgetAttribute(0, #PB_Canvas_MouseX)
        CanvasY = GetGadgetAttribute(0, #PB_Canvas_MouseY)
        
        DrawingX = ConvertCoordinateX(CanvasX, CanvasY, #PB_Coordinate_Device, #PB_Coordinate_User)
        DrawingY = ConvertCoordinateY(CanvasX, CanvasY, #PB_Coordinate_Device, #PB_Coordinate_User)
        
        AddPathBox(CanvasX, CanvasY, 10, 5)
        VectorSourceColor(RGBA(255, 0, 0, 255))
        FillPath()
        
        AddPathBox(DrawingX, DrawingY, 5, 10)
        VectorSourceColor(RGBA(0, 255, 0, 255))
        FillPath()
        
        Debug Str(CanvasX) + "px" + ":" + Str(CanvasY) + "px"
        Debug Str(DrawingX) + "pt" + ":" + Str(DrawingY) + "pt"
        StopVectorDrawing()
      EndIf
      
    EndIf
    
  Until Event = #PB_Event_CloseWindow
EndIf
Merci
Avatar de l’utilisateur
microdevweb
Messages : 1802
Inscription : mer. 29/juin/2011 14:11
Localisation : Belgique

Re: [PB 5.40]Lib Vector - Coordonées - Pas tout compris ou b

Message par microdevweb »

Voila le code corrigé
il falait utilisé #PB_Unit_Pixel et non #PB_Unit_Point

Code : Tout sélectionner

If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 400, 200)   
 
  Repeat
    Event = WaitWindowEvent()
   
    If Event = #PB_Event_Gadget And EventGadget() = 0 And EventType() = #PB_EventType_LeftButtonDown
      CanvasX.d = GetGadgetAttribute(0, #PB_Canvas_MouseX)
      CanvasY.d = GetGadgetAttribute(0, #PB_Canvas_MouseY)
          
     If StartVectorDrawing(CanvasVectorOutput(0, #PB_Unit_Pixel))
            
        DrawingX = ConvertCoordinateX(CanvasX, CanvasY, #PB_Coordinate_Device, #PB_Coordinate_User)
        DrawingY = ConvertCoordinateY(CanvasX, CanvasY, #PB_Coordinate_Device, #PB_Coordinate_User)
        AddPathBox(CanvasX, CanvasY, 10, 5)
        VectorSourceColor(RGBA(255, 0, 0, 255))
        FillPath()
        AddPathBox(DrawingX, DrawingY, 5, 10)
        VectorSourceColor(RGBA(0, 255, 0, 255))
        FillPath()
;         Debug Str(CanvasX) + "px" + ":" + Str(CanvasY) + "px"
;         Debug Str(DrawingX) + "pt" + ":" + Str(DrawingY) + "pt"
        StopVectorDrawing()
      EndIf
     
    EndIf
   
  Until Event = #PB_Event_CloseWindow
EndIf
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Torp
Messages : 360
Inscription : lun. 22/nov./2004 13:05

Re: [PB 5.40]Lib Vector - Coordonées - Pas tout compris ou b

Message par Torp »

Merci pour la réponse, mais c'était bien un bug. Cela ne se produit plus avec la nouvelle version.

PS : Me suis aperçu que j'avais posté au mauvais endroit, je pensais être dans débutant. Si qq pouvait déplacer le post. Merci.
Répondre