How to resolve the algorithm Munching squares step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Munching squares step by step in the zkl programming language

Table of Contents

Problem Statement

Render a graphical pattern where each pixel is colored by the value of 'x xor y' from an arbitrary color table.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Munching squares step by step in the zkl programming language

Source code in the zkl programming language

fcn muncher{
   bitmap:=PPM(256,256);
   coolness:=(1).random(0x10000);  // 55379, 18180, 40, 51950, 57619, 43514, 65465
   foreach y,x in ([0 .. 255],[0 .. 255]){
      b:=x.bitXor(y);	// shades of blue
//      rgb:=b*coolness;                 // kaleidoscopic image
//      rgb:=(b*coolness + b)*coolness + b;  // more coolness
      rgb:=(b*0x10000 + b)*0x10000 + b;  // copy ADA image
      bitmap[x,y]=rgb;
   }
   bitmap.write(File("foo.ppm","wb"));
}();

while(1){ muncher(); Atomic.sleep(3); }

  

You may also check:How to resolve the algorithm Runtime evaluation/In an environment step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Doubly-linked list/Element insertion step by step in the C programming language
You may also check:How to resolve the algorithm Play recorded sounds step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Loops/Foreach step by step in the LFE programming language
You may also check:How to resolve the algorithm Bitmap/Bézier curves/Quadratic step by step in the TI-89 BASIC programming language