cylindricalEmbossTest.frink

Download or view cylindricalEmbossTest.frink in plain text format


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

res = 254/inch

h = 1 inch
r = .5 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]]

// Create a graphic from text
/*
g = new graphics
g.font["SansSerif", "bold", 10]
g.text["Frink Rules!",0,0]
img = g.toImage[undef, 200]
img.show[]
img.write["FrinkRules.png"]
*/


// Or load an image
img = new image["https://frinklang.org/frinksamp/FrinkRules.png"]

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

emboss = v.cylindricalEmboss[img, 0,0,0, 180 deg, 360 deg, 1 inch res, -.0 cm res, 1 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 = "cylindricalEmboss.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[v.toObjFormat["v", 1/(res mm)]]
w.close[]
println["done."]


Download or view cylindricalEmbossTest.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 19965 days, 7 hours, 5 minutes ago.