Posts

Showing posts from August, 2021

1 gallon of fuel

Image
  Sometimes it helps to express things in human scales

64

Image
  I'm getting arty now. Following my previous post on greyscale, I wondered whether the numbers 0..63 can be made to look pretty too.  So I ran this in a terminal and then rotated and stretched the result in an image manipulation program. for i in range(64): s = f "{i:06b}" print(s.replace( '0' , ' ' ).replace( '1' , '\u2588' )) Mesmerizing!

Lord Greyscale

Image
  Posting a pretty picture of some greyscale in which the fractal nature of it is clearly visible.  Black rectangles represent zeros and white rectangles represent ones. Read it as an array of columns going from left to right.  In each column exactly one bit changes relative to the previous, making it an ideal scheme for a head to determine its position. An $n$-bit greyscale sequence has $2^n$ members, and the last member always differs from the first in just 1 bit position.  This makes greyscale ideal for determining position around a cylinder. Here's the code: #!/usr/bin/env python3 def __greyscale_fwd(nbits, preset_bits): if nbits == 1: yield 0 + preset_bits yield 1 + preset_bits else : for x in __greyscale_fwd(nbits-1, preset_bits): yield x for x in __greyscale_rev(nbits-1, preset_bits | (1 << (nbits-1))): yield x def __greyscale_rev(nbits, preset_bits): if nbits == 1: yield 1 + preset_bits yi