Changes
5 changed files (+228/-11)
-
-
@@ -83,6 +83,20 @@ , thickness : Length} type alias BuckleTongue = { thickness : Length , width : Length } {-| Clasp / Buckle. -} type alias Buckle = { springBarDiameter : Length , tongue : Maybe BuckleTongue } {-| Parameters for the short piece, which has clasp at the end. This does not have to be shorter than `LongPiece`. -}
-
@@ -91,6 +105,7 @@ { length : Length, loops : Loops , caseSideFlap : Length , claspSideFlap : Length , buckle : Buckle }
-
@@ -156,6 +171,13 @@ , overlap = mm 5} defaultBuckleTongue : BuckleTongue defaultBuckleTongue = { thickness = mm 2 , width = mm 2.6 } default : Parameters default = { lugWidth = mm 20
-
@@ -166,7 +188,7 @@ , buckleHole ={ offset = mm 50 , count = 7 , interval = mm 6 , diameter = mm 3 , diameter = mm 2 } , flap = mm 15 }
-
@@ -180,6 +202,10 @@ , thickness = mm 1.0} , caseSideFlap = mm 15 , claspSideFlap = mm 20 , buckle = { springBarDiameter = mm 1.4 , tongue = Just defaultBuckleTongue } } , profile = Straight , thickness = mm 2.5
-
-
-
@@ -15,7 +15,7 @@ import Html.Attributes exposing (..)import Html.Events exposing (onBlur, onFocus, onInput) import Html.LivingStandard exposing (..) import Length exposing (Length, toMM) import Parameters exposing (ColorSchema(..), LoopStyle(..), Parameters, colorSchemaToString, defaultFixedLoop, defaultFreeLoop, loopStyleToString) import Parameters exposing (ColorSchema(..), LoopStyle(..), Parameters, colorSchemaToString, defaultBuckleTongue, defaultFixedLoop, defaultFreeLoop, loopStyleToString) import Parameters.Constraints exposing (NumberConstraints, constraints) import Parameters.Key as Key exposing (Key(..)) import Parameters.Parser exposing (..)
-
@@ -85,6 +85,20 @@ , params.shortPiece.loops.free |> Maybe.withDefault defaultFreeLoop |> .play |> toMM |> String.fromFloat) , ( Key.toString FreeLoopOverlap , params.shortPiece.loops.free |> Maybe.withDefault defaultFreeLoop |> .overlap |> toMM |> String.fromFloat ) , ( Key.toString BuckleSpringBarDiameter, String.fromFloat (toMM params.shortPiece.buckle.springBarDiameter) ) , ( Key.toString HasBuckleTongue , if params.shortPiece.buckle.tongue == Nothing then "false" else "true" ) , ( Key.toString BuckleTongueThickness , params.shortPiece.buckle.tongue |> Maybe.withDefault defaultBuckleTongue |> .thickness |> toMM |> String.fromFloat ) , ( Key.toString BuckleTongueWidth , params.shortPiece.buckle.tongue |> Maybe.withDefault defaultBuckleTongue |> .width |> toMM |> String.fromFloat ) , ( Key.toString ShortPieceLength, String.fromFloat (toMM params.shortPiece.length) ) , ( Key.toString CanvasMargin, String.fromFloat (toMM params.rendering.margin) )
-
@@ -217,22 +231,74 @@ |> Dict.fromList|> Err parseBuckleTongue : Fields -> Result Errors (Maybe Parameters.BuckleTongue) parseBuckleTongue fields = case parseField HasBuckleTongue parseBool fields of Ok True -> case ( parseField BuckleTongueWidth (parseLength constraints.shortPiece.buckle.tongue.width) fields , parseField BuckleTongueThickness (parseLength constraints.shortPiece.buckle.tongue.thickness) fields ) of ( Ok width, Ok thickness ) -> Ok (Just { width = width, thickness = thickness }) ( width, thickness ) -> Err (mkErrors [ ( BuckleTongueWidth, getError width ) , ( BuckleTongueThickness, getError thickness ) ] ) _ -> Ok Nothing parseBuckle : Fields -> Result Errors Parameters.Buckle parseBuckle fields = case ( parseBuckleTongue fields , parseField BuckleSpringBarDiameter (parseLength constraints.shortPiece.buckle.springBarDiameter) fields ) of ( Ok tongue, Ok springBarDiameter ) -> Ok { tongue = tongue, springBarDiameter = springBarDiameter } ( tongue, springBarDiameter ) -> [ getError tongue |> Maybe.withDefault Dict.empty , mkErrors [ ( BuckleSpringBarDiameter, getError springBarDiameter ) ] ] |> List.map Dict.toList |> List.concat |> Dict.fromList |> Err parseShortPiece : Fields -> Result Errors Parameters.ShortPiece parseShortPiece fields = case ( parseLoops fields, parseField ShortPieceLength (parseLength constraints.shortPiece.length) fields ) of ( Ok loops, Ok length ) -> case ( parseLoops fields , parseField ShortPieceLength (parseLength constraints.shortPiece.length) fields , parseBuckle fields ) of ( Ok loops, Ok length, Ok buckle ) -> let base = Parameters.default.shortPiece in Ok { base | loops = loops, length = length } Ok { base | loops = loops, length = length, buckle = buckle } ( loops, length ) -> Err (Dict.union (getError loops |> Maybe.withDefault Dict.empty) (mkErrors [ ( ShortPieceLength, getError length ) ]) ) ( loops, length, buckle ) -> [ getError loops |> Maybe.withDefault Dict.empty , mkErrors [ ( ShortPieceLength, getError length ) ] , getError buckle |> Maybe.withDefault Dict.empty ] |> List.map Dict.toList |> List.concat |> Dict.fromList |> Err parseBuckleHole : Fields -> Result Errors Parameters.BuckleHole
-
@@ -723,6 +789,56 @@ , unit = Just "mm", disabled = model.parameters.longPiece.buckleHole.count == 0 , attrs = step "0.5" :: lengthFieldAttrs constraints.longPiece.buckleHole.interval } , numberField model { key = BuckleSpringBarDiameter , title = [ text "Spring Bar Diameter" ] , description = [ text "Diameter of the spring bar to use for buckle / clasp." ] , unit = Just "mm" , disabled = False , attrs = step "0.1" :: lengthFieldAttrs constraints.shortPiece.buckle.springBarDiameter } , choiceField model { key = HasBuckleTongue , title = [ text "Buckle Tongue Cutout" ] , description = [ text "Whether to draw cutout for buckle tongue." ] , attrs = [] , disabled = False , choices = [ { label = [ text "Enabled" ] , description = [ text "Draw cutout at where buckle tongue sits on." ] , value = "true" } , { label = [ text "Disabled" ] , description = [ text "Do not draw cutout for buckle tongue. " , text "Select this if you're planning to use a deployant buckle." ] , value = "false" } ] } , numberField model { key = BuckleTongueWidth , title = [ text "Buckle Tongue Width" ] , description = [ text "Width of the buckle tongue / pin." ] , unit = Just "mm" , disabled = not (Dict.get (Key.toString HasBuckleTongue) model.fields == Just "true") , attrs = step "0.1" :: lengthFieldAttrs constraints.shortPiece.buckle.tongue.width } , numberField model { key = BuckleTongueThickness , title = [ text "Buckle Tongue Thickness" ] , description = [ text "Thickness of the buckle tongue / pin, to add to the cutout depth." ] , unit = Just "mm" , disabled = not (Dict.get (Key.toString HasBuckleTongue) model.fields == Just "true") , attrs = step "0.1" :: lengthFieldAttrs constraints.shortPiece.buckle.tongue.thickness } ] , hr [] []
-
-
-
@@ -39,9 +39,22 @@ , thickness : NumberConstraints Length} type alias BuckleTongue = { thickness : NumberConstraints Length , width : NumberConstraints Length } type alias Buckle = { springBarDiameter : NumberConstraints Length , tongue : BuckleTongue } type alias ShortPiece = { loops : Loops , length : NumberConstraints Length , buckle : Buckle }
-
@@ -101,6 +114,13 @@ }, thickness = { min = Just (mm 0.1), max = Just (mm 1) } } , length = { min = Just (mm 5), max = Just (mm 150) } , buckle = { springBarDiameter = { min = Just (mm 1), max = Just (mm 3) } , tongue = { thickness = { min = Just (mm 0.1), max = Just (mm 3) } , width = { min = Just (mm 1), max = Just (mm 5) } } } } , lining = { min = Just (mm 0), max = Just (mm 5) } , thickness = { min = Just (mm 0.1), max = Just (mm 5) }
-
-
-
@@ -18,6 +18,10 @@ | BuckleHoleOffset| BuckleHoleCount | BuckleHoleInterval | BuckleHoleDiameter | BuckleSpringBarDiameter | HasBuckleTongue | BuckleTongueThickness | BuckleTongueWidth | LongPieceLength | LoopThickness | LoopStyle
-
@@ -57,6 +61,18 @@ "buckle-hole-diameter"BuckleHoleInterval -> "buckle-hole-interval" BuckleSpringBarDiameter -> "buckle-spring-bar-diameter" HasBuckleTongue -> "has-buckle-tongue" BuckleTongueThickness -> "buckle-tongue-thickness" BuckleTongueWidth -> "buckle-tongue-width" LongPieceLength -> "long-piece-length"
-
-
-
@@ -261,6 +261,45 @@ , strokeWidth (toMM params.rendering.lineWidth |> String.fromFloat), highlightStroke (highlighting == Just ShortPieceLength || highlighting == Just LugWidth) ] [] , case params.shortPiece.buckle.tongue of Just { thickness, width } -> let springBarDiameter = toMM params.shortPiece.buckle.springBarDiameter cutoutWidth = toMM width cutoutLength = toMM thickness * 2 + (pi * (springBarDiameter / 2)) + springBarDiameter + toMM params.thickness + toMM params.lining in Svg.path [ Path.d [ MoveTo Absolute ( p.x + lugWidth / 2, p.y + caseSideFlap + length ) , MoveTo Relative ( -cutoutWidth / 2, -springBarDiameter - toMM thickness ) , VerticalLineTo Relative cutoutLength , HorizontalLineTo Relative cutoutWidth , VerticalLineTo Relative -cutoutLength , ClosePath ] , fill "none" , stroke "currentColor" , strokeWidth (toMM params.rendering.lineWidth |> String.fromFloat) , highlightStroke (highlighting == Just BuckleSpringBarDiameter || highlighting == Just BuckleTongueThickness || highlighting == Just BuckleTongueWidth || highlighting == Just SurfaceThickness ) ] [] _ -> g [] [] , g (skivingSeamStroke params) [ Svg.path
-