GEBCube2.frink

Download or view GEBCube2.frink in plain text format


/** This makes a cube that projects a different silhouette
    along 3 axes, and renders it in Waveform .obj format for 3-D printing.
    This version can take text for each axis. (They can
    be different sizes; this resizes them to 200x200 pixels.) The white
    parts will be "cut out" of the cube.
*/


gr = new graphics
gr.font["Cantarell Extra Bold", 10]
gr.rotate[-90 deg]
gr.text["E",0,0]
i1 = new image[gr, 400, 400].autocrop[]
i1 = i1.resize[200,200]
//i1.show[]   
[w1, h1] = i1.getSize[]

v = newJava["frink.graphics.VoxelArray", [w1,h1,h1,true]]

for x=0 to w1-1
   for y=0 to h1-1
   {
      [r,g,b] = i1.getPixel[x,y]
      if (r+g+b) > 1.5
         v.setRange[x,x,0,h1-1,h1-1-y,h1-1-y,false]
   }

gr = new graphics
gr.font["Cantarell Extra Bold", 10]
gr.text["S",0,0]
i2 = new image[gr, 400, 400].autocrop[]
i2 = i2.resize[200,200]
//i2.show[]   
[w1, h1] = i2.getSize[]

for x=0 to w1-1
   for y=0 to h1-1
   {
      [r,g,b] = i2.getPixel[x,y]
      if (r+g+b) > 1.5
         v.setRange[y,y,x,x,0,h1-1,false]
   }

gr = new graphics
gr.font["Cantarell Extra Bold", 10]
gr.text["J",0,0]
i3 = new image[gr, 400, 400].autocrop[]
i3 = i3.resize[200,200]
//i3.show[]   
[w1, h1] = i3.getSize[]

for x=0 to w1-1
   for y=0 to h1-1
   {
      [r,g,b] = i3.getPixel[x,y]
      if (r+g+b) > 1.5
         v.setRange[0,w1-1,y,y,x,x,false]
   }

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


Download or view GEBCube2.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 19355 days, 10 hours, 17 minutes ago.