Changes
5 changed files (+169/-9)
-
-
@@ -90,6 +90,7 @@type alias Rendering = { size : CanvasSize , margin : Length , gap : Length , lineWidth : Length , colorSchema : ColorSchema }
-
@@ -101,7 +102,7 @@ , longPiece : LongPiece, shortPiece : ShortPiece , profile : Profile , thickness : Length , lining : Maybe Length , lining : Length , rendering : Rendering }
-
@@ -138,10 +139,11 @@ , claspSideFlap = mm 20} , profile = Straight , thickness = mm 2.5 , lining = Just (mm 0.5) , lining = mm 0.5 , rendering = { size = A4 , margin = mm 10 , gap = mm 10 , lineWidth = mm 0.3 , colorSchema = BlackOnWhite }
-
-
-
@@ -46,6 +46,7 @@ letfields = Dict.fromList [ ( Key.toString LugWidth, String.fromFloat (toMM params.lugWidth) ) , ( Key.toString LiningThickness, String.fromFloat (toMM params.lining) ) , ( Key.toString BuckleHoleCount, String.fromInt params.longPiece.buckleHole.count ) , ( Key.toString BuckleHoleDiameter, String.fromFloat (toMM params.longPiece.buckleHole.diameter) ) , ( Key.toString CanvasMargin, String.fromFloat (toMM params.rendering.margin) )
-
@@ -160,20 +161,23 @@parse : Fields -> Result Errors Parameters parse fields = case ( parseField LugWidth (parseLength constraints.lugWidth) fields ( ( parseField LugWidth (parseLength constraints.lugWidth) fields , parseField LiningThickness (parseLength constraints.lining) fields ) , parseLongPiece fields , parseCanvas fields ) of ( Ok lugWidth, Ok longPiece, Ok rendering ) -> ( ( Ok lugWidth, Ok lining ), Ok longPiece, Ok rendering ) -> let base = Parameters.default in Ok { base | lugWidth = lugWidth, longPiece = longPiece, rendering = rendering } Ok { base | lugWidth = lugWidth, lining = lining, longPiece = longPiece, rendering = rendering } ( lugWidth, longPiece, rendering ) -> ( ( lugWidth, lining ), longPiece, rendering ) -> [ mkErrors [ ( LugWidth, getError lugWidth ) ] , mkErrors [ ( LiningThickness, getError lining ) ] , getError longPiece |> Maybe.withDefault Dict.empty , getError rendering |> Maybe.withDefault Dict.empty ]
-
@@ -430,6 +434,15 @@ , text "You can use a size smaller than your lug width to create a play."] , unit = Just "mm" , attrs = step "1.0" :: lengthFieldAttrs constraints.lugWidth } , numberField model { key = LiningThickness , title = [ text "Lining Thickness" ] , description = [ text "Thickness of lining leather. Set to 0 to disable lining generation." ] , unit = Just "mm" , attrs = step "0.1" :: lengthFieldAttrs constraints.lining } ] , hr [] []
-
-
-
@@ -39,6 +39,7 @@type alias Parameters = { lugWidth : NumberConstraints Length , longPiece : LongPiece , lining : NumberConstraints Length , rendering : Rendering }
-
@@ -52,6 +53,7 @@ { count = { min = Just 0, max = Just 10 }, diameter = { min = Just (mm 1), max = Just (mm 10) } } } , lining = { min = Just (mm 0), max = Just (mm 5) } , rendering = { margin = { min = Just (mm 0), max = Just (mm 20) } , lineWidth = { min = Just (mm 0.1), max = Just (mm 1) }
-
-
-
@@ -12,6 +12,7 @@type Key = LugWidth | LiningThickness | BuckleHoleCount | BuckleHoleDiameter | CanvasMargin
-
@@ -24,6 +25,9 @@ toString key =case key of LugWidth -> "lug-width" LiningThickness -> "lining-thickness" BuckleHoleCount -> "buckle-hole-count"
-
-
-
@@ -53,6 +53,12 @@ |> Tuple.mapBoth toMM toMMmargin = toMM params.rendering.margin lugWidth = toMM params.lugWidth gap = toMM params.rendering.gap in svg (viewBox (String.join " " [ "0", "0", String.fromInt (ceiling canvasWidth), String.fromInt (ceiling canvasHeight) ])
-
@@ -85,7 +91,8 @@ []] ] , longPiece params (TopLeft ( margin, margin )) , shortPiece params (TopLeft ( toMM params.lugWidth + margin + 10, margin )) , shortPiece params (TopLeft ( margin + lugWidth + gap, margin )) , linings params (TopRight ( canvasWidth - margin, margin )) ]
-
@@ -233,6 +240,11 @@ , strokeDasharray "1 0.5"] longPieceSize : Parameters -> Size longPieceSize params = Size (toMM params.lugWidth) (toMM params.longPiece.length + toMM params.longPiece.flap) longPiece : Parameters -> Anchor -> Svg msg longPiece params anchor = let
-
@@ -246,7 +258,7 @@ flap =toMM params.longPiece.flap ( ox, oy ) = topLeftFor anchor (Size lugWidth length) topLeftFor anchor (longPieceSize params) in g []
-
@@ -355,6 +367,11 @@ ]] shortPieceSize : Parameters -> Size shortPieceSize params = Size (toMM params.lugWidth) (toMM params.shortPiece.length + toMM params.shortPiece.caseSideFlap) shortPiece : Parameters -> Anchor -> Svg msg shortPiece params anchor = let
-
@@ -371,7 +388,7 @@ claspSideFlap =toMM params.shortPiece.claspSideFlap ( ox, oy ) = topLeftFor anchor (Size lugWidth length) topLeftFor anchor (shortPieceSize params) in g []
-
@@ -429,3 +446,125 @@ ][] ] ] linings : Parameters -> Anchor -> Svg msg linings params anchor = if toMM params.lining == 0 then g [] [] else let gap = toMM params.rendering.gap lugWidth = toMM params.lugWidth sectionWidth = lugWidth * 2 + gap headerHeight = 5.0 size = Size sectionWidth (headerHeight + gap / 2 + Basics.max (toMM params.longPiece.length) (toMM params.shortPiece.length)) ( ox, oy ) = topLeftFor anchor size in g [] [ longLining params (TopLeft ( ox, oy + headerHeight + gap / 2 )) , shortLining params (TopLeft ( ox + lugWidth + gap, oy + headerHeight + gap / 2 )) , text_ [ x (ox + sectionWidth / 2 |> String.fromFloat) , y (oy + 4 |> String.fromFloat) , fontSize "5" , fontWeight "100" , textAnchor "middle" , fill "currentColor" ] [ text ("Linings / t = " ++ (toMM params.lining |> String.fromFloat) ++ "mm") ] ] longLiningSize : Parameters -> Size longLiningSize params = Size (toMM params.lugWidth) (toMM params.longPiece.length) longLining : Parameters -> Anchor -> Svg msg longLining params anchor = let lugWidth = toMM params.lugWidth length = toMM params.longPiece.length ( ox, oy ) = topLeftFor anchor (longLiningSize params) in g [] [ Svg.path [ Svg.Path.d [ MoveTo Absolute ( ox, oy ) , VerticalLineTo Relative (length - lugWidth / 2) , EllipticalArcCurve Relative { rx = lugWidth / 2 , ry = lugWidth / 2 , angle = 0.0 , largeArcFlag = LargeArc , sweepFlag = Counterclockwise , x = lugWidth , y = 0 } [] , VerticalLineTo Relative -(length - lugWidth / 2) , ClosePath ] , fill "none" , stroke "currentColor" , strokeWidth (toMM params.rendering.lineWidth |> String.fromFloat) ] [] ] shortLiningSize : Parameters -> Size shortLiningSize params = Size (toMM params.lugWidth) (toMM params.shortPiece.length) shortLining : Parameters -> Anchor -> Svg msg shortLining params anchor = let lugWidth = toMM params.lugWidth length = toMM params.shortPiece.length ( ox, oy ) = topLeftFor anchor (shortLiningSize params) in g [] [ Svg.path [ Svg.Path.d [ MoveTo Absolute ( ox, oy ) , VerticalLineTo Relative length , HorizontalLineTo Relative lugWidth , VerticalLineTo Relative -length , ClosePath ] , fill "none" , stroke "currentColor" , strokeWidth (toMM params.rendering.lineWidth |> String.fromFloat) ] [] ]
-