AddPathRoundBox

Programmation d'applications complexes
Avatar de l’utilisateur
Micoute
Messages : 2522
Inscription : dim. 02/oct./2011 16:17
Localisation : 35520 La Mézière

AddPathRoundBox

Message par Micoute »

Bonsoir à tous, je ne sais pas si ça va intéresser quelqu'un, mais je trouve que cette fonction manque dans la librairie VectorDrawing, alors j'ai pensé à la rajouter.

Code : Tout sélectionner

Procedure AddPathRoundBox(x.d, y.d, Largeur.d, Hauteur.d, RayonCoin, Epaisseur, Couleur, pleine = #False, Drapeau = #PB_Path_Default)
  MovePathCursor(x + RayonCoin, y, Drapeau & #PB_Path_Relative)
  ;coin haut gauche
  AddPathEllipse(0, RayonCoin, RayonCoin, RayonCoin, 180, -90, #PB_Path_Relative)
  ;Ligne supérieure
  AddPathLine((Largeur-RayonCoin*2)-Epaisseur/2, 0, #PB_Path_Relative)
  ;Coin haut droite
  AddPathEllipse(0, RayonCoin, RayonCoin, RayonCoin, -90, 0, #PB_Path_Connected | #PB_Path_Relative)
  ;Ligne verticale droite
  AddPathLine(0, (Hauteur-RayonCoin*2)-Epaisseur/2, #PB_Path_Relative)
  ;Coin Bas droite
  AddPathEllipse(-RayonCoin, 0, RayonCoin, RayonCoin, 0, 90, #PB_Path_Connected | #PB_Path_Relative)
  ;Ligne inférieure
  AddPathLine((RayonCoin + RayonCoin-Largeur) + Epaisseur/2, 0, #PB_Path_Relative)
  ;Coin bas gauche
  AddPathEllipse(0, -RayonCoin, RayonCoin, RayonCoin, 90, 180, #PB_Path_Connected | #PB_Path_Relative)
  ClosePath()
  ;Définir la couleur
  VectorSourceColor(Couleur)
  
  If pleine
    ;si pleine = #True, remplir la box
    FillPath()
  Else
    ;sinon juste tracer un trait à l'épaisseur demandée
    StrokePath(epaisseur)
  EndIf  
EndProcedure

OpenWindow(0, 0, 0, 1920, 1040, "VectorRoundBox", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

CanvasGadget(0, 0, 0, 1920, 1040)
StartVectorDrawing(CanvasVectorOutput(0))
AddPathBox(0, 0, 1920, 1040)
VectorSourceColor($FF606060)
FillPath()

AddPathRoundBox( 100, 100, 500, 200, 20, 5, $FFAA9CFF, 1)
AddPathRoundBox( 100, 300, 500, 200, 20, 5, $FFFF9CAA)
AddPathRoundBox( 600, 100, 500, 200, 20, 5, $FFAAF9FC)
AddPathRoundBox( 600, 300, 500, 200, 20, 5, $FFF9FCAA, 1)
AddPathRoundBox(1100, 100, 500, 200, 20, 5, $FFF9AAFC)
AddPathRoundBox(1100, 300, 500, 200, 20, 5, $FFAAFCF9)
StopVectorDrawing()
Repeat
  Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow  
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 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
kwandjeen
Messages : 204
Inscription : dim. 16/juil./2006 21:44

Re: AddPathRoundBox

Message par kwandjeen »

Merci pour le partage :)
Répondre