Skip to content

Commit 49c04b2

Browse files
fix: Turtle.get/set_ViewBox negative bounds ( Fixes #286 )
No longer offsetting path data from origin unless Start is present
1 parent 66c0639 commit 49c04b2

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

Types/Turtle/get_PathData.ps1

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
1212
This format can also be used as a [Path2D](https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D) in a Canvas element.
1313
14-
It can also be used in WPF, where it is simply called [Path Markup](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/path-markup-syntax)
14+
It can also be used in WPF, where it is simply called [Path Markup](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/path-markup-syntax)
1515
.LINK
1616
https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorials/SVG_from_scratch/Paths
1717
.LINK
1818
https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D
1919
.LINK
20-
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/path-markup-syntax
20+
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/path-markup-syntax?wt.mc_id=MVP_321542
21+
.EXAMPLE
22+
turtle square 42 pathdata
2123
#>
2224
@(
2325
# Let's call this trick Schrödinger's rounding.
@@ -35,34 +37,9 @@
3537
} else {
3638
"m $($this.Start.x) $($this.Start.y)"
3739
}
38-
3940
}
4041
else {
41-
@("m"
42-
# If the viewbox has been manually set
43-
if ($this.'.ViewBox') {
44-
0, 0 # do not adjust our starting position
45-
} else {
46-
# otherwise, translate by the minimum point.
47-
if ($this.Minimum.X -lt 0) {
48-
if ($precision) {
49-
-1 * $this.Minimum.X | roundToPrecision
50-
} else {
51-
-1 * $this.Minimum.X
52-
}
53-
}
54-
else { 0 }
55-
56-
if ($this.Minimum.Y -lt 0) {
57-
if ($precision) {
58-
-1 * $this.Minimum.Y | roundToPrecision
59-
} else {
60-
-1 * $this.Minimum.Y
61-
}
62-
63-
}
64-
else { 0 }
65-
}) -join ' '
42+
"m 0 0"
6643
}
6744

6845
# Walk over our steps

0 commit comments

Comments
 (0)