some improvments

This commit is contained in:
Adrian Zürcher
2026-01-01 11:00:23 +01:00
parent 8f313c00f0
commit ef0778c8b3
20 changed files with 305 additions and 385 deletions

View File

@@ -11,36 +11,36 @@ func NewPath() Path {
return path
}
func (this Path) AppendPoint(point Point) Path {
this.Points = append(this.Points, point)
return this
func (p Path) AppendPoint(point Point) Path {
p.Points = append(p.Points, point)
return p
}
func (this Path) RemovePoint(number int) Path {
if number < 1 || number > len(this.Points) {
return this
func (p Path) RemovePoint(number int) Path {
if number < 1 || number > len(p.Points) {
return p
}
idx := number - 1
this.Points = append(this.Points[:idx], this.Points[idx+1:]...)
return this
p.Points = append(p.Points[:idx], p.Points[idx+1:]...)
return p
}
func (this Path) Length() int {
return len(this.Points)
func (p Path) Length() int {
return len(p.Points)
}
func (this Path) GetPointNumber(number int) Point {
if number < 1 || number > len(this.Points) {
func (p Path) GetPointNumber(number int) Point {
if number < 1 || number > len(p.Points) {
return Point{}
}
return this.Points[number-1]
return p.Points[number-1]
}
func (path Path) Copy() Path {
func (p Path) Copy() Path {
pathcopy := Path{}
pathcopy.Points = []Point{}
for _, p := range path.Points {
for _, p := range p.Points {
pathcopy.Points = append(pathcopy.Points, p)
}
return pathcopy