Satimage Previous | Next
Polygons and stars with smooth angles
Home Documentation Smile The graphic library Samples Polygons and stars with smooth angles  
ArcToPointPath is a sophisticated command which draws an arc of given radius as the angle between two lines. See here how to use it to draw a star with smooth angles (setting k to 1 will draw regular polygons).
Import 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)}

SetPenWidth(x / 50)
SetPenColor({0.0, 0.3, 1})
SetFillColor({1, 0.7, 0.0})
repeat with i from k to k * n by k
    ArcToPointPath(AngleToPt(i / n, r), AngleToPt(i / n + k / n, r), rr)
end repeat
Version française
Copyright ©2008 Paris, Satimage