Besoin d'aide VectorDrawing

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
Naheulf
Messages : 193
Inscription : dim. 10/mars/2013 22:22
Localisation : France

Re: Besoin d'aide VectorDrawing

Message par Naheulf »

si je reprend le début de ton StartVectorDrawing() pour y ajouter deux lignes en bas du premier rectangle :

Code : Tout sélectionner

If StartVectorDrawing(CanvasVectorOutput(0))
		
		BoxX.d = 50.5
		BoxY.d = 25.5
		BoxWidth.d = 201
		BoxHeight.d = 50
		
		AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
		VectorSourceColor(RGBA(0, 0, 0, 255))
		StrokePath(1)
		
		; Dessin de la ligne du haut : aucun problème
		LineX1.d = BoxX.d + 0.5
		LineY1.d = BoxY.d + 0.5
		
		LineX2.d = LineX1.d + BoxWidth.d - 1
		LineY2.d = BoxY.d + 0.5
		
		Thickness.d = 10
		
		SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut, 10, 12)
		
		; Dessin de la ligne bleue du bas (code attendu en passant par une fonction qui fait tout) : 
		LineX1.d = BoxX.d + 0.5
		LineY1.d = BoxY.d + BoxHeight - 0.5
		
		LineX2.d = LineX1.d + BoxWidth.d - 1
		LineY2.d = BoxY.d + BoxHeight - 0.5
		
		Thickness.d = 10
		
		SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(0, 0, 255, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut, 10, 12)
		
		; Dessin de la ligne verte du bas (appels corrigé pour compenser les erreurs de la fonction): 
		LineX1.d = BoxX.d + 0.5
		LineY1.d = BoxY.d + BoxHeight - 0.5
		
		LineX2.d = LineX1.d + BoxWidth.d - 1
		LineY2.d = BoxY.d + BoxHeight - 0.5
		
		Thickness.d = 10
		
		SimplyVector_DrawLine(LineX1.d, LineY1.d - Thickness, LineX2.d, LineY2.d - Thickness, RGBA(0, 255, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut, 10, 12)
Comme on peut le voir en exécutant le code, la ligne bleue est mal positionnée. On est obligé d’apporter un correction selon l'axe des y pour :
- 1 : annuler le mauvais offset fait par la fonction (-Thickness/2)
- 2 : faire le boulot qu'aurait dû faire la fonction (-Thickness/2)
Ce qui donne (en factorisant l tout) : -Thickness
Shadow
Messages : 1413
Inscription : mer. 04/nov./2015 17:39

Re: Besoin d'aide VectorDrawing

Message par Shadow »

Regarde, voici ce que ça donne sans aucune correction, tu comprends maintenant ou je veux en venir ?

Code : Tout sélectionner

If OpenWindow(0, 0, 0, 800, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 800, 600)
  
  If StartVectorDrawing(CanvasVectorOutput(0))
    
    BoxX.d = 50.5
    BoxY.d = 25.5
    BoxWidth.d = 201
    BoxHeight.d = 50
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(Thickness, #PB_Path_Default)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(Thickness, #PB_Path_SquareEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(Thickness, #PB_Path_RoundEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DashPath(10, 12, #PB_Path_Default)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DashPath(10, 12, #PB_Path_SquareEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DashPath(10, 12, #PB_Path_RoundEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DotPath(10, 12, #PB_Path_Default)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DotPath(10, 12, #PB_Path_RoundEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DotPath(10, 12, #PB_Path_SquareEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(Thickness, #PB_Path_Default)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(Thickness, #PB_Path_SquareEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(Thickness, #PB_Path_RoundEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DashPath(10, 12, #PB_Path_Default)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DashPath(10, 12, #PB_Path_SquareEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DashPath(10, 12, #PB_Path_RoundEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DotPath(10, 12, #PB_Path_Default)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DotPath(10, 12, #PB_Path_RoundEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 20
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    MovePathCursor(LineX1.d, LineY1.d)
    AddPathLine(LineX2.d, LineY2.d)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    DotPath(10, 12, #PB_Path_SquareEnd)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    StopVectorDrawing()
    
  EndIf
  
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
  
EndIf
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Shadow
Messages : 1413
Inscription : mer. 04/nov./2015 17:39

Re: Besoin d'aide VectorDrawing

Message par Shadow »

Naheulf non ma fonction fonctionne parfaitement, tout est normale !
La fonction corrige la position et la taille mais la le code est niquel, c'est à toi d'indiquer les bonne position, dans ta ligne bleu tu ne prends pas en compte ça hauteur !
Après je crois que je comprends se que tu veux dire sauf que non, la fonction est bonne !
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Avatar de l’utilisateur
Naheulf
Messages : 193
Inscription : dim. 10/mars/2013 22:22
Localisation : France

Re: Besoin d'aide VectorDrawing

Message par Naheulf »

Bah du coup fait moi ta correction de mon code de la ligne bleue. Car c'est possible que j'ai loupé un truc.
Shadow
Messages : 1413
Inscription : mer. 04/nov./2015 17:39

Re: Besoin d'aide VectorDrawing

Message par Shadow »

Quand tu dessine une ligne tu la dessine de haut en bas et pas l'inverse !

Si tu dis au programme de la dessiner tout en bas du rectangle et quel dépasse celui-ci, c'est normale, tu n'as pas pris en compte ça hauteur !
Ici ma routine te calcule tous, peut importe de ou tu dessine la ligne, de gauche vers la droite ou de droite vers la gauche.

Ma routine prends en compte la position originale puis le type de ligne et des options qui vont avec et te la dessine ou tu t’attends à ce quel soit dessiné !
Actuellement, la hauteur de ligne n'est pas prix en compte dans les vecteurs, elle change avec l’épaisseur, mais aussi avec le type de ligne aux extrémité normale, carré ou ronde !
Bref, donc ici ma routine marche très bien !

Cependant je suis sur quel contient quelque erreurs de position mais elle marche !
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Avatar de l’utilisateur
Naheulf
Messages : 193
Inscription : dim. 10/mars/2013 22:22
Localisation : France

Re: Besoin d'aide VectorDrawing

Message par Naheulf »

Bah justement : si je doit prendre en compte la hauteur je fait le boulot de la procédure. Donc elle ne sert à rien...
Shadow
Messages : 1413
Inscription : mer. 04/nov./2015 17:39

Re: Besoin d'aide VectorDrawing

Message par Shadow »

C'est toi qui n'a pas compris comment ça marche !
Si je dois prendre la hauteur de la ligne en compte alors elle sera dessiner de - hauteur en Y, bha non c'est pas bon !
Tu veux dessiner ta ligne ou en Y, à 100 PX, elle commence à 100 PX ok ?
Et bien ça coule de source, ta ligne serra dessiner à 100 PX en Y, pas 100 - hauteur logique !
Le carré est un exemple, c'était pour faire marcher la routine et te montrer quel marche !
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Shadow
Messages : 1413
Inscription : mer. 04/nov./2015 17:39

Re: Besoin d'aide VectorDrawing

Message par Shadow »

Bon, j'ai revue complètement le code, il est clair que j'avais pondus un gros pavé pour rien !
J'ai transformer le pavé en petite pierre :mrgreen:

Pourquoi faire simple quand ont peux faire compliqué :)
Mais c'est ça le soucis, quand ont ne maîtrise pas le sujet !

Je pense que la routine est correcte, bien que je trouve le comportement des vecteur étrange :?
En mode Default, ça fonctionne plutôt pas trop mal mais peut mieux faire, mais sinon ya des décalage important je trouve.
Quand la ligne est pivoté, c'est là ou intervienne les soucis !

Code : Tout sélectionner

#SV_TypeLine = 1   ; Ligne
#SV_TypeDash = 2   ; Tirets
#SV_TypeDot = 3    ; Points

#SV_StyleDefaut = #PB_Path_Default                 ; Pas de comportement spécial (Par défaut).
#SV_StyleRoundEnd = #PB_Path_RoundEnd              ; Trace la ligne avec des extrémités arrondies.
#SV_StyleSquareEnd = #PB_Path_SquareEnd            ; Trace la ligne avec un carré aux extrémités.
#SV_StyleRoundCorner = #PB_Path_RoundCorner        ; Trace la ligne avec des coins arrondis.
#SV_StyleDiagonalCorner = #PB_Path_DiagonalCorner  ; Trace la ligne avec les coins coupés en diagonal.

;{ Draw a line at the indicated position and of the desired size.
; VectorImage.i = Image.
; X1.d = Start X position.
; Y1.d = Starting Y position.
; X2.d = End X position.
; Y2.d = End X position.
; Color.q = Line color.
; Thickness.d = Thickness of the line, the position of the patterns will be automatically centered on this line in relation To their Width (Length.d) If the type chosen is #SV_TypeDash Or #SV_TypeDoth.
; 
; Type: #SV_TypeLine : Draws a continuous line.
; #SV_TypeDash: Draws a discontinuous line with Dashes.
; #SV_TypeDot: Draws a discontinuous line with Dots.
; 
; Style: #SV_StyleRoundEnd: Draws a line With rounded ends.
; #SV_StyleSquareEnd: Draws the line with a square at the ends.
;
; Length: Length (If Style <> #SV_StyleDefault) Or Width (If Style = #SV_StyleDefault) of the Pattern Traits (Square, Round) If Type = #SV_TypeDash Or #SV_TypeDot, otherwise no effect.
; Distance: Distance between patterns (Square, Round) If Type = #SV_TypeDash Or #SV_TypeDot, otherwise no effect.
;
; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; 
; Trace une ligne à la position indiqué et de la taille désiré.
; VectorImage.i = Image.
; X1.d = Position X de départ.
; Y1.d = Position Y de départ.
; X2.d = Position X de fin.
; Y2.d = Position X de fin.
; Color.q = Couleur de la ligne.
; Thickness.d = Epaisseur de la ligne, la position des motifs sera automatiquement centré sur cette ligne par apport à leur Largeur (Length.d) si le type choisie est #SV_TypeDash ou #SV_TypeDoth.
; 
; Type: #SV_TypeLine              : Trace une ligne continue.
;       #SV_TypeDash              : Trace une ligne discontinue avec des Tirets.
;       #SV_TypeDot               : Trace une ligne discontinue avec des Points.
; 
; Style: #SV_StyleRoundEnd        : Trace la ligne avec des extrémités arrondies.
;        #SV_StyleSquareEnd       : Trace la ligne avec un carré aux extrémités.
;
; Length: Longueur (Si Style <> #SV_StyleDefaut) ou Largeur (Si Style = #SV_StyleDefaut) des Traits des motifs (Carré, Rond) si Type = #SV_TypeDash ou #SV_TypeDot, sinon pas d'effet.
; Distance: Distance entre les motifs (Carré, Rond) si Type = #SV_TypeDash ou #SV_TypeDot, sinon pas d'effet.
;}
Procedure.b SimplyVector_DrawLine(X1.d, Y1.d, X2.d, Y2.d, Color.q = 18446744073692774400, Thickness.d = 1, Type.i = #SV_TypeLine, Style.i = #SV_StyleSquareEnd, Length.d = 10, Distance.d = 10)
  
  If Type.i = #SV_TypeLine
    If Style.i = #SV_StyleSquareEnd Or Style.i = #SV_StyleRoundEnd
      MovePathCursor(X1.d + (Thickness.d / 2), Y1.d + (Thickness.d / 2))
      AddPathLine(X1.d + (X2.d - X1.d) - (Thickness.d / 2), Y2.d + (Thickness.d / 2))
    Else
      MovePathCursor(X1.d, Y1.d + (Thickness.d / 2))
      AddPathLine(X2.d, Y2.d + (Thickness.d / 2))
    EndIf
  Else
    If Style.i = #SV_StyleSquareEnd Or Style.i = #SV_StyleRoundEnd
      MovePathCursor(X1.d + (Length.d / 2), Y1.d + (Length.d / 2))
      AddPathLine(X1.d + (X2.d - X1.d) - (Length.d / 2), Y2.d + (Length.d / 2))
    Else
      MovePathCursor(X1.d, Y1.d + (Length.d / 2))
      AddPathLine(X2.d, Y2.d + (Length.d / 2))
    EndIf
  EndIf

  VectorSourceColor(Color.q)
  
  Select Type.i
      
    Case #SV_TypeLine ; 1
      StrokePath(Thickness.d, Style.i)
      
    Case #SV_TypeDash ; 2
      DashPath(Length.d, Distance.d, Style.i)
      
    Case #SV_TypeDot ; 3
      DotPath(Length.d, Distance.d, Style.i)
      
    Default ; 1
      StrokePath(Thickness.d, Style.i)
      
  EndSelect
  
  ProcedureReturn 1
  
EndProcedure

If OpenWindow(0, 0, 0, 800, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 800, 600)
  
  If StartVectorDrawing(CanvasVectorOutput(0))
    
    BoxX.d = 50.5
    BoxY.d = 25.5
    BoxWidth.d = 201
    BoxHeight.d = 50
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleSquareEnd, 10, 12)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleRoundEnd, 10, 12)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleDefaut, 10, 2)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleSquareEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleRoundEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleDefaut, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleSquareEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleRoundEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 25
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleSquareEnd, 10, 12)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleRoundEnd, 10, 12)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleDefaut, 10, 2)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleSquareEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleRoundEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleDefaut, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleSquareEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5 + BoxHeight.d
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleRoundEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 25
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleSquareEnd, 10, 12)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleRoundEnd, 10, 12)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleDefaut, 10, 2)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleSquareEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDash, #SV_StyleRoundEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    BoxX.d = 50.5
    BoxY.d + BoxHeight.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleDefaut, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleSquareEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    BoxX.d + BoxWidth.d + 5
    
    AddPathBox(BoxX.d, BoxY.d, BoxWidth.d, BoxHeight.d)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1)
    
    LineX1.d = BoxX.d + 0.5
    LineY1.d = BoxY.d + 0.5 + BoxHeight.d
    
    LineX2.d = LineX1.d + BoxWidth.d - 1
    LineY2.d = BoxY.d + 0.5
    
    Thickness.d = 10
    
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleRoundEnd, 10, 11)
    
    ; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    StopVectorDrawing()
    
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Avatar de l’utilisateur
falsam
Messages : 7317
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Besoin d'aide VectorDrawing

