From ddb01005c88a1de6a2e53651f1aec5f9d7f5ff8b Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Tue, 2 Jan 2024 10:14:39 -0600 Subject: [PATCH] Inline simple curve_to method Shorter and more obvious to do the direct svg code (just a Q followed by the points). --- HexGrid/Path.pm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/HexGrid/Path.pm b/HexGrid/Path.pm index 5203dd5..3c3e9c1 100644 --- a/HexGrid/Path.pm +++ b/HexGrid/Path.pm @@ -40,10 +40,6 @@ sub get_edge_direction($tile1, $tile2) return undef; } -sub curve_to($qx, $qy, $x, $y) -{ - return "Q $qx,$qy $x,$y"; -} # Instance @@ -188,7 +184,7 @@ sub render($this, $grid, $svg) ($x0, $y0) = $grid->coords_of_edge($previous_tile->nw, $previous_tile->sw, $this->starts_from); $path_spec .= "M $x0,$y0 "; my ($cx, $cy) = $grid->coords_of_centre($previous_tile->nw, $previous_tile->sw); - $path_spec .= curve_to($cx, $cy, $x, $y); + $path_spec .= "Q $cx,$cy $x,$y"; } else { @@ -207,7 +203,7 @@ sub render($this, $grid, $svg) my ($qx,$qy) = $grid->coords_of_centre($current_tile->nw, $current_tile->sw); ($x,$y) = $grid->coords_of_edge($current_tile->nw, $current_tile->sw, $next_edge); - $path_spec .= " " . curve_to($qx,$qy, $x,$y); + $path_spec .= " Q $qx,$qy $x,$y"; $previous_tile = $current_tile; $current_tile = $next_tile; @@ -218,7 +214,7 @@ sub render($this, $grid, $svg) { ($x, $y) = $grid->coords_of_centre($current_tile->nw, $current_tile->sw); my ($xe, $ye) = $grid->coords_of_edge($current_tile->nw, $current_tile->sw, $this->ends_to); - $path_spec .= curve_to($x, $y, $xe, $ye); + $path_spec .= "Q $x,$y $xe,$ye"; } else {