kittyHockeyPuck.frink

View or download kittyHockeyPuck.frink in plain text format


/** Make a kitty-sized hockey puck with embossed text.

    A standard hockey puck is 3 inches in diameter and 1 inch thick.
*/


diam = 1.25 in
height = diam / 3

textHeight = .25 in
textDepth = 2 mm

chamferHeight = 1 mm

// The resolution of the object in voxels/length.
r = 254*2/in


// Puck body
c1 = chamferedCylinder[diam/2 r, height r, chamferHeight r]

t1 = text["Mischa", textHeight r, textDepth r]
t1.translate[0, 0, round[(height-textDepth/2) r]]
c1.remove[t1]

t2 = text["Smokey", textHeight r, textDepth r]
t2 = t2.rotateXYZ[0,0,0,0 deg, 180 deg, 0 deg]
t2.translate[0, 0, round[textDepth/2 r]]
c1.remove[t2]


c1.projectX[undef].show["X"]
c1.projectY[undef].show["Y"]
c1.projectZ[undef].show["Z"]   

filename = "kittyHockeyPuck.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[c1.toObjFormat["test", 1/(r mm)]]
w.close[]
println["done."]


/** Extrude text and create a VoxelArray of it. */
text[str, textHeight, depth] :=
{
   g = new graphics
   g.font["SansSerif", "bold", textHeight]
   g.text[str, 0, 0]
   img = g.toImage[undef, round[textHeight]].autocrop[]
   
   return callJava["frink.graphics.VoxelArray", "extrudeZ", [img, depth]]
}

/** Make a chamfered cylinder */
chamferedCylinder[radius, height, chamferHeight] :=
{
   // Bottom layer
   c1 = callJava["frink.graphics.VoxelArray", "makeTaperedCylinder", [0, 0, 0, 0, 0, chamferHeight, radius-chamferHeight, radius]]

   // Central cylinder
   c2 = callJava["frink.graphics.VoxelArray", "makeCylinder", [0, 0, chamferHeight, 0, 0, height-chamferHeight, radius]]

   // Top cylinder
   c3 = callJava["frink.graphics.VoxelArray", "makeTaperedCylinder", [0, 0, height-chamferHeight, 0, 0, height, radius, radius-chamferHeight]]

   return c1.union[c2].union[c3]
}


View or download kittyHockeyPuck.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19100 days, 8 hours, 56 minutes ago.