diff --git a/pkg/path/splines.go b/pkg/path/splines.go index aa80281..6c5445b 100644 --- a/pkg/path/splines.go +++ b/pkg/path/splines.go @@ -2,10 +2,10 @@ package path import ( "fmt" - "git.wtrh.nl/patterns/gopatterns/pkg/util" "log/slog" "git.wtrh.nl/patterns/gopatterns/pkg/point" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "github.com/tdewolff/canvas" splines "gitlab.com/Achilleshiel/gosplines" ) diff --git a/pkg/pattern/pattern.go b/pkg/pattern/pattern.go index b3ee4d3..d11f211 100644 --- a/pkg/pattern/pattern.go +++ b/pkg/pattern/pattern.go @@ -3,11 +3,11 @@ package pattern import ( "fmt" - "git.wtrh.nl/patterns/gopatterns/pkg/util" "git.wtrh.nl/patterns/gopatterns/pkg/dimensions" "git.wtrh.nl/patterns/gopatterns/pkg/pattern/text" "git.wtrh.nl/patterns/gopatterns/pkg/point" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "github.com/tdewolff/canvas" "golang.org/x/image/font/gofont/goregular" "gopkg.in/Knetic/govaluate.v3" diff --git a/pkg/point/between_point.go b/pkg/point/between_point.go index 33168aa..f585dab 100644 --- a/pkg/point/between_point.go +++ b/pkg/point/between_point.go @@ -1,10 +1,10 @@ package point import ( - "git.wtrh.nl/patterns/gopatterns/pkg/util" "math" "git.wtrh.nl/patterns/gopatterns/pkg/position" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "git.wtrh.nl/patterns/gopatterns/pkg/vector" "github.com/tdewolff/canvas" ) @@ -53,8 +53,7 @@ func (b *BetweenPoint) Vector() vector.Vector { // Matrix calculates and returns the [canvas.Matrix] of a point. func (b *BetweenPoint) Matrix() canvas.Matrix { - return b.p.Matrix().Translate(b.inBetween().Values()). - Rotate((b.p.Vector().AngleBetween(b.q.Vector()) - math.Pi/2) * 180 / math.Pi) + return canvas.Identity.Translate(b.Vector().Values()).Rotate(b.Position().RotationD()) } // ID returns the point ID. diff --git a/pkg/point/extend_point.go b/pkg/point/extend_point.go index d8c1f6f..70a5e25 100644 --- a/pkg/point/extend_point.go +++ b/pkg/point/extend_point.go @@ -1,10 +1,10 @@ package point import ( - "git.wtrh.nl/patterns/gopatterns/pkg/util" "math" "git.wtrh.nl/patterns/gopatterns/pkg/position" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "git.wtrh.nl/patterns/gopatterns/pkg/vector" "github.com/tdewolff/canvas" ) diff --git a/pkg/point/relative_point.go b/pkg/point/relative_point.go index 0dbab40..9762fa5 100644 --- a/pkg/point/relative_point.go +++ b/pkg/point/relative_point.go @@ -1,10 +1,10 @@ package point import ( - "git.wtrh.nl/patterns/gopatterns/pkg/util" "math" "git.wtrh.nl/patterns/gopatterns/pkg/position" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "git.wtrh.nl/patterns/gopatterns/pkg/vector" "github.com/tdewolff/canvas" ) diff --git a/pkg/position/position.go b/pkg/position/position.go index 80b203f..3050ed8 100644 --- a/pkg/position/position.go +++ b/pkg/position/position.go @@ -22,8 +22,9 @@ func (p Position) Add(q Position) Position { } } +// RotationD returns the rotation angle of the position in degrees. func (p Position) RotationD() float64 { - return p.Rotation*180/math.Pi + return p.Rotation * 180 / math.Pi } // Distance returns the distance between two positions. diff --git a/pkg/template/line.go b/pkg/template/line.go index 3058cc0..8f5d1c1 100644 --- a/pkg/template/line.go +++ b/pkg/template/line.go @@ -2,11 +2,11 @@ package template import ( "errors" - "git.wtrh.nl/patterns/gopatterns/pkg/util" "git.wtrh.nl/patterns/gopatterns/pkg/path" "git.wtrh.nl/patterns/gopatterns/pkg/pattern" "git.wtrh.nl/patterns/gopatterns/pkg/point" + "git.wtrh.nl/patterns/gopatterns/pkg/util" ) var ErrLineNotFound = errors.New("required path not found") diff --git a/pkg/template/point.go b/pkg/template/point.go index 622661d..eff169c 100644 --- a/pkg/template/point.go +++ b/pkg/template/point.go @@ -3,13 +3,13 @@ package template import ( "errors" "fmt" - "git.wtrh.nl/patterns/gopatterns/pkg/path" - "git.wtrh.nl/patterns/gopatterns/pkg/util" "maps" "math" "strconv" + "git.wtrh.nl/patterns/gopatterns/pkg/path" "git.wtrh.nl/patterns/gopatterns/pkg/point" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "gopkg.in/Knetic/govaluate.v3" ) diff --git a/pkg/template/point_test.go b/pkg/template/point_test.go index 99d5943..a20a589 100644 --- a/pkg/template/point_test.go +++ b/pkg/template/point_test.go @@ -2,7 +2,6 @@ package template_test import ( _ "embed" - "git.wtrh.nl/patterns/gopatterns/pkg/util" "math" "testing" @@ -10,6 +9,7 @@ import ( "git.wtrh.nl/patterns/gopatterns/pkg/position" "git.wtrh.nl/patterns/gopatterns/pkg/position/testutil" "git.wtrh.nl/patterns/gopatterns/pkg/template" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "git.wtrh.nl/patterns/gopatterns/pkg/vector" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" @@ -231,11 +231,11 @@ func TestFunctions(t *testing.T) { tests := map[string]struct { result float64 }{ - "distance": {result: 5}, - "angle": {result: math.Atan2(3, 4)}, - "yDistance": {result: 3}, - "xDistance": {result: 4}, - "lineLength": {result: 12}, + "distance": {result: 5}, + "angle": {result: math.Atan2(3, 4)}, + "yDistance": {result: 3}, + "xDistance": {result: 4}, + "lineLength": {result: 12}, "lineLength2": {result: 4}, } temp := &template.Template{} diff --git a/pkg/util/id_test.go b/pkg/util/id_test.go index dad652b..0f9dd1f 100644 --- a/pkg/util/id_test.go +++ b/pkg/util/id_test.go @@ -1,9 +1,10 @@ package util_test import ( + "testing" + "git.wtrh.nl/patterns/gopatterns/pkg/util" "github.com/stretchr/testify/require" - "testing" ) func TestID(t *testing.T) { @@ -20,7 +21,7 @@ func TestID(t *testing.T) { }, "1.test": { panel: "1", - name:"test", + name: "test", }, } for testName, tt := range tests { @@ -30,4 +31,4 @@ func TestID(t *testing.T) { require.Equal(t, tt.name, id.Name()) }) } -} \ No newline at end of file +} diff --git a/templates/tailored_shirt_block.yaml b/templates/tailored_shirt_block.yaml index 5ac9866..6276c1e 100644 --- a/templates/tailored_shirt_block.yaml +++ b/templates/tailored_shirt_block.yaml @@ -367,8 +367,8 @@ panels: 8a: between: from: 4 - to: 0 - offset: 0.25 + to: 9a + offset: 0.5 8: relativeTo: 8a position: @@ -384,9 +384,9 @@ panels: x: -12.5 10a: between: - from: 4 + from: 9a to: 0 - offset: 0.75 + offset: 0.5 10: relativeTo: 10a position: