From 78e0b16e7c7629aa7d30ba09b130b4289f07fc7d Mon Sep 17 00:00:00 2001 From: Wouter Horlings Date: Tue, 23 Sep 2025 12:53:53 +0200 Subject: [PATCH] Fix tailored shirt block --- pkg/template/point.go | 18 +++++++++++++ templates/tailored_shirt_block.yaml | 39 ++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/pkg/template/point.go b/pkg/template/point.go index eff169c..219eac3 100644 --- a/pkg/template/point.go +++ b/pkg/template/point.go @@ -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 diff --git a/templates/tailored_shirt_block.yaml b/templates/tailored_shirt_block.yaml index 6276c1e..fb57b81 100644 --- a/templates/tailored_shirt_block.yaml +++ b/templates/tailored_shirt_block.yaml @@ -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,6 +343,25 @@ 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: points: 0: {} @@ -342,7 +372,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 +381,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 +389,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 +496,7 @@ panels: relativeTo: 16 position: y: 150 + lines: scye: through: [4,8,9,10,0,11,12,13,6]