sphericalEmbossTest.frink

Download or view sphericalEmbossTest.frink in plain text format


/** This is a test of cylindrical embossing for 3-D printing. */

res = 254/inch

h = 1 inch
r = 1 inch

// Test on a cylinder
//v = callJava["frink.graphics.VoxelArray", "makeCylinder", [0,0,h/2 res,0,0,-h/2 res, r res]]

// Test on a cuboid
/*v = callJava["frink.graphics.VoxelArray", "cube", [-r res, r res,
                                                   -r res, r res,
                                                   -h res, h res, true]] */


// Or a sphere
v = callJava["frink.graphics.VoxelArray", "makeSphere", [r res]]

// Load an image
//img = new image["file:Frink100.png"]

// Or create one from text
g = new graphics
g.font["SansSerif", "bold", 10]
g.text["Frink Rules!",0,0]
img = g.toImage[undef, 200]
img.show[]

// 2-pixel cube tool for testing
pixelTool = newJava["frink.graphics.VoxelArray", [0,2,0,2,0,2,true]]

emboss = v.sphericalEmboss[img, 0,0,0, 180 deg, 360 deg, 0 deg, 90 deg, -.5 cm res, .5 cm res, pixelTool, 0, 0, 0]

//v.remove[emboss]    // Test removal
//v = v.union[emboss]   // Test addition
v = emboss            // Just show embossing.

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

filename = "sphericalEmboss.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[v.toObjFormat["v", 1/(res mm)]]
w.close[]
println["done."]


Download or view sphericalEmbossTest.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 19908 days, 4 hours, 42 minutes ago.