Changes
6 changed files (+166/-41)
-
-
@@ -151,6 +151,7 @@ type alias Parameters ={ shoulderWidth : Length , longPiece : LongPiece , shortPiece : ShortPiece , paddingOffset : Length , profile : Profile , rendering : Rendering }
-
@@ -197,6 +198,7 @@ , free = Just defaultFreeLoop, style = Simple } } , paddingOffset = mm 5 , profile = Straight , rendering = { size = A4
-
@@ -218,6 +220,7 @@ toDict params =[ ( "version", "1.0" ) , ( Key.toString TipStyle, tipStyleToString params.longPiece.tip ) , ( Key.toString ShoulderWidth, String.fromFloat (toMM params.shoulderWidth) ) , ( Key.toString PaddingOffset, String.fromFloat (toMM params.paddingOffset) ) , ( Key.toString LongPieceLength, String.fromFloat (toMM params.longPiece.length) ) , ( Key.toString LoopStyle, loopStyleToString params.shortPiece.loops.style ) , ( Key.toString ShortPieceLength, String.fromFloat (toMM params.shortPiece.length) )
-
-
-
@@ -543,6 +543,17 @@ , unit = Just "mm", disabled = False , attrs = step "1.0" :: lengthFieldAttrs constraints.shoulderWidth } , numberField model { key = PaddingOffset , title = [ text "Padding Offset" ] , description = [ text "Offset of the padding pattern, from main pieces. " , text "Set to 0mm to disable paddings output." ] , unit = Just "mm" , disabled = False , attrs = step "1.0" :: lengthFieldAttrs constraints.paddingOffset } , choiceField model { key = Profile , title = [ text "Profile" ]
-
-
-
@@ -69,6 +69,7 @@ type alias Parameters ={ shoulderWidth : NumberConstraints Length , longPiece : LongPiece , shortPiece : ShortPiece , paddingOffset : NumberConstraints Length , taperTo : NumberConstraints Length , rendering : Rendering }
-
@@ -101,6 +102,7 @@ }} , length = { min = Just (mm 5), max = Just (mm 150) } } , paddingOffset = { min = Just (mm 0), max = Just (mm 14) } , taperTo = { min = Just (mm 5), max = Just (mm 28) } , rendering = { margin = { min = Just (mm 0), max = Just (mm 20) }
-
-
-
@@ -12,6 +12,7 @@type Key = ShoulderWidth | PaddingOffset | TipStyle | TipSharpness | Profile
-
@@ -57,6 +58,9 @@ "taper-to"ShoulderWidth -> "shoulder-width" PaddingOffset -> "padding-offset" BuckleHoleDistance -> "buckle-hole-distance"
-
-
-
@@ -172,6 +172,16 @@ |> Maybe.withDefault ""|> f parseOptionalField : Key -> (String -> Result Error a) -> ParametersDict -> Result Error (Maybe a) parseOptionalField key f fields = case getKey key fields of Just value -> f value |> Result.map Just Nothing -> Ok Nothing parseFixedLoop : ParametersDict -> Result Errors (Maybe Parameters.FixedLoop) parseFixedLoop fields = if hasKey HasFixedLoop fields then
-
@@ -398,7 +408,10 @@ parse fields =case getKey Version fields of Just "1.0" -> case ( parseField ShoulderWidth (parseLength constraints.shoulderWidth) fields ( ( parseField ShoulderWidth (parseLength constraints.shoulderWidth) fields , parseOptionalField PaddingOffset (parseLength constraints.paddingOffset) fields |> Result.map (Maybe.withDefault (mm 0)) ) , ( parseLongPiece fields , parseShortPiece fields , parseProfile fields
-
@@ -406,18 +419,20 @@ ), parseRendering fields ) of ( Ok shoulderWidth, ( Ok longPiece, Ok shortPiece, Ok profile ), Ok rendering ) -> ( ( Ok shoulderWidth, Ok paddingOffset ), ( Ok longPiece, Ok shortPiece, Ok profile ), Ok rendering ) -> Ok { shoulderWidth = shoulderWidth , longPiece = longPiece , shortPiece = shortPiece , paddingOffset = paddingOffset , rendering = rendering , profile = profile } ( shoulderWidth, ( longPiece, shortPiece, profile ), rendering ) -> ( ( shoulderWidth, paddingOffset ), ( longPiece, shortPiece, profile ), rendering ) -> [ mkErrors [ ( ShoulderWidth, getError shoulderWidth ) , ( PaddingOffset, getError paddingOffset ) ] , getError longPiece |> Maybe.withDefault Dict.empty , getError shortPiece |> Maybe.withDefault Dict.empty
-
-
-
@@ -39,9 +39,11 @@ |> padded (toMM params.rendering.gap / 2)|> gapped (toMM params.rendering.gap) |> Container.build ([ columns |> gapped (toMM params.rendering.gap) |> gapped (toMM params.rendering.gap * 2) |> Container.build [ surfacePieces params highlighting |> noGrow ] [ surfacePieces params highlighting |> noGrow , paddings params highlighting |> noGrow ] |> Just , loops params highlighting ]
-
@@ -86,35 +88,44 @@ , strokeDasharray "0.5 1"] longPieceShape : ( Float, Float ) -> Parameters -> Maybe Key -> List Path.PathCommand -> Svg msg longPieceShape ( x, y ) params highlighting commands = type alias LongPieceShapeProps = { x : Float , y : Float , offset : Float , highlighting : Maybe Key , parameters : Parameters } longPieceShape : LongPieceShapeProps -> Svg msg longPieceShape { x, y, offset, highlighting, parameters } = let shoulderWidth = toMM params.shoulderWidth toMM parameters.shoulderWidth - offset * 2 length = toMM params.longPiece.length toMM parameters.longPiece.length - offset taperUntil = Basics.min (toMM params.longPiece.buckleHole.distance - (toMM params.longPiece.buckleHole.interval * toFloat (params.longPiece.buckleHole.adjustments + 1)) (toMM parameters.longPiece.buckleHole.distance - (toMM parameters.longPiece.buckleHole.interval * toFloat (parameters.longPiece.buckleHole.adjustments + 1)) ) (length / 2) taper = case params.profile of case parameters.profile of Straight -> 0.0 Tapered to -> shoulderWidth - toMM to shoulderWidth - (toMM to - offset * 2) buckleWidth = shoulderWidth - taper curvedSectionLength = case params.longPiece.tip of case parameters.longPiece.tip of Round -> buckleWidth / 2
-
@@ -128,7 +139,7 @@ [ Path.d(MoveTo Absolute ( x, y ) :: LineTo Relative ( taper / 2, taperUntil ) :: VerticalLineTo Relative (length - curvedSectionLength - taperUntil) :: (case params.longPiece.tip of :: (case parameters.longPiece.tip of Round -> [ EllipticalArcCurve Relative { rx = buckleWidth / 2
-
@@ -163,13 +174,14 @@ )[] ] ) ++ VerticalLineTo Relative -(length - curvedSectionLength - taperUntil) :: LineTo Relative ( taper / 2, -taperUntil ) :: commands ++ [ VerticalLineTo Relative -(length - curvedSectionLength - taperUntil) , LineTo Relative ( taper / 2, -taperUntil ) , ClosePath ] ) , fill "none" , stroke "currentColor" , strokeWidth (toMM params.rendering.lineWidth |> String.fromFloat) , strokeWidth (toMM parameters.rendering.lineWidth |> String.fromFloat) , highlightStroke (highlighting == Just LongPieceLength
-
@@ -179,7 +191,7 @@ || highlighting== Just Profile || highlighting == Just TaperTo || (case params.profile of || (case parameters.profile of Straight -> False
-
@@ -201,7 +213,7 @@ :: highlightStroke (highlighting == Just LongPieceLength):: guideStroke ) [] , case params.longPiece.tip of , case parameters.longPiece.tip of Round -> g [] []
-
@@ -214,7 +226,7 @@ ]:: guideStroke ) [] , case params.profile of , case parameters.profile of Straight -> g [] []
-
@@ -259,10 +271,12 @@ \p _ ->g [] (longPieceShape ( p.x, p.y ) params highlighting [ ClosePath ] { x = p.x , y = p.y , offset = 0 , highlighting = highlighting , parameters = params } :: (List.range 0 (params.longPiece.buckleHole.adjustments * 2) |> List.map (\index ->
-
@@ -340,32 +354,33 @@ ]] shortPieceShape : Parameters -> Maybe Key -> ( Float, Float ) -> Svg msg shortPieceShape params highlighting at = type alias ShortPieceShapeProps = LongPieceShapeProps shortPieceShape : ShortPieceShapeProps -> Svg msg shortPieceShape { x, y, offset, parameters, highlighting } = let shoulderWidth = toMM params.shoulderWidth toMM parameters.shoulderWidth - offset * 2 length = toMM params.shortPiece.length toMM parameters.shortPiece.length - offset taperUntil = Basics.min (toMM params.longPiece.buckleHole.distance - (toMM params.longPiece.buckleHole.interval * toFloat (params.longPiece.buckleHole.adjustments + 1)) (toMM parameters.longPiece.buckleHole.distance - (toMM parameters.longPiece.buckleHole.interval * toFloat (parameters.longPiece.buckleHole.adjustments + 1)) ) (length - 10) taper = case params.profile of case parameters.profile of Straight -> 0.0 Tapered to -> shoulderWidth - toMM to ( x, y ) = at shoulderWidth - (toMM to - offset * 2) in g []
-
@@ -383,7 +398,7 @@ |> List.filterMap identity) , fill "none" , stroke "currentColor" , strokeWidth (toMM params.rendering.lineWidth |> String.fromFloat) , strokeWidth (toMM parameters.rendering.lineWidth |> String.fromFloat) , highlightStroke (highlighting == Just ShortPieceLength
-
@@ -393,7 +408,7 @@ || highlighting== Just Profile || highlighting == Just TaperTo || (case params.profile of || (case parameters.profile of Straight -> False
-
@@ -415,7 +430,7 @@ :: highlightStroke (highlighting == Just ShortPieceLength):: guideStroke ) [] , case params.profile of , case parameters.profile of Straight -> g [] []
-
@@ -444,7 +459,13 @@ { size ={ width = Exactly shoulderWidth, height = Exactly length } , element = \p _ -> g [] [ shortPieceShape params highlighting ( p.x, p.y ) ] shortPieceShape { x = p.x , y = p.y , offset = 0 , parameters = params , highlighting = highlighting } }
-
@@ -648,3 +669,72 @@ ]} ) params.shortPiece.loops.free paddings : Parameters -> Maybe Key -> Item msg paddings params highlighting = let offset = toMM params.paddingOffset narrowestWidth = case params.profile of Straight -> toMM params.shoulderWidth Tapered to -> toMM to in if offset == 0 || (offset * 2) >= narrowestWidth then Item { width = Exactly 0, height = Exactly 0 } (\_ _ -> g [] []) else rows |> aligned Container.Center |> gapped (toMM params.rendering.gap / 2) |> Container.build [ Item { width = Exactly 21, height = Exactly 5 } (\p size -> text_ [ x (String.fromFloat (p.x + size.width / 2)) , y (String.fromFloat p.y) , fontSize (String.fromFloat size.height) , fontWeight "100" , textAnchor "middle" , dominantBaseline "hanging" , fill "currentColor" ] [ text "Paddings" ] ) , columns |> gapped (toMM params.rendering.gap) |> Container.build [ Item { width = Exactly (toMM params.shoulderWidth - offset * 2) , height = Exactly (toMM params.longPiece.length - offset) } (\p _ -> longPieceShape { x = p.x , y = p.y , offset = offset , parameters = params , highlighting = highlighting } ) , Item { width = Exactly (toMM params.shoulderWidth - offset * 2) , height = Exactly (toMM params.shortPiece.length - offset) } (\p _ -> shortPieceShape { x = p.x , y = p.y , offset = offset , parameters = params , highlighting = highlighting } ) ] ]
-