GEBText.frink

Download or view GEBText.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 400x400 pixels.) The white
    parts will be "cut out" of the cube.
*/


gr = new graphics
gr.font["Roboto Black", 10]
gr.rotate[90 deg]
gr.text["RULES",0,0]
i1 = new image[gr, undef, 800].autocrop[]
i1 = i1.resize[400,400]
//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
      if i1.getPixelGrayInt[x,y] > 128
         v.setRange[x,x,0,h1-1,h1-1-y,h1-1-y,false]

gr = new graphics
   //gr.font["Noto Sans Condensed Black", 10]
gr.font["Roboto Black", 10]
gr.rotate[180 deg]
gr.text["FRINK",0,0]
i2 = new image[gr, undef, 800].autocrop[]
i2 = i2.resize[400,400]

//i2.show[]   
[w1, h1] = i2.getSize[]

for x=0 to w1-1
   for y=0 to h1-1
      if i2.getPixelGrayInt[x,y] > 128
         v.setRange[y,y,x,x,0,h1-1,false]
   
gr = new graphics
   //gr.font["Nimbus Sans Bold", 10]
gr.font["Roboto Black", 10]
gr.text["C",0,0]
i3 = new image[gr, 400, 400].autocrop[]
i3 = i3.resize[400,400]
//i3.show[]   
[w1, h1] = i3.getSize[]

/*
for x=0 to w1-1
   for y=0 to h1-1
      if i3.getPixelGrayInt[x,y] > 128
         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.toObjFormat["test", 1/10]]


Download or view GEBText.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 20217 days, 23 hours, 59 minutes ago.