Inline simple curve_to method

Shorter and more obvious to do the direct svg code (just a Q followed by the points).
main
Daniel Asher Resnick 5 months ago
parent 4ddba48847
commit ddb01005c8
  1. 10
      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
{

Loading…
Cancel
Save