scarfquinetest.frink

Download or view scarfquinetest.frink in plain text format

// https://frinklang.org
s = readLines["file:scarfquinetest.frink"]
g = new graphics
g.font["Monospaced", 1]
for n = 0 to length[s]-1
   g.text[s@n, (n div 10) * 40,
          n mod 10, "left","center"]
f = new image[g, 1200, 100]
f.show[]
f.write["scarfquine.tif"]
[w, h] = f.getSize[]
n = 0
for x = w-1 to 0 step -1
   for y = 0 to h-1
   {
      n = n * 2
      [r,g,b] = f.getPixel[x,y]
      if r < 1/2
         n = n + 1
   }
// https://knityak.com
n = n * h
println["n = $n"]
println["Graph the points"]
println["   0 <= x < $w,"]
println["   n <= y < n+$h,"]
println[" where"]
println[" 1/2 > floor(mod(floor(y/$h)*"]
println["    2^(-$h*floor(x)-"]
println["       mod(floor(y), $h)),2))"]

// Reproduce the scarf just from n
g = new graphics
for x=0 to w-1
   for y = n to n+h-1
      if ((y div h) * 2^(-h x -
          (y mod h))) mod 2 >= 1/2
         g.fillRectCenter[x,-(y-n),1,1]
   
g.show[]


Download or view scarfquinetest.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 20139 days, 6 hours, 19 minutes ago.