-
Notifications
You must be signed in to change notification settings - Fork 0
/
kitt.kcl
258 lines (201 loc) · 9.49 KB
/
kitt.kcl
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
// Kitt
// The beloved KittyCAD mascot in a voxelized style.
// pixel box function
fn pixelBox = (kitExtrude, extrudeTag, positionY, positionZ, width, height, depth) => {
pixelBoxBody = startSketchOn(kitExtrude, extrudeTag)
|> startProfileAt([positionY, positionZ], %)
|> line([0, height], %)
|> line([width, 0], %)
|> line([0, -height], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> extrude(depth, %)
return pixelBoxBody
}
// 1. Kitty Body
kitBodyElevation = 6
kitBodyWidth = 26
kitBodyHeight = 25
kitBodyDepth = 18
kitBody = startSketchOn('XZ')
|> startProfileAt([-kitBodyWidth / 2, kitBodyElevation], %)
|> line([0, kitBodyHeight], %)
|> line([kitBodyWidth, 0], %, $seg01)
|> line([0, -kitBodyHeight], %, $seg02)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> extrude(kitBodyDepth, %)
// 2. Kitty Head (Frame of display)
kitHeadOffset = 1
kitHeadHeight = 16
kitHeadElevation = kitBodyElevation + kitBodyHeight - kitHeadOffset - kitHeadHeight
kitHeadWidth = kitBodyWidth - (kitHeadOffset * 2)
kitHeadDepth = 3
kitHead = pixelBox(kitBody, 'END', -kitHeadWidth / 2, kitHeadElevation, kitHeadWidth, kitHeadHeight, kitHeadDepth)
kitFaceElevation = kitHeadElevation + 2
// 3. Kitty Face
kitFaceWidth = kitHeadWidth - 4
kitFaceHeight = kitHeadElevation + kitHeadHeight - kitFaceElevation - 3
kitFaceDepth = 2
kitFace = startSketchOn(kitHead, 'END')
|> startProfileAt([-kitFaceWidth / 2, kitFaceElevation], %)
|> line([0, 1], %) // left lower corner up
|> line([-1, 0], %) // left lower corner left
|> line([0, kitFaceHeight], %) // left side up
|> line([1, 0], %) // left upper corner right
|> line([0, 1], %) // left upper corner up
|> line([kitFaceWidth, 0], %) // upper side right
|> line([0, -1], %) // right upper corner down
|> line([1, 0], %) // right upper corner right
|> line([0, -kitFaceHeight], %) // right side down
|> line([-1, 0], %) // right lower corner left
|> line([0, -1], %) // right lower corner down
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> extrude(-kitFaceDepth, %)
// Kitty Face Features:
// 3.1 Kitty Eyes
// 3.1.1 Kitty Left Eye
kitEyeDepth = 0.5
kitEyeHeihgt = kitFaceElevation + 7
kitEyeOffset = 7
// 3.1.2 Kitty Right Eye
kitLeftEye1 = pixelBox(kitFace, 'START', -kitEyeOffset, kitEyeHeihgt, 1, 1, kitEyeDepth)
// 3.2 Kitty Nose
kitLeftEye2 = pixelBox(kitFace, 'START', -kitEyeOffset + 1, kitEyeHeihgt + 1, 3, 1, kitEyeDepth)
kitLeftEye3 = pixelBox(kitFace, 'START', -kitEyeOffset + 4, kitEyeHeihgt, 1, 1, kitEyeDepth)
kitRightEye = pixelBox(kitFace, 'START', kitEyeOffset - 3, kitEyeHeihgt - 1, 2, 4, kitEyeDepth)
kitNoseElevation = kitEyeHeihgt - 5
kitNose = startSketchOn(kitFace, 'START')
|> startProfileAt([-2, kitNoseElevation], %) // H V
|> line([0, 1], %) // lower-left up
|> line([2, 0], %) // lower-left right
|> line([0, 2], %) // mid-left up
|> line([-1, 0], %) // upper-left left
|> line([0, 1], %) // upper-left up
|> line([3, 0], %) // upper-mid right
|> line([0, -1], %) // upper-right down
|> line([-1, 0], %) // upper-right left
|> line([0, -2], %) // mid-left down
|> line([2, 0], %) // lower-right right
|> line([0, -1], %) // lower-right down
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
|> extrude(kitEyeDepth, %)
// 3.3 Kitty Mouth
kitMouthOffset = 4
kitMouthHeight = kitEyeHeihgt - 3
kitMouthUpLeft = pixelBox(kitFace, 'START', -kitMouthOffset, kitMouthHeight, 1, 1, kitEyeDepth)
// 4. Kitty Belly
kitMouthDownLeft = pixelBox(kitFace, 'START', -kitMouthOffset + 1, kitMouthHeight - 1, 1, 1, kitEyeDepth)
kitMouthUpRight = pixelBox(kitFace, 'START', kitMouthOffset, kitMouthHeight, 1, 1, kitEyeDepth)
kitMouthDownRight = pixelBox(kitFace, 'START', kitMouthOffset - 1, kitMouthHeight - 1, 1, 1, kitEyeDepth)
kitBellyElevation = kitBodyElevation + 1
kitBellyHeight = kitHeadElevation - kitBellyElevation - 1
// 4.1 Kitty VHS
kitBellyWidth = kitHeadWidth
kitBellyDepth = kitHeadDepth
kitBelly = pixelBox(kitBody, 'END', -kitBellyWidth / 2, kitBellyElevation, kitBellyWidth, kitBellyHeight, kitBellyDepth)
kitVHSelevation = kitBellyElevation + 1
kitVHSheight = 2
// 4.2 Kitty Floppy
kitVHSwidth = 8
kitVHSdepth = 1
kitVHS = pixelBox(kitBelly, 'END', -kitVHSwidth / 2, kitVHSelevation, kitVHSwidth, kitVHSheight, kitVHSdepth)
kitFloppyElevation = kitBellyElevation + 1
kitFloppyHeight = 1
kitFloppyWidth = 5
kitFloppyOffset = kitBellyWidth / 2 - 1
kitFloppyDepth = 2
// 4.3 Kitty Belly Button
kitFloppy1 = pixelBox(kitBelly, 'END', -kitFloppyOffset, kitFloppyElevation, kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
kitFloppy2 = pixelBox(kitBelly, 'END', -kitFloppyOffset, kitFloppyElevation + 2, kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
kitFloppy3 = pixelBox(kitBelly, 'END', kitFloppyOffset, kitFloppyElevation, -kitFloppyWidth, kitFloppyHeight, -kitFloppyDepth)
kitBellyButtonOffset = kitHeadWidth / 2 - 3
kitBellyButtonElevation = kitHeadElevation - 1
kitBellyButtonWidth = 2
// 4.4 Kitty Buttons
kitBellyButtonHeight = 1
kitBellyButtonDepth = kitHeadDepth + 1
kitBellyButton = pixelBox(kitBody, 'END', -kitBellyButtonOffset, kitBellyButtonElevation, kitBellyButtonWidth, kitBellyButtonHeight, kitBellyButtonDepth)
kitButtonWidth = 1
kitButtonHeight = 2
kitButtonDepth = kitFloppyDepth
kitButtonElevation = kitFloppyElevation + 2
kitButton1 = pixelBox(kitBelly, 'END', kitFloppyOffset, kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
// 5. Kitty Legs
kitButton2 = pixelBox(kitBelly, 'END', kitFloppyOffset - kitButtonWidth - 1, kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
kitButton3 = pixelBox(kitBelly, 'END', kitFloppyOffset - (2 * (kitButtonWidth + 1)), kitFloppyElevation + 2, -kitButtonWidth, kitButtonHeight, -kitButtonDepth)
kitShoeWidth = 7
kitShoeLength = 10
kitShoeHeight = 3
fn kitLeg = (offsetFront, offsetSide) => {
kitShoeOffsetFront = (kitShoeLength / 2) - (kitBodyDepth / 2) - offsetFront
kitFootPrint = startSketchOn('XY')
|> startProfileAt([offsetSide, kitShoeOffsetFront], %)
|> line([kitShoeWidth, 0], %)
|> line([0, -kitShoeLength], %)
|> line([-kitShoeWidth, 0], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
kitShoe = extrude(kitShoeHeight, kitFootPrint)
kitPantsOffsetSide = offsetSide + 1
kitPantsOffsetFront = 2 * kitShoeOffsetFront - 2
kitPantsWidth = kitShoeWidth - 2
kitPantsFrontWidth = kitPantsWidth
kitPantsHeight = kitBodyElevation - kitShoeHeight
kitPants = pixelBox(kitShoe, 'END', kitPantsOffsetSide, kitPantsOffsetFront, kitPantsFrontWidth, kitPantsWidth, kitPantsHeight)
return kitShoe
}
kitLegOffset = 3
kitRightLeg = kitLeg(0, kitLegOffset)
kitLeftLeg = kitLeg(0, -kitLegOffset - kitShoeWidth)
// 6. Kitty Ears
kitEarWidth = 8
kitEarDepth = 8
kitEarHeight = 2
fn kitEar = (earOffsetFront, earOffsetSide) => {
kitNewEarOffsetFront = kitBodyDepth - earOffsetFront
kitNewEarOffsetSide = -(kitBodyWidth / 2 - earOffsetSide)
baseVolume = pixelBox(kitBody, seg01, kitNewEarOffsetSide, kitNewEarOffsetFront, kitEarWidth, -kitEarDepth, kitEarHeight)
secondOffset = 1
secondLevel = pixelBox(baseVolume, 'END', kitNewEarOffsetSide + secondOffset, kitNewEarOffsetFront - 0.01, kitEarWidth - (secondOffset * 2), -kitEarDepth + secondOffset * 2, kitEarHeight)
thirdOffset = 2
thirdLevel = pixelBox(secondLevel, 'END', kitNewEarOffsetSide + thirdOffset, kitNewEarOffsetFront - 0.02, kitEarWidth - (thirdOffset * 2), -kitEarDepth + thirdOffset * 2, kitEarHeight)
fourthOffset = 3
fourthLevel = pixelBox(thirdLevel, 'END', kitNewEarOffsetSide + fourthOffset, kitNewEarOffsetFront - 0.03, kitEarWidth - (fourthOffset * 2), -kitEarDepth + fourthOffset * 2, kitEarHeight)
return baseVolume
}
kitEarOffsetFront = 4
kitEarOffsetSide = 1
kitRightEar = kitEar(kitEarOffsetFront, kitEarOffsetSide)
kitLeftEar = kitEar(kitEarOffsetFront, kitBodyWidth - kitEarWidth - kitEarOffsetSide)
// 7. Kitty Side
// 7.1 Grill
grillOffset = 4
grillRowA = kitBodyElevation + kitBodyHeight - grillOffset
grillRowB = grillRowA - 2
grillRowC = grillRowA - 4
grillColumnA = kitBodyDepth - grillOffset
grillColumnB = grillColumnA - 1
grillColumnC = grillColumnA - 2
grillColumnD = grillColumnA - 3
grillColumnE = grillColumnA - 4
grillHoleSize = 1
grillHoleDepth = -2
grillHoleAB = pixelBox(kitBody, seg02, grillRowA, grillColumnB, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleAD = pixelBox(kitBody, seg02, grillRowA, grillColumnD, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleBA = pixelBox(kitBody, seg02, grillRowB, grillColumnA, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleBC = pixelBox(kitBody, seg02, grillRowB, grillColumnC, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleBE = pixelBox(kitBody, seg02, grillRowB, grillColumnE, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleCB = pixelBox(kitBody, seg02, grillRowC, grillColumnB, grillHoleSize, grillHoleSize, grillHoleDepth)
grillHoleCD = pixelBox(kitBody, seg02, grillRowC, grillColumnD, grillHoleSize, grillHoleSize, grillHoleDepth)
// 7.2 Kitty Vent
kitVentElevation = kitBodyElevation + 1
kitVentOffset = 1
kitVentHoleWidth = 1
kitVentHoleHeight = 4
kitVentHoleDepth = grillHoleDepth
kitVentA = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)
kitVentB = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset + 2, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)
kitVentC = pixelBox(kitBody, seg02, kitVentElevation, kitVentOffset + 4, kitVentHoleHeight, kitVentHoleWidth, kitVentHoleDepth)