Przeglądaj źródła

Add unit tests for points

undefined
Wouter Horlings 4 miesięcy temu
rodzic
commit
8682ca0111
3 zmienionych plików z 7 dodań i 3 usunięć
  1. +1
    -1
      pkg/path/path.go
  2. +2
    -2
      pkg/point/absolute_point.go
  3. +4
    -0
      pkg/position/position.go

+ 1
- 1
pkg/path/path.go Wyświetl plik

@@ -20,7 +20,7 @@ func (p *Polygon) Through() []point.Point {

// NewPolygon returns a new [Polygon].
func NewPolygon(points []point.Point, style Style, id util.ID) *Polygon {
return &Polygon{points: points, style: style}
return &Polygon{points: points, style: style, id: id}
}

// WithStyle updates the style of the Polygon.


+ 2
- 2
pkg/point/absolute_point.go Wyświetl plik

@@ -19,7 +19,7 @@ type AbsolutePoint struct {

// Matrix calculates and returns the [canvas.Matrix] of a point.
func (a *AbsolutePoint) Matrix() canvas.Matrix {
return canvas.Identity.Translate(a.position.Vector.Values()).Rotate(a.position.Rotation)
return canvas.Identity.Translate(a.position.Vector.Values()).Rotate(a.position.RotationD())
}

// ID returns the point ID.
@@ -69,7 +69,7 @@ func (a *AbsolutePoint) SetDraw() {

// UnsetDraw indicates that the point should not be drawn.
func (a *AbsolutePoint) UnsetDraw() {
a.draw = true
a.draw = false
}

// Hide returns if the point must remain hidden.


+ 4
- 0
pkg/position/position.go Wyświetl plik

@@ -22,6 +22,10 @@ func (p Position) Add(q Position) Position {
}
}

func (p Position) RotationD() float64 {
return p.Rotation*180/math.Pi
}

// Distance returns the distance between two positions.
func (p Position) Distance(q Position) float64 {
return p.Vector.Distance(q.Vector)


Ładowanie…
Anuluj
Zapisz