set scriptDir [file normalize [file join [file dirname [info script]] ".."]]
set auto_path [linsert $auto_path 0 $scriptDir]

package require poFti

# Create icon object.
set iconObj [poFti Icon new]

# Create item and set draw type and color.
set itemObj [poFti Item new "Spiral"]

$itemObj SetType "line"
$itemObj SetColorRgb 170 0 200

# Spiral parameters.
set cx 50
set cy 50
set turns 5
set pointsPerTurn 20
set totalPoints [expr {$turns * $pointsPerTurn}]
set maxRadius 40

puts "Creating magenta spiral"
# Generate spiral points.
for {set i 0} {$i <= $totalPoints} {incr i} {
    set angle [expr {2.0 * 3.14159 * $i / $pointsPerTurn}]
    set radius [expr {double($i) / $totalPoints * $maxRadius}]
    
    set x [format "%.2f" [expr {$cx + $radius * cos($angle)}]]
    set y [format "%.2f" [expr {$cy + $radius * sin($angle)}]]
    
    $itemObj AddVertex $x $y
}

# Add item to icon and write icon as FTI file.
$iconObj AddItem $itemObj
puts "Writing file spiralSimple.fti ([$iconObj GetNumItems] item)"
$iconObj Write "spiralSimple.fti"

exit 0
