kcl-samples →
kitt
KCL
// Kitt
// The KittyCAD mascot
// Define constants
const l1 = 10
const l2 = 10
const arcR = 2
const footH = 3.5
const bodyHeight = 2.5
const filletRadius = 0.25
// Create a function for defining one of Kitt's legs
fn kittLeg = (sk1, sk2) => {
const legExtrude = startSketchAt([sk1, sk2])
|> line([3, 0], %)
|> line([0, -3], %)
|> line([-3, 0], %)
|> close(%)
|> extrude(bodyHeight, %)
return legExtrude
}
// Create a function to define an ear
fn kittEar = (sk1, sk2, size) => {
const earExtrude = startSketchAt([sk1, sk2])
|> arc({
angle_start: 180,
angle_end: 180,
radius: 1.5
}, %)
|> close(%)
|> extrude(bodyHeight, %)
return earExtrude
}
// Create a function to define a foot
fn kittFoot = (sk1, sk2) => {
const footExtrude = startSketchAt([sk1, sk2])
|> line([3, 0], %)
|> line([0, -1.5], %)
|> line([-3, 0], %)
|> close(%)
|> extrude(footH, %)
return footExtrude
}
// Create the body
const kittBody = startSketchAt([-l2/2, -l1/2])
|> line([0, l1], %)
|> line([l2, 0], %)
|> line([0, -l1], %)
|> close(%)
|> extrude(bodyHeight, %)
// Create the legs, ears, and feet of Kitt
const leg1 = kittLeg(-4, -5)
const leg2 = kittLeg(1, -5)
const ear1 = kittEar(-4, 5, 3)
const ear2 = kittEar(1, 5, 3)
const foot1 = kittFoot(-4, -8)
const foot2 = kittFoot(1, -8)
// Create the face. This creates a small indentation into the body.
const face = startSketchOn(kittBody, 'end')
|> startProfileAt([-l2/2+1, -l1/2+1], %)
|> line([l1 - 2, 0], %)
|> line([0, l2 - 2], %)
|> line([-l1 + 2, 0], %)
|> close(%)
|> extrude(-.25, %)
// Create a function that defines a singular button
fn button = (start1, start2, w, l, h) => {
const buttonSketch = startSketchOn(kittBody, 'end')
|> startProfileAt([start1, start2], %)
|> line([w, 0], %)
|> line([0, l], %)
|> line([-w, 0], %)
|> close(%)
|> extrude(h, %)
return buttonSketch
}
// Place three buttons on Kitt's body
const button1 = button(-4.75, -4.75, 1, .25, .125)
const button2 = button(-3, -4.75, 1, .25, .125)
const button3 = button(-1.25,-4.75, 1, .25, .125)