QRCodeEgg.frink

Download or view QRCodeEgg.frink in plain text format


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

res = 254/inch
h = 1 inch
r = 1 inch

text = "https://triplenine.org"

// On an ellipsoid
v = callJava["frink.graphics.VoxelArray", "makeSuperellipsoid", [r res, r res, 1.3 r res, 1, 1]]

img = qrcode[text, "L"]
//img = img.gaussianBlur[2]  // This makes it feasible to print without overhang

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

// Out emboss
emboss = v.sphericalEmboss[img, 0,0,0, 180 deg, 90 deg, 0 deg, 70 deg, 0, 254, 0 cm res, 0 cm res, -.2 cm res, 0 cm res, pixelTool, 0, 0, 0]

// In emboss
emboss2 = v.sphericalEmboss[img, 0,0,0, 0 deg, 90 deg, 0 deg, 70 deg, 0, 254, 0 cm res, 0 cm res, .2 cm res, 0 cm res, pixelTool, 0, 0, 0]

v = v.union[emboss]   // Add extrusion
v.remove[emboss2]     // remove carving

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

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

// Generates a QRcode image using Google Charts API:
// http://code.google.com/apis/chart/docs/gallery/qr_codes.html

// Generate a QRcode image and return that image.
// errorCorrection is a letter consisting of one of the following:
// "L" (can correct up to  7% errors)
// "M" (can correct up to 15% errors)
// "Q" (can correct up to 25% errors)
// "H" (can correct up to 30% errors)
qrcode[text, errorCorrection="M", width=400, height=400] :=
{
   return new image["http://chart.apis.google.com/chart?cht=qr&chs=${width}x${height}&chld=$errorCorrection&chl=" + URLEncode[text, "UTF8"]]
}


Download or view QRCodeEgg.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 19975 days, 0 hours, 35 minutes ago.