scarfquine1.frink

Download or view scarfquine1.frink in plain text format

// https://frinklang.org
s = readLines["file:scarfquine1.frink"]
g = new graphics;  g.font["Monospaced", 1]
g.antialiasedText[false]
for n = 0 to length[s]-1
   g.text[s@n, (n div 10) * 40,
      1.22 (n mod 10), "left", "center"]
f =  new image[g, 1200, 100];
f.makeMono[]; f.show[]
f.write["scarfquine1.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
gr = 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
         gr.fillRectCenter[x, -(y - n), 1, 1]
gr.show[]


Download or view scarfquine1.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 20162 days, 22 hours, 59 minutes ago.