Satimage Previous | Next
Text around a circle
Home Documentation Smile The graphic library Samples Text around a circle  
To write text other than horizontal you have to apply a geometrical transformation. This is done using SetTransformation.

You see here different uses of SetTransformation:
  • the first call shifts the origin to the center of the circle,
  • then an initial rotation is given,
  • finally successive incremental rotations are applied.
SetTransformation applies to the current state (SetTransformation is relative, not absolute), so rotations cumulate.
Import script

on SetRotation(a)
    SetTransformation({cos a, sin a, -1 * (sin a), cos a, 0, 0})
end SetRotation

-- variables that you can adjust
set s to "What a wonderful world!"
set d to 500
set da to pi / 30
set letter_size_ratio to 0.6

-- prepare data
set c to {d / 2, d / 2}
set r to {0, d / 2.5}
set n to s's length

SetTextSize(d * da * letter_size_ratio)
-- set the origin of coordinates to center
SetTransformation({1, 0, 0, 1} & c)
SetRotation(n / 2 * da)
repeat with i from 1 to n
    SetFillColor({1 - i / n, 1 / 2, i / n})
    DrawString("[h]" & character i of s)
end repeat
Version française
Copyright ©2008 Paris, Satimage