diff options
| author | Omar Rizwan <omar@omar.website> | 2023-07-10 17:17:04 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2023-07-10 17:17:04 +0000 |
| commit | 34fe40bd470793dd0f35a512b9e2c85ff0c8b5ee (patch) | |
| tree | 942d48673d76f066faa447162f74ba4eb07a278f | |
| parent | Better thread errors (diff) | |
| download | folk-34fe40bd470793dd0f35a512b9e2c85ff0c8b5ee.tar.gz folk-34fe40bd470793dd0f35a512b9e2c85ff0c8b5ee.zip | |
Actually fix stroke
| -rw-r--r-- | pi/Display.tcl | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/pi/Display.tcl b/pi/Display.tcl index 5804614d..def14ca6 100644 --- a/pi/Display.tcl +++ b/pi/Display.tcl @@ -289,28 +289,26 @@ namespace eval Display { } proc stroke {points width color} { - for {set i 0} {$i < [llength $points]} {incr i} { - set a [lindex $points $i] - set b [lindex $points [expr $i+1]] - if {$b == ""} break - - # if line is past edge of screen, clip it to the nearest - # point along edge of screen - clipLine a b $width - - set bMinusA [math::linearalgebra::sub $b $a] - if {[lindex $bMinusA 0] == 0.0 || [lindex $bMinusA 1] == 0.0} { - continue - } - set nudge [list [lindex $bMinusA 1] [expr {[lindex $bMinusA 0]*-1}]] - set nudge [math::linearalgebra::scale $width [math::linearalgebra::unitLengthVector $nudge]] - - set a0 [math::linearalgebra::add $a $nudge] - set a1 [math::linearalgebra::sub $a $nudge] - set b0 [math::linearalgebra::add $b $nudge] - set b1 [math::linearalgebra::sub $b $nudge] - fillTriangle $a0 $a1 $b1 [getColor $color] - fillTriangle $a0 $b0 $b1 [getColor $color] + for {set i 0} {$i < [expr {[llength $points] - 1}]} {incr i} { + try { + set a [lindex $points $i] + set b [lindex $points [expr $i+1]] + + # if line is past edge of screen, clip it to the nearest + # point along edge of screen + clipLine a b $width + + set bMinusA [math::linearalgebra::sub $b $a] + set nudge [list [lindex $bMinusA 1] [expr {[lindex $bMinusA 0]*-1}]] + set nudge [math::linearalgebra::scale $width [math::linearalgebra::unitLengthVector $nudge]] + + set a0 [math::linearalgebra::add $a $nudge] + set a1 [math::linearalgebra::sub $a $nudge] + set b0 [math::linearalgebra::add $b $nudge] + set b1 [math::linearalgebra::sub $b $nudge] + fillTriangle $a0 $a1 $b1 [getColor $color] + fillTriangle $a0 $b0 $b1 [getColor $color] + } on error e {} } } |
