Tracé d'un cercle basique

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Tracé d'un cercle basique

Message par kernadec »

bjr à tous

@SPH oui c'est vrai que les fonctions vectorDrawing() sont classe :D

Utiliser la commande " RotateCoordinates(x, y, angle) " pour l' afficher avec un angle de rotation
cordialement

Code : Tout sélectionner

ch.d=250
cw.d=250
rayon.d=200
rayon2.d=150

If OpenWindow(0, 0, 0, 1000, 500, " Cercle Ellipse Gradués avec VectorDrawing ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 1000, 500)
  
  If StartVectorDrawing(CanvasVectorOutput(0))
    
    ; Mode Cercle
    AddPathCircle(cw + 500, ch, rayon, 0, 360)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(3, #PB_Path_RoundCorner)              ; Epaisseur du cercle
    
    For o= 0 To 360 Step 5                         ; Boucle Graduations Circle
      x.d = cw + 500 + rayon * Sin(Radian(o))
      y.d = ch + rayon * Cos(Radian(o))
      xx.d = cw + 500 + (rayon -20) * Sin(Radian(o))
      yy.d = ch + (rayon -20) * Cos(Radian(o))
      
      MovePathCursor(x, y)
      AddPathLine(x, y, #PB_Path_Default )
      AddPathLine(xx, yy, #PB_Path_Default)
      MovePathCursor(xx, yy)
    Next o
    
    VectorSourceColor(RGBA(0, 0, 0, 255))
    StrokePath(1, #PB_Path_RoundCorner)            ; Epaisseur des Graduations
    
    ; Mode Ellipse horizontale 
    RotateCoordinates(cw, ch, 45)                 ; angle 105
    AddPathEllipse(cw, ch, rayon, rayon2, 0, 360)
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(3, #PB_Path_RoundCorner)   
    
    For o= 0 To 360 Step 5                         ; Boucle Graduations Ellipse horizontale
      x.d = cw + rayon * Sin(Radian(o))
      y.d = ch + rayon2 * Cos(Radian(o))
      xx.d = cw + (rayon -20) * Sin(Radian(o))
      yy.d = ch + (rayon2 -20) * Cos(Radian(o))
      
      MovePathCursor(x, y)
      AddPathLine(x, y, #PB_Path_Default )
      AddPathLine(xx, yy, #PB_Path_Default)
      MovePathCursor(xx, yy)
    Next o
    
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(1, #PB_Path_RoundCorner)            ; Epaisseur des Graduations
    
    ; Mode Ellipse verticale 
    RotateCoordinates(cw, ch, 0)                  ; angle 45
    AddPathEllipse(cw, ch, rayon2, rayon, 0, 360)
    VectorSourceColor(RGBA(0, 0, 255, 255))
    StrokePath(3, #PB_Path_RoundCorner)   
    
    For o= 0 To 360 Step 5                         ; Boucle Graduations Ellipse verticale
      x.d = ch + rayon2 * Sin(Radian(o))
      y.d = cw + rayon * Cos(Radian(o))
      xx.d = ch + (rayon2 -20) * Sin(Radian(o))
      yy.d = cw + (rayon -20) * Cos(Radian(o))
      
      MovePathCursor(x, y)
      AddPathLine(x, y, #PB_Path_Default )
      AddPathLine(xx, yy, #PB_Path_Default)
      MovePathCursor(xx, yy)
    Next o
    
    VectorSourceColor(RGBA(0, 0, 255, 255))
    StrokePath(1, #PB_Path_RoundCorner)            ; Epaisseur des Graduations
    
    StopVectorDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Répondre