-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-- Copyright 2026 Shota FUJI
--
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at https://mozilla.org/MPL/2.0/.
--
-- SPDX-License-Identifier: MPL-2.0
module Parameters exposing (..)
import Length exposing (Length, mm)
type TipShape
= Round
type Profile
= Straight
type alias BuckleHole =
-- Offset from the case side (lug side.)
{ offset : Length
-- Number of buckle holes, can be 0.
, count : Int
-- Center-to-center.
, interval : Length
-- TODO: Support non circular holes.
, diameter : Length
}
{-| Parameters for the long piece, which has buckle holes.
This does not have to be longer than `ShortPiece`.
-}
type alias LongPiece =
{ length : Length
, tip : TipShape
, buckleHole : BuckleHole
, flap : Length
}
type alias FixedLoop =
{ width : Length
, play : Length
, offset : Length
}
type alias FreeLoop =
{ width : Length
, play : Length
, overlap : Length
}
type LoopStyle
= Simple
| Folded
loopStyleToString : LoopStyle -> String
loopStyleToString style =
case style of
Simple ->
"simple"
Folded ->
"folded"
type alias Loops =
{ fixed : Maybe FixedLoop
, free : Maybe FreeLoop
, style : LoopStyle
, thickness : Length
}
{-| Parameters for the short piece, which has clasp at the end.
This does not have to be shorter than `LongPiece`.
-}
type alias ShortPiece =
{ length : Length
, loops : Loops
, caseSideFlap : Length
, claspSideFlap : Length
}
type CanvasSize
= A4
canvasSizeDimension : CanvasSize -> ( Length, Length )
canvasSizeDimension size =
case size of
A4 ->
( mm 210, mm 297 )
type ColorSchema
= BlackOnWhite
| WhiteOnBlack
colorSchemaToString : ColorSchema -> String
colorSchemaToString schema =
case schema of
BlackOnWhite ->
"black-on-white"
WhiteOnBlack ->
"white-on-black"
type alias Rendering =
{ size : CanvasSize
, margin : Length
, gap : Length
, lineWidth : Length
, colorSchema : ColorSchema
}
type alias Parameters =
{ lugWidth : Length
, longPiece : LongPiece
, shortPiece : ShortPiece
, profile : Profile
, thickness : Length
, lining : Length
, rendering : Rendering
}
defaultFixedLoop : FixedLoop
defaultFixedLoop =
{ offset = mm 8
, width = mm 6
, play = mm 1
}
defaultFreeLoop : FreeLoop
defaultFreeLoop =
{ width = mm 5
, play = mm 2
, overlap = mm 5
}
default : Parameters
default =
{ lugWidth = mm 20
, longPiece =
{ length = mm 112
, tip = Round
, buckleHole =
{ offset = mm 50
, count = 7
, interval = mm 6
, diameter = mm 3
}
, flap = mm 15
}
, shortPiece =
{ length = mm 80
, loops =
{ fixed = Just defaultFixedLoop
, free = Just defaultFreeLoop
, style = Simple
, thickness = mm 1.0
}
, caseSideFlap = mm 15
, claspSideFlap = mm 20
}
, profile = Straight
, thickness = mm 2.5
, lining = mm 0.5
, rendering =
{ size = A4
, margin = mm 10
, gap = mm 10
, lineWidth = mm 0.3
, colorSchema = BlackOnWhite
}
}