Message par falsam »

Bonjour Shadow.

■ Pourquoi chercher à créer de nouvelles constantes quand celles ci existe déja.

Code : Tout sélectionner

#SV_StyleDefaut = #PB_Path_Default
il en est de même pour les autres.

Code : Tout sélectionner

#SV_StyleDefaut = #PB_Path_Default                 ; Pas de comportement spécial (Par défaut).
#SV_StyleRoundEnd = #PB_Path_RoundEnd              ; Trace la ligne avec des extrémités arrondies.
#SV_StyleSquareEnd = #PB_Path_SquareEnd            ; Trace la ligne avec un carré aux extrémités.
#SV_StyleRoundCorner = #PB_Path_RoundCorner        ; Trace la ligne avec des coins arrondis.
#SV_StyleDiagonalCorner = #PB_Path_DiagonalCorner  ; Trace la ligne avec les coins coupés en diagonal.
■ L'épaisseur du trait dans ton exemple ne fonctionne pas.

Code : Tout sélectionner

#SV_TypeLine = 1   ; Ligne
#SV_TypeDash = 2   ; Tirets
#SV_TypeDot = 3    ; Points

#SV_StyleDefaut = #PB_Path_Default                 ; Pas de comportement spécial (Par défaut).
#SV_StyleRoundEnd = #PB_Path_RoundEnd              ; Trace la ligne avec des extrémités arrondies.
#SV_StyleSquareEnd = #PB_Path_SquareEnd            ; Trace la ligne avec un carré aux extrémités.
#SV_StyleRoundCorner = #PB_Path_RoundCorner        ; Trace la ligne avec des coins arrondis.
#SV_StyleDiagonalCorner = #PB_Path_DiagonalCorner  ; Trace la ligne avec les coins coupés en diagonal.


