QuasiSpace - Linux 128 bytes
I wished to do a C 128 bytes on Linux since a long time, this
is not until Campers that i
could achieve it with something interesting to show.
It show some kind of tilted apollonian
fractal pattern, the pattern drift a bit on purpose to give
"depth" and alleviate accumulating noise, it is some kind of
minsky algorithm
variation again.
I remember spending a lot of time tweaking the parameters and
fighting GCC code gen, the code could probably made much shorter
(see below) but i wasn't aware of this at the time, i am okay with
the final result although it had an artifact at the center which
could have been solved, i guess ones could explain it by QuasiSpace
definition but that would be a bit too far-etched. :D
The picture is square due to a downscale on the final
coordinates with a shift, this avoid checking that the drawing is
outside buffer boundary and maintain the aspect ratio.
Does not use saturated arithmetic so the image become
increasingly noisy.
Here is the very small algorithm that produce this kind of
fractal (see Apollonian
for more) :
// init (different constants here makes
for variations; small constants produce an ellipse)
x = 1e18
y = 1e9
// loop, preferably iterating more than once per loop (also works
without the x shift !)
x -= (y >> 2)
y += (x >> 1)
// scale it down when you plot it (here for a 512x512 image, y can
be scaled some more to have a good aspect ratio) : (x >> 23),
(y >> 23)
the image produced by the code above (with
aspect ratio correction)
non tilted version by removing
(x
>> 1)
and in loop after y compute add : x -= (y
>> 2)
by shifting the x final coordinate :
(x
>> 23) & 511
with
(y >> 2)
(x
>> 2)
(y >> 2)
and
slightly bigger initial valuesback to top