| @@ -1,20 +1,20 @@ | |||
| module git.wtrh.nl/patterns/gopatterns | |||
| go 1.24.5 | |||
| go 1.25.1 | |||
| require ( | |||
| github.com/stoewer/go-strcase v1.3.1 | |||
| github.com/stretchr/testify v1.10.0 | |||
| github.com/tdewolff/canvas v0.0.0-20250508181010-75987a1ae9cc | |||
| github.com/stretchr/testify v1.11.1 | |||
| github.com/tdewolff/canvas v0.0.0-20250923071733-b2b2ba99a987 | |||
| gitlab.com/Achilleshiel/gosplines v0.0.0-20240602125710-c93b87aea1ee | |||
| gitlab.com/slxh/go/env v1.2.0 | |||
| golang.org/x/image v0.29.0 | |||
| golang.org/x/image v0.31.0 | |||
| gopkg.in/Knetic/govaluate.v3 v3.0.0 | |||
| gopkg.in/yaml.v3 v3.0.1 | |||
| ) | |||
| require ( | |||
| codeberg.org/go-latex/latex v0.1.0 // indirect | |||
| codeberg.org/go-latex/latex v0.2.0 // indirect | |||
| codeberg.org/go-pdf/fpdf v0.11.1 // indirect | |||
| github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 // indirect | |||
| github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 // indirect | |||
| @@ -33,12 +33,12 @@ require ( | |||
| github.com/pmezard/go-difflib v1.0.0 // indirect | |||
| github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect | |||
| github.com/srwiley/scanx v0.0.0-20190309010443-e94503791388 // indirect | |||
| github.com/tdewolff/font v0.0.0-20250602165824-bf05faa75fda // indirect | |||
| github.com/tdewolff/minify/v2 v2.23.8 // indirect | |||
| github.com/tdewolff/parse/v2 v2.8.1 // indirect | |||
| github.com/tdewolff/font v0.0.0-20250902141222-fb72ecc1bc0a // indirect | |||
| github.com/tdewolff/minify/v2 v2.24.3 // indirect | |||
| github.com/tdewolff/parse/v2 v2.8.4-0.20250902141113-be7b6b11bb1b // indirect | |||
| github.com/wcharczuk/go-chart/v2 v2.1.2 // indirect | |||
| golang.org/x/net v0.42.0 // indirect | |||
| golang.org/x/text v0.27.0 // indirect | |||
| golang.org/x/net v0.44.0 // indirect | |||
| golang.org/x/text v0.29.0 // indirect | |||
| gonum.org/v1/gonum v0.16.0 // indirect | |||
| gonum.org/v1/plot v0.16.0 // indirect | |||
| modernc.org/knuth v0.5.5 // indirect | |||
| @@ -4,12 +4,15 @@ codeberg.org/go-fonts/liberation v0.5.0 h1:SsKoMO1v1OZmzkG2DY+7ZkCL9U+rrWI09niOL | |||
| codeberg.org/go-fonts/liberation v0.5.0/go.mod h1:zS/2e1354/mJ4pGzIIaEtm/59VFCFnYC7YV6YdGl5GU= | |||
| codeberg.org/go-latex/latex v0.1.0 h1:hoGO86rIbWVyjtlDLzCqZPjNykpWQ9YuTZqAzPcfL3c= | |||
| codeberg.org/go-latex/latex v0.1.0/go.mod h1:LA0q/AyWIYrqVd+A9Upkgsb+IqPcmSTKc9Dny04MHMw= | |||
| codeberg.org/go-latex/latex v0.2.0 h1:Ol/a6VHY06N+5gPfewswymoRb5ZcKDXWVaVegcx4hbI= | |||
| codeberg.org/go-latex/latex v0.2.0/go.mod h1:VJAwQir7/T8LZxj7xAPivISKiVOwkMpQ8bTuPQ31X0Y= | |||
| codeberg.org/go-pdf/fpdf v0.11.1 h1:U8+coOTDVLxHIXZgGvkfQEi/q0hYHYvEHFuGNX2GzGs= | |||
| codeberg.org/go-pdf/fpdf v0.11.1/go.mod h1:Y0DGRAdZ0OmnZPvjbMp/1bYxmIPxm0ws4tfoPOc4LjU= | |||
| git.sr.ht/~sbinet/cmpimg v0.1.0 h1:E0zPRk2muWuCqSKSVZIWsgtU9pjsw3eKHi8VmQeScxo= | |||
| git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dkp/pxE= | |||
| git.sr.ht/~sbinet/gg v0.6.0 h1:RIzgkizAk+9r7uPzf/VfbJHBMKUr0F5hRFxTUGMnt38= | |||
| git.sr.ht/~sbinet/gg v0.6.0/go.mod h1:uucygbfC9wVPQIfrmwM2et0imr8L7KQWywX0xpFMm94= | |||
| git.sr.ht/~sbinet/gg v0.7.0 h1:YmNf7YKd7diDMTPm86hZa1EM3pbkOyD/zzjl0LZUdNM= | |||
| github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 h1:1qlsVAQJXZHsaM8b6OLVo6muQUQd4CwkH/D3fnnbHXA= | |||
| github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ= | |||
| github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 h1:lTG4HQym5oPKjL7nGs+csTgiDna685ZXjxijkne828g= | |||
| @@ -70,14 +73,24 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO | |||
| github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | |||
| github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | |||
| github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | |||
| github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= | |||
| github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= | |||
| github.com/tdewolff/canvas v0.0.0-20250508181010-75987a1ae9cc h1:hZ/uFsNQuNRaJWk/IVvIogyBfmfhRg2CLOhKpfeNGK0= | |||
| github.com/tdewolff/canvas v0.0.0-20250508181010-75987a1ae9cc/go.mod h1:xXkALI8c2qLMmoMWPRhDHkc1AtNSW/OGPPxp7lBfycU= | |||
| github.com/tdewolff/canvas v0.0.0-20250923071733-b2b2ba99a987 h1:tzQqRIECH8fEHpkG16gD7uOadYfgSgAuzxq6GaHk8v0= | |||
| github.com/tdewolff/canvas v0.0.0-20250923071733-b2b2ba99a987/go.mod h1:r5O5UHm7WMj6o9mbY1gdBHkg308r0EcfS/10YBbBLHI= | |||
| github.com/tdewolff/font v0.0.0-20250602165824-bf05faa75fda h1:WB5DpyaMFc/Y+n/neEg8o1lRUQgaj53FVK2H7mTT5zs= | |||
| github.com/tdewolff/font v0.0.0-20250602165824-bf05faa75fda/go.mod h1:eDnkgh2pt95UFXk0GsUv2JNj5gumg78c02QX0TdcwTA= | |||
| github.com/tdewolff/font v0.0.0-20250902141222-fb72ecc1bc0a h1:IuR6wFg9mSxhxcCogXcG5bte813psi1PE4KTjMAkM6k= | |||
| github.com/tdewolff/font v0.0.0-20250902141222-fb72ecc1bc0a/go.mod h1:lGIMHKyJnHCmJeb9MqdWnudFoPDVz8COuALmILs95xY= | |||
| github.com/tdewolff/minify/v2 v2.23.8 h1:tvjHzRer46kwOfpdCBCWsDblCw3QtnLJRd61pTVkyZ8= | |||
| github.com/tdewolff/minify/v2 v2.23.8/go.mod h1:VW3ISUd3gDOZuQ/jwZr4sCzsuX+Qvsx87FDMjk6Rvno= | |||
| github.com/tdewolff/minify/v2 v2.24.3 h1:BaKgWSFLKbKDiUskbeRgbe2n5d1Ci1x3cN/eXna8zOA= | |||
| github.com/tdewolff/minify/v2 v2.24.3/go.mod h1:1JrCtoZXaDbqioQZfk3Jdmr0GPJKiU7c1Apmb+7tCeE= | |||
| github.com/tdewolff/parse/v2 v2.8.1 h1:J5GSHru6o3jF1uLlEKVXkDxxcVx6yzOlIVIotK4w2po= | |||
| github.com/tdewolff/parse/v2 v2.8.1/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo= | |||
| github.com/tdewolff/parse/v2 v2.8.4-0.20250902141113-be7b6b11bb1b h1:ltRewarE+mA/m3nJrYJVfFFUUFP+RXOx8V1g5tVsU64= | |||
| github.com/tdewolff/parse/v2 v2.8.4-0.20250902141113-be7b6b11bb1b/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo= | |||
| github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE= | |||
| github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= | |||
| github.com/wcharczuk/go-chart/v2 v2.1.2 h1:Y17/oYNuXwZg6TFag06qe8sBajwwsuvPiJJXcUcLL6E= | |||
| @@ -98,6 +111,8 @@ golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+o | |||
| golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= | |||
| golang.org/x/image v0.29.0 h1:HcdsyR4Gsuys/Axh0rDEmlBmB68rW1U9BUdB3UVHsas= | |||
| golang.org/x/image v0.29.0/go.mod h1:RVJROnf3SLK8d26OW91j4FrIHGbsJ8QnbEocVTOWQDA= | |||
| golang.org/x/image v0.31.0 h1:mLChjE2MV6g1S7oqbXC0/UcKijjm5fnJLUYKIYrLESA= | |||
| golang.org/x/image v0.31.0/go.mod h1:R9ec5Lcp96v9FTF+ajwaH3uGxPH4fKfHHAVbUILxghA= | |||
| golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | |||
| golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= | |||
| golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= | |||
| @@ -114,6 +129,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= | |||
| golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= | |||
| golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= | |||
| golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= | |||
| golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= | |||
| golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= | |||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
| golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
| golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
| @@ -151,6 +168,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | |||
| golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= | |||
| golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= | |||
| golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= | |||
| golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= | |||
| golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= | |||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | |||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | |||
| golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | |||
| @@ -3,6 +3,7 @@ package panel | |||
| import ( | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/dimensions" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/path" | |||
| "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" | |||
| @@ -13,6 +14,7 @@ type Panel struct { | |||
| Lines map[util.ID]path.Path | |||
| Points map[util.ID]point.Point | |||
| Dimensions dimensions.Dimensions | |||
| Texts []text.Text | |||
| } | |||
| func (p Panel) Draw(c *canvas.Canvas, face *canvas.FontFace, debug bool) error { | |||
| @@ -31,5 +33,9 @@ func (p Panel) Draw(c *canvas.Canvas, face *canvas.FontFace, debug bool) error { | |||
| point.Draw(c, drawPoints, face, debug) | |||
| } | |||
| for _, t := range p.Texts { | |||
| t.ToCanvas(c, face) | |||
| } | |||
| return nil | |||
| } | |||
| @@ -1,21 +1,22 @@ | |||
| package text | |||
| import ( | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/point" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/position" | |||
| "github.com/tdewolff/canvas" | |||
| ) | |||
| type Text struct { | |||
| point.Point | |||
| anchor string | |||
| text string | |||
| Position position.Position | |||
| Anchor string | |||
| Text string | |||
| } | |||
| func NewText(point point.Point, anchor string, text string) *Text { | |||
| return &Text{Point: point, anchor: anchor, text: text} | |||
| func NewText(position position.Position, anchor string, text string) Text { | |||
| return Text{Position: position, Anchor: anchor, Text: text} | |||
| } | |||
| func (t Text) ToCanvas(c *canvas.Canvas, face *canvas.FontFace) { | |||
| text := canvas.NewTextLine(face, t.text, canvas.Left) | |||
| c.RenderText(text, t.Matrix()) | |||
| text := canvas.NewTextLine(face, t.Text, canvas.Left) | |||
| matrix := canvas.Identity.Translate(t.Position.Vector.X, t.Position.Vector.Y).Rotate(t.Position.RotationD()) | |||
| c.RenderText(text, matrix) | |||
| } | |||
| @@ -2,10 +2,6 @@ package renderer | |||
| import ( | |||
| "fmt" | |||
| "path/filepath" | |||
| "strings" | |||
| "unicode" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/config" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/dimensions" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/template" | |||
| @@ -13,6 +9,8 @@ import ( | |||
| "github.com/tdewolff/canvas" | |||
| "github.com/tdewolff/canvas/renderers" | |||
| "golang.org/x/image/font/gofont/goregular" | |||
| "path/filepath" | |||
| "strings" | |||
| ) | |||
| type Storage interface { | |||
| @@ -37,7 +35,7 @@ func RenderPatterns(s Storage, request config.Request, outputDir string, debug b | |||
| // renderer := Renderer{dimensions: dim, owner: request.Owner, pattern: request.Template} | |||
| for name := range loadedTemplate.Panels { | |||
| newPanel, err := loadedTemplate.GetPanel(template.Request{Dims: dim, Panel: name}) | |||
| newPanel, err := loadedTemplate.GetPanel(template.Request{Dims: dim, Panel: name, Owner: request.Owner}) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -143,22 +141,3 @@ type Renderer struct { | |||
| // | |||
| // return nil | |||
| //} | |||
| func startCase(text string) string { | |||
| output := make([]rune, len(text)) | |||
| for i, val := range text { | |||
| switch { | |||
| case i == 0: | |||
| output[i] = unicode.ToUpper(val) | |||
| case val == '_': | |||
| output[i] = ' ' | |||
| case output[i-1] == ' ': | |||
| output[i] = unicode.ToUpper(val) | |||
| default: | |||
| output[i] = val | |||
| } | |||
| } | |||
| return string(output) | |||
| } | |||
| @@ -1,6 +1,45 @@ | |||
| package template | |||
| import ( | |||
| "fmt" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/pattern/text" | |||
| "slices" | |||
| "strings" | |||
| ) | |||
| type Information struct { | |||
| Point `yaml:",inline"` | |||
| Anchor string `yaml:"anchor"` | |||
| } | |||
| func (t Template) createInformation(req request) (text.Text, error) { | |||
| templatePanel, ok := t.Panels[req.panel] | |||
| if !ok { | |||
| return text.Text{}, ErrPanelNotFound | |||
| } | |||
| dims := make([]string, 0, len(req.dimensions)) | |||
| for _, dimension := range req.dimensions { | |||
| dims = append(dims, fmt.Sprintf(" %s: %.1f cm", dimension.Name, dimension.Value/10)) | |||
| } | |||
| slices.Sort(dims) | |||
| dims = append([]string{ | |||
| "For: " + req.owner, | |||
| "Pattern: " + startCase(t.Name), | |||
| "Panel: " + startCase(req.panel), | |||
| "Hem allowance: " + templatePanel.Allowances.Hem, | |||
| "Seam allowance: " + templatePanel.Allowances.Seam, | |||
| "\nMeasurements:", | |||
| }, dims...) | |||
| templatePanel.Points["_information"] = templatePanel.Information.Point | |||
| point, err := t.getOrCreatePoint("_information", req, 0) | |||
| if err != nil { | |||
| return text.Text{}, err | |||
| } | |||
| info := text.NewText(point.Position(), templatePanel.Information.Anchor, strings.Join(dims, "\n")) | |||
| return info, nil | |||
| } | |||
| @@ -69,7 +69,7 @@ func (t Template) getOrCreateLine(id util.ID, req request, depth int) (path.Path | |||
| } | |||
| func (t Template) createLine(id util.ID, req request, depth int) (path.Path, error) { | |||
| line, err := t.templateLine(req.name, id) | |||
| line, err := t.templateLine(req.panel, id) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -129,6 +129,24 @@ func (t Template) functions(req request) map[string]govaluate.ExpressionFunction | |||
| return line[0].Length() | |||
| }, | |||
| "DiagonalTo": func(args ...interface{}) (interface{}, error) { | |||
| if len(args) != 3 { | |||
| return nil, fmt.Errorf("function DiagonalTo() requires 3 arguments: %w", ErrInvalidArguments) | |||
| } | |||
| points, err := t.getOrCreatePointsFromArgs(req, args[0:2]...) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| f, ok := args[2].(float64) | |||
| if !ok { | |||
| return nil, fmt.Errorf("function DiagonalTo() requires the third argument to be a float: %w", | |||
| ErrInvalidArguments) | |||
| } | |||
| return math.Sqrt(math.Pow(f, 2) - math.Pow(points[0].Position().Distance(points[1].Position()), 2)), nil | |||
| }, | |||
| }) | |||
| return functions | |||
| @@ -253,7 +271,7 @@ func (t Template) evaluationFunctions() map[string]govaluate.ExpressionFunction | |||
| } | |||
| func (t Template) createPoint(id util.ID, req request, depth int) (p point.Point, err error) { | |||
| templatePoint, err := t.templatePoint(req.name, id) | |||
| templatePoint, err := t.templatePoint(req.panel, id) | |||
| if err != nil { | |||
| return nil, fmt.Errorf("creating point: %w", err) | |||
| } | |||
| @@ -298,7 +316,7 @@ func (t Template) createPoint(id util.ID, req request, depth int) (p point.Point | |||
| } | |||
| func (t Template) createRelative(id util.ID, req request, depth int) (*point.RelativePoint, error) { | |||
| templatePoint, err := t.templatePoint(req.name, id) | |||
| templatePoint, err := t.templatePoint(req.panel, id) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -325,7 +343,7 @@ func (t Template) createRelative(id util.ID, req request, depth int) (*point.Rel | |||
| //nolint:ireturn,dupl | |||
| func (t Template) createBetween(id util.ID, req request, depth int) (point.Point, error) { | |||
| newPoint, err := t.templatePoint(req.name, id) | |||
| newPoint, err := t.templatePoint(req.panel, id) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -388,7 +406,7 @@ func (t Template) getOrCreatePoint(id util.ID, req request, depth int) (point.Po | |||
| //nolint:ireturn,dupl | |||
| func (t Template) createExtend(id util.ID, req request, depth int) (point.Point, error) { | |||
| newPoint, err := t.templatePoint(req.name, id) | |||
| newPoint, err := t.templatePoint(req.panel, id) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -417,7 +435,7 @@ func (t Template) createExtend(id util.ID, req request, depth int) (point.Point, | |||
| //nolint:ireturn | |||
| func (t Template) createPolar(id util.ID, req request, depth int) (point.Point, error) { | |||
| templatePoint, err := t.templatePoint(req.name, id) | |||
| templatePoint, err := t.templatePoint(req.panel, id) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -6,6 +6,7 @@ import ( | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/pattern/panel" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/point" | |||
| "git.wtrh.nl/patterns/gopatterns/pkg/util" | |||
| "unicode" | |||
| ) | |||
| type Template struct { | |||
| @@ -17,13 +18,15 @@ type Template struct { | |||
| } | |||
| type Request struct { | |||
| Owner string | |||
| Dims dimensions.Dimensions | |||
| Panel string | |||
| } | |||
| type request struct { | |||
| dimensions dimensions.Dimensions | |||
| name string | |||
| panel string | |||
| owner string | |||
| lines map[util.ID]path.Path | |||
| points map[util.ID]point.Point | |||
| } | |||
| @@ -36,9 +39,10 @@ func (t Template) GetPanel(req Request) (panel.Panel, error) { | |||
| r := request{ | |||
| dimensions: req.Dims, | |||
| name: req.Panel, | |||
| panel: req.Panel, | |||
| lines: make(map[util.ID]path.Path), | |||
| points: make(map[util.ID]point.Point), | |||
| owner: req.Owner, | |||
| } | |||
| result := panel.Panel{ | |||
| @@ -75,5 +79,31 @@ func (t Template) GetPanel(req Request) (panel.Panel, error) { | |||
| result.Points[id] = newPoint | |||
| } | |||
| text, err := t.createInformation(r) | |||
| if err != nil { | |||
| return panel.Panel{}, err | |||
| } | |||
| result.Texts = append(result.Texts, text) | |||
| return result, nil | |||
| } | |||
| func startCase(text string) string { | |||
| output := make([]rune, len(text)) | |||
| for i, val := range text { | |||
| switch { | |||
| case i == 0: | |||
| output[i] = unicode.ToUpper(val) | |||
| case val == '_': | |||
| output[i] = ' ' | |||
| case output[i-1] == ' ': | |||
| output[i] = unicode.ToUpper(val) | |||
| default: | |||
| output[i] = val | |||
| } | |||
| } | |||
| return string(output) | |||
| } | |||
| @@ -144,14 +144,11 @@ panels: | |||
| y: -10 | |||
| relativeTo: 1 | |||
| points: | |||
| 5r: | |||
| position: | |||
| rotation: pi/4 | |||
| relativeTo: 5 | |||
| 5d: | |||
| position: | |||
| y: 35 | |||
| relativeTo: 5r | |||
| polar: | |||
| length: (waist-640)*0.015625+27.5 | |||
| rotation: 3*pi/4 | |||
| relativeTo: 5 | |||
| hide: true | |||
| 6e: | |||
| between: | |||
| @@ -192,28 +189,38 @@ panels: | |||
| through: [0,2,1,4,3] | |||
| 5: | |||
| through: [6,10,0l,0b,0r,11] | |||
| style: | |||
| thickness: 1 | |||
| 6: | |||
| through: [9,5d,6] | |||
| curve: | |||
| start: 5 | |||
| end: 6e | |||
| style: | |||
| thickness: 1 | |||
| 7: | |||
| through: [15,14,12,13] | |||
| style: | |||
| thickness: 1 | |||
| 8: | |||
| through: [15,9] | |||
| curve: | |||
| start: 15e | |||
| style: | |||
| thickness: 1 | |||
| 9: | |||
| through: [13,8,11] | |||
| curve: | |||
| start: 13e | |||
| style: | |||
| thickness: 1 | |||
| back: | |||
| name: Back | |||
| information: | |||
| position: | |||
| x: 10 | |||
| y: -10 | |||
| relativeTo: 1 | |||
| relativeTo: 2 | |||
| allowances: | |||
| hem: none | |||
| seam: none | |||
| @@ -287,26 +294,40 @@ panels: | |||
| lines: | |||
| 1: | |||
| through: [19,21,30l,30b,30r,31l,31b,31r,22] | |||
| style: | |||
| thickness: 1 | |||
| 2: | |||
| through: [24,16d,19] | |||
| curve: | |||
| start: 23a | |||
| end: 19e | |||
| style: | |||
| thickness: 1 | |||
| 3: | |||
| through: [29,24] | |||
| curve: | |||
| start: 29extend | |||
| style: | |||
| thickness: 1 | |||
| 4: | |||
| through: [27,25,22] | |||
| curve: | |||
| start: 27extend | |||
| style: | |||
| thickness: 1 | |||
| 5: | |||
| through: [29,28] | |||
| style: | |||
| thickness: 1 | |||
| 6: | |||
| through: [27,26] | |||
| style: | |||
| thickness: 1 | |||
| 7: | |||
| through: [28,3down,26] | |||
| curve: {} | |||
| style: | |||
| thickness: 1 | |||
| 8: | |||
| through: [23,1] | |||
| 9: | |||
| @@ -183,21 +183,32 @@ panels: | |||
| 3: | |||
| through: [9, 1extend] | |||
| 4: | |||
| through: [14,12,13,15,14] | |||
| through: [14,12,13,15] | |||
| style: | |||
| thickness: 1 | |||
| 5: | |||
| through: [14,8,11] | |||
| curve: | |||
| start: extend12-14 | |||
| end: offset_between11-8 | |||
| style: | |||
| thickness: 1 | |||
| 6: | |||
| through: [15,9] | |||
| curve: | |||
| start: extend13-15 | |||
| style: | |||
| thickness: 1 | |||
| 7: | |||
| through: [9, h5, 6] | |||
| curve: {} | |||
| style: | |||
| thickness: 1 | |||
| 8: | |||
| through: [6, 10, 11] | |||
| style: | |||
| thickness: 1 | |||
| 9: | |||
| through: [15,14] | |||
| back: | |||
| name: Back | |||
| @@ -273,24 +284,42 @@ panels: | |||
| 3: | |||
| through: [22, 16, 16extend] | |||
| 4: | |||
| through: [28, 30, 29, 27] | |||
| through: [28, 30] | |||
| style: | |||
| thickness: 1 | |||
| 4a: | |||
| through: [30, 29] | |||
| 4b: | |||
| through: [29, 27] | |||
| style: | |||
| thickness: 1 | |||
| 5: | |||
| through: [21,25a,25c,25b,24] | |||
| style: | |||
| thickness: 1 | |||
| 6: | |||
| through: [28,2down,27] | |||
| curve: {} | |||
| style: | |||
| thickness: 1 | |||
| 7: | |||
| through: [23,16offset,19,21] | |||
| curve: | |||
| start: 23a | |||
| style: | |||
| thickness: 1 | |||
| 8: | |||
| through: [30,23] | |||
| curve: | |||
| start: 30extend | |||
| style: | |||
| thickness: 1 | |||
| 9: | |||
| through: [29,26,24] | |||
| curve: | |||
| start: 29extend | |||
| style: | |||
| thickness: 1 | |||
| @@ -103,6 +103,14 @@ panels: | |||
| through: [22,29,29b,36] | |||
| style: | |||
| thickness: 1 | |||
| 00: | |||
| relativeTo: 17 | |||
| 01: | |||
| relativeTo: 25 | |||
| 02: | |||
| relativeTo: 01 | |||
| position: | |||
| y: (LineLength("11")-70)/3 | |||
| points: | |||
| 0: | |||
| @@ -151,10 +159,13 @@ panels: | |||
| relativeTo: 0 | |||
| position: | |||
| x: half_back + 40 | |||
| 14: | |||
| 13: | |||
| relativeTo: 12 | |||
| position: | |||
| x: 15 | |||
| 14: | |||
| relativeTo: 13 | |||
| position: | |||
| y: 20 | |||
| 15: | |||
| relativeTo: 10 | |||
| @@ -332,7 +343,34 @@ panels: | |||
| position: | |||
| y: 7 | |||
| x: -30 | |||
| 00: | |||
| relativeTo: 17 | |||
| 01: | |||
| relativeTo: 25 | |||
| 02: | |||
| relativeTo: 01 | |||
| position: | |||
| y: (LineLength("11")-70)/3 | |||
| 03: | |||
| between: | |||
| from: 01 | |||
| to: 02 | |||
| offset: 0.5 | |||
| 06: | |||
| relativeTo: 02 | |||
| position: | |||
| x: ((DistanceBetween("24","26")^2 - (DistanceBetween("02","26")^2))^0.5) | |||
| sleeve: | |||
| information: | |||
| relativeTo: A | |||
| position: | |||
| x: 10 | |||
| y: -10 | |||
| allowances: | |||
| hem: none | |||
| seam: 1cm | |||
| points: | |||
| 0: {} | |||
| 1: | |||
| @@ -342,7 +380,7 @@ panels: | |||
| 2: | |||
| relativeTo: 0 | |||
| position: | |||
| y: -(sleeve_length_shirt+60-cuff_depth) | |||
| y: -(sleeve_length_shirt+60-cuff_depth - DistanceBetween("body.0","body.13")) | |||
| 3: | |||
| between: | |||
| from: 2 | |||
| @@ -351,7 +389,7 @@ panels: | |||
| 4: | |||
| relativeTo: 1 | |||
| position: | |||
| x: -(502.6/2 -5) | |||
| x: -DiagonalTo("0","1",502.6/2 -5) | |||
| 5: | |||
| relativeTo: 4 | |||
| position: | |||
| @@ -359,7 +397,7 @@ panels: | |||
| 6: | |||
| relativeTo: 1 | |||
| position: | |||
| x: (502.6/2 -5) | |||
| x: DiagonalTo("0","1",502.6/2 -5) | |||
| 7: | |||
| relativeTo: 6 | |||
| position: | |||
| @@ -466,6 +504,7 @@ panels: | |||
| relativeTo: 16 | |||
| position: | |||
| y: 150 | |||
| lines: | |||
| scye: | |||
| through: [4,8,9,10,0,11,12,13,6] | |||