Procedure.b SimplyVector_DrawLine(X1.d, Y1.d, X2.d, Y2.d, Color.q = 18446744073692774400, Thickness.d = 1, Type.i = #SV_TypeLine, Style.i = #SV_StyleSquareEnd, Length.d = 10, Distance.d = 10)
 
  If Type.i = #SV_TypeLine
    If Style.i = #SV_StyleSquareEnd Or Style.i = #SV_StyleRoundEnd
      MovePathCursor(X1.d + (Thickness.d / 2), Y1.d + (Thickness.d / 2))
      AddPathLine(X1.d + (X2.d - X1.d) - (Thickness.d / 2), Y2.d + (Thickness.d / 2))
    Else
      MovePathCursor(X1.d, Y1.d + (Thickness.d / 2))
      AddPathLine(X2.d, Y2.d + (Thickness.d / 2))
    EndIf
  Else
    If Style.i = #SV_StyleSquareEnd Or Style.i = #SV_StyleRoundEnd
      MovePathCursor(X1.d + (Length.d / 2), Y1.d + (Length.d / 2))
      AddPathLine(X1.d + (X2.d - X1.d) - (Length.d / 2), Y2.d + (Length.d / 2))
    Else
      MovePathCursor(X1.d, Y1.d + (Length.d / 2))
      AddPathLine(X2.d, Y2.d + (Length.d / 2))
    EndIf
  EndIf

  VectorSourceColor(Color.q)
 
  Select Type.i
     
    Case #SV_TypeLine ; 1
      StrokePath(Thickness.d, Style.i)
     
    Case #SV_TypeDash ; 2
      DashPath(Length.d, Distance.d, Style.i)
     
    Case #SV_TypeDot ; 3
      DotPath(Length.d, Distance.d, Style.i)
     
    Default ; 1
      StrokePath(Thickness.d, Style.i)
     
  EndSelect
 
  ProcedureReturn 1
 
EndProcedure

If OpenWindow(0, 0, 0, 800, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 800, 600)
 
  If StartVectorDrawing(CanvasVectorOutput(0))
   
    LineX1.d = 0
    LineY1.d = 100
   
    LineX2.d = 100
    LineY2.d = 0
   
    Thickness.d = 1 ; ou  100 Ne change rien
   
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeDot, #SV_StyleRoundEnd, 10, 11)
   
    StopVectorDrawing()
  EndIf
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Thickness.d = 1 ou 100 ne change rien.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
falsam
Messages : 7317
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Besoin d'aide VectorDrawing

Message par falsam »

Je ne comprends pas pourquoi tu cherches à recalculer le positionnement de la ligne en fonction de l'épaisseur de cette ligne.

Avec ce code je crée deux rectangles avec les fonctions natives de PureBasic et je trace une diagonale.
- La diagonale du rectangle de gauche est tracée avec ta fonction SimplyVector_DrawLine()
- La diagonale du rectangle de droite est tracée avec ma fonction VectorLineXY()

Code : Tout sélectionner

Procedure VectorLineXY(x0, y0, x1, y1, Color = 0)
  VectorSourceColor(Color)
  MovePathCursor(x0, y0)
  AddPathLine(x1 - x0, y1 - y0, #PB_Path_Relative)
EndProcedure

■ Exécutes ce code et tu verras que la diagonale crée avec ta procédure (Rectangle de gauche) se positionne mal.

Code : Tout sélectionner

#SV_TypeLine = 1   ; Ligne
#SV_TypeDash = 2   ; Tirets
#SV_TypeDot = 3    ; Points

#SV_StyleDefaut = #PB_Path_Default                 ; Pas de comportement spécial (Par défaut).
#SV_StyleRoundEnd = #PB_Path_RoundEnd              ; Trace la ligne avec des extrémités arrondies.
#SV_StyleSquareEnd = #PB_Path_SquareEnd            ; Trace la ligne avec un carré aux extrémités.
#SV_StyleRoundCorner = #PB_Path_RoundCorner        ; Trace la ligne avec des coins arrondis.
#SV_StyleDiagonalCorner = #PB_Path_DiagonalCorner  ; Trace la ligne avec les coins coupés en diagonal.


Procedure.b SimplyVector_DrawLine(X1.d, Y1.d, X2.d, Y2.d, Color.q = 18446744073692774400, Thickness.d = 1, Type.i = #SV_TypeLine, Style.i = #SV_StyleSquareEnd, Length.d = 10, Distance.d = 10)
 
  If Type.i = #SV_TypeLine
    If Style.i = #SV_StyleSquareEnd Or Style.i = #SV_StyleRoundEnd
      MovePathCursor(X1.d + (Thickness.d / 2), Y1.d + (Thickness.d / 2))
      AddPathLine(X1.d + (X2.d - X1.d) - (Thickness.d / 2), Y2.d + (Thickness.d / 2))
    Else
      MovePathCursor(X1.d, Y1.d + (Thickness.d / 2))
      AddPathLine(X2.d, Y2.d + (Thickness.d / 2))
    EndIf
  Else
    If Style.i = #SV_StyleSquareEnd Or Style.i = #SV_StyleRoundEnd
      MovePathCursor(X1.d + (Length.d / 2), Y1.d + (Length.d / 2))
      AddPathLine(X1.d + (X2.d - X1.d) - (Length.d / 2), Y2.d + (Length.d / 2))
    Else
      MovePathCursor(X1.d, Y1.d + (Length.d / 2))
      AddPathLine(X2.d, Y2.d + (Length.d / 2))
    EndIf
  EndIf

  VectorSourceColor(Color.q)
 
  Select Type.i
     
    Case #SV_TypeLine ; 1
      StrokePath(Thickness.d, Style.i)
     
    Case #SV_TypeDash ; 2
      DashPath(Length.d, Distance.d, Style.i)
     
    Case #SV_TypeDot ; 3
      DotPath(Length.d, Distance.d, Style.i)
     
    Default ; 1
      StrokePath(Thickness.d, Style.i)
     
  EndSelect
 
  ProcedureReturn 1
 
EndProcedure

Procedure VectorLineXY(x0, y0, x1, y1, Color = 0)
  VectorSourceColor(Color)
  MovePathCursor(x0, y0)
  AddPathLine(x1 - x0, y1 - y0, #PB_Path_Relative)
EndProcedure

If OpenWindow(0, 0, 0, 800, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 800, 600)
 
  If StartVectorDrawing(CanvasVectorOutput(0))
    
    ;- Methode Shadow en utilisant la fontion SimplyVector_DrawLine() 
    LineX1.d = 20
    LineY1.d = 10
   
    LineX2.d = 320
    LineY2.d = 300
   
    Thickness.d = 20 
    
    ; Dessin d'un carré à gauche
    VectorSourceColor(RGBA(0, 0, 0, 255))
    AddPathBox(LineX1, LineY1, LineX2 - LineX1, LineY2 - LineY1)
    StrokePath(Thickness)
    
    ; Dessin de la ligne
    SimplyVector_DrawLine(LineX1.d, LineY1.d, LineX2.d, LineY2.d, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut, 10, 11)
    
    ; Method falsam  
    LineX1.d = 400
    LineY1.d = 10
   
    LineX2.d = 700
    LineY2.d = 300
    
    ; Dessin d'un carré à droite
    VectorSourceColor(RGBA(0, 0, 0, 255))
    AddPathBox(LineX1, LineY1, LineX2 - LineX1, LineY2 - LineY1)
    StrokePath(Thickness)
    
    VectorLineXY(LineX1, LineY1, LineX2, LineY2, RGBA(255, 0, 0, 255))  
    StrokePath(Thickness)
    
    StopVectorDrawing()
  EndIf
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Shadow
Messages : 1413
Inscription : mer. 04/nov./2015 17:39

Re: Besoin d'aide VectorDrawing

Message par Shadow »

Coucou Falsam,

Si si tkt pas ça marche....

En faite si le type de ligne est ligne, pas dash ni doth, alors Thickness serra utiliser sinon c'est Length !
Tu remarquera que le motif est centré sur la ligne donc si ça marche bien :)

Thickness = épaisseur de la ligne à tracé
Length = si le type de ligne est dash ou doth, alors Length serra utiliser !

Ainsi ça permet de centrer la ligne des motif sur cette ligne, essais tu verras :)
Ensuite regarde, je te prouve que ma routine marche, c'est les vecteur qui ont un soucis ont dirait ?
Les vecteur c'est la merde faut le dire :? :|

Code : Tout sélectionner

If OpenWindow(0, 0, 0, 800, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 800, 600)

  If StartVectorDrawing(CanvasVectorOutput(0))
   
    ;- Methode Shadow en utilisant la fontion SimplyVector_DrawLine()
    LineX1.d = 10
    LineY1.d = 10
   
    LineX2.d = 320
    LineY2.d = 300
   
    Thickness.d = 20
   
    ; Dessin d'un carré à gauche
    VectorSourceColor(RGBA(0, 0, 0, 255))
    AddPathBox(LineX1, LineY1, LineX2 - LineX1, LineY2 - LineY1)
    StrokePath(Thickness)
   
    ; Dessin de la ligne bleu
    SimplyVector_DrawLine(Thickness.d, Thickness.d, Thickness.d + (LineX2 - LineX1) - Thickness.d, Thickness.d, RGBA(0, 0, 255, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut, 10, 11)
    
    ; Dessin de la ligne rouge
    SimplyVector_DrawLine(Thickness.d, Thickness.d, LineX2 - LineX1, LineY2 - LineY1, RGBA(255, 0, 0, 255), Thickness.d, #SV_TypeLine, #SV_StyleDefaut, 10, 11)
    
    
    ; Method falsam 
    LineX1.d = 400
    LineY1.d = 10
   
    LineX2.d = 700
    LineY2.d = 300
   
    ; Dessin d'un carré à droite
    VectorSourceColor(RGBA(0, 0, 0, 255))
    AddPathBox(LineX1, LineY1, LineX2 - LineX1, LineY2 - LineY1)
    StrokePath(Thickness)
   
    VectorLineXY(LineX1, LineY1, LineX2, LineY2, RGBA(255, 0, 0, 255)) 
    StrokePath(Thickness)
   
    StopVectorDrawing()
  EndIf

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Avatar de l’utilisateur
falsam
Messages : 7317
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Besoin d'aide VectorDrawing

Message par falsam »

Shadow a écrit :Ensuite regarde, je te prouve que ma routine marche, c'est les vecteur qui ont un soucis ont dirait ?
Les vecteur c'est la merde faut le dire
J'abandonne :wink:
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Shadow
Messages : 1413
Inscription : mer. 04/nov./2015 17:39

Re: Besoin d'aide VectorDrawing

Message par Shadow »

falsam a écrit :
Shadow a écrit :Ensuite regarde, je te prouve que ma routine marche, c'est les vecteur qui ont un soucis ont dirait ?
Les vecteur c'est la merde faut le dire
J'abandonne :wink:
J'ai vraiment l'impression de pas être compris ici !
Tu abandonne, bien, comme tu veux !
Processeur: Intel Core I7-4790 - 4 Cœurs - 8 Thread: 3.60 Ghz.
Ram: 32 GB.
Disque: C: SDD 250 GB, D: 3 TB.
Vidéo: NVIDIA GeForce GTX 960: 2 GB DDR5.
Écran: Asus VX248 24 Pouces: 1920 x 1080.
Système: Windows 7 64 Bits.

PureBasic: 5.60 x64 Bits.
Avatar de l’utilisateur
grendizer
Messages : 61
Inscription : mer. 29/mai/2019 6:29

Re: Besoin d'aide VectorDrawing

Message par grendizer »

Shadow a écrit :
falsam a écrit :
Shadow a écrit :Ensuite regarde, je te prouve que ma routine marche, c'est les vecteur qui ont un soucis ont dirait ?
Les vecteur c'est la merde faut le dire
J'abandonne :wink:
J'ai vraiment l'impression de pas être compris ici !
Tu abandonne, bien, comme tu veux !

:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
Avatar de l’utilisateur
Micoute
Messages : 2583
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

Re: Besoin d'aide VectorDrawing

Message par Micoute »

Désolé Shadow, il y en a un qui ne comprend pas, ou alors c'est tous les autres.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 6.20 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
Répondre