From 558b479674b6865f2ccf18d437044fbd6fe5ec4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 4 Sep 2023 16:19:20 -0400 Subject: Begin rewriting shapes to correctly use centroid-relative positioning --- virtual-programs/shapes.folk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'virtual-programs') diff --git a/virtual-programs/shapes.folk b/virtual-programs/shapes.folk index 25c615c5..33d13767 100644 --- a/virtual-programs/shapes.folk +++ b/virtual-programs/shapes.folk @@ -58,7 +58,12 @@ proc shape {numPoints x y r {color white} {filled false} args} { } When /someone/ wishes /p/ draws a /color/ /shape/ offset /offsetVector/ & /p/ has region /r/ { - lassign [regionToInnerRect $r] x y width height + # -------------- + # TODO: Remove magic numbers, replace with consistent math defined off of centroid, width, and height + # -------------- + lassign [region centroid $r] x y + set width [region width $r] + set height [region height $r] lassign $offsetVector offsetX offsetY if {$offsetX != 0} { @@ -68,6 +73,8 @@ When /someone/ wishes /p/ draws a /color/ /shape/ offset /offsetVector/ & /p/ ha set y [expr {$y + $offsetY}] } + # Hmmmm, what's the point of adjustedWidth? To compensate for the wacky shape function? + # Solution is to probably refactor shae to return linked points of consistent size from centroid. set adjustedWidth [expr {$width * 0.25}] set x [expr { $x * 1.3}] set y [expr { $y * 1.25}] -- cgit v1.2.3