Satimage Précédent | Suivant
Polygones et étoiles à pointes arrondies
Accueil Documentation Smile La bibliothèque de dessin Samples Polygones et étoiles à pointes arrondies  
ArcToPointPath est une commande sophistiquée qui permet de dessiner un arc de rayon donné pour relier deux segments. Voyez ici comment l'utiliser pour dessiner un étoile à pointes arrondies (définir k à 1 dessinera des polygones réguliers).
Importer le script

on AngleToPt(a, r)
    global c
    set {cx, cy} to c
    set a to 2 * pi * a
    {cx + r * (sin a), cy + r * (cos a)}
end AngleToPt

set x to 500
set n to 5 -- number of sides
set k to 2 -- join vertex i to i+k
set rr to x / 50 -- the radius of the arcs
set r to x / 2.5
set c to {x / 2, x / 2}
set a to barycenter {AngleToPt(0, r), AngleToPt(k / n, r)}

BeginFigure(0)
SetPenWidth(x / 50)
SetPenColor({0.0, 0.3, 1})
SetFillColor({1, 0.7, 0.0})
MoveTo(a)
repeat with i from k to k * n by k
    ArcToPointPath(AngleToPt(i / n, r), AngleToPt(i / n + k / n, r), rr)
end repeat
ClosePath()
DrawPath(3)
EndFigure()
English version
Copyright ©2008 Paris, Satimage