summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNaveen Michaud-Agrawal <naveen.michaudagrawal@gmail.com>2023-11-21 02:32:45 +0000
committerNaveen Michaud-Agrawal <naveen.michaudagrawal@gmail.com>2023-11-21 02:32:45 +0000
commiteb69cd6a28f86bb6fc5af0ef628f114b562c3db2 (patch)
tree15ad8ac06c5ec6ef9a9373e89d8e970973183263 /lib
parentMerge pull request #113 from FolkComputer/nm/sharper-color-text (diff)
downloadfolk-eb69cd6a28f86bb6fc5af0ef628f114b562c3db2.tar.gz
folk-eb69cd6a28f86bb6fc5af0ef628f114b562c3db2.zip
Region helper to create a new region center on x y
Diffstat (limited to 'lib')
-rw-r--r--lib/math.tcl12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/math.tcl b/lib/math.tcl
index cec6eee7..c87226cc 100644
--- a/lib/math.tcl
+++ b/lib/math.tcl
@@ -63,6 +63,18 @@ namespace eval ::region {
list $vertices $edges $angle
}
+ proc newRegion {x y w h {angle 0}} {
+ set hw [expr {$w / 2.}]
+ set hh [expr {$h / 2.}]
+ set vertices [list \
+ [list [expr {$x-$hw}] [expr {$y+$hh}]] \
+ [list [expr {$x+$hw}] [expr {$y+$hh}]] \
+ [list [expr {$x+$hw}] [expr {$y-$hh}]] \
+ [list [expr {$x-$hw}] [expr {$y-$hh}]]]
+ set edges [list [list 0 1] [list 1 2] [list 2 3] [list 3 0]]
+ region rotate [region create $vertices $edges] $angle
+ }
+
proc vertices {r} { lindex $r 0 }
proc edges {r} { lindex $r 1 }
# Angle the region is rotated above the horizontal, in radians: