kcl-samples → kitt →
kitt
KCL
// 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)