|
|
|
@@ -16,9 +16,9 @@ type Path struct { |
|
|
|
} |
|
|
|
|
|
|
|
// NewPath returns a new [Path]. |
|
|
|
func NewPath(points ...point.Point) Path { |
|
|
|
func NewPath(points ...point.Point) *Path { |
|
|
|
black := canvas.Black |
|
|
|
return Path{points: points, color: black, thickness: 0.2} |
|
|
|
return &Path{points: points, color: black, thickness: 0.2} |
|
|
|
} |
|
|
|
|
|
|
|
// NewPathWithStyle returns a new [Path] with the specified thickness and color. |
|
|
|
@@ -26,8 +26,13 @@ func NewPathWithStyle(thickness float64, color color.RGBA, points ...point.Point |
|
|
|
return Path{points: points, color: color, thickness: thickness} |
|
|
|
} |
|
|
|
|
|
|
|
// SetThickness updates the tickness of the line |
|
|
|
func (p *Path) SetThickness(thickness float64) { |
|
|
|
p.thickness = thickness |
|
|
|
} |
|
|
|
|
|
|
|
// Draw the path to the provided [canvas.Canvas]. |
|
|
|
func (p Path) Draw(c *canvas.Canvas) error { |
|
|
|
func (p *Path) Draw(c *canvas.Canvas) error { |
|
|
|
polyline := canvas.Polyline{} |
|
|
|
for _, next := range p.points { |
|
|
|
polyline.Add(next.Vector().Values()) |
|
|
|
|