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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Munching squares step by step in the Ada 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 Ada programming language

Source code in the ada programming language

with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Image_Surface; use Cairo.Image_Surface;
procedure XorPattern is
   type xorable is mod 256;
   Surface : Cairo_Surface;
   Data : RGB24_Array_Access;
   Status : Cairo_Status;
   Num : Byte;
begin
   Data := new RGB24_Array(0..256*256-1);
   for x in Natural range 0..255 loop
      for y in Natural range 0..255 loop
         Num := Byte(xorable(x) xor xorable(y));
         Data(x+256*y) := RGB24_Data'(Num,0,Num);
      end loop;
   end loop;
   Surface := Create_For_Data_RGB24(Data, 256, 256);
   Status := Write_To_Png (Surface, "AdaXorPattern.png");
   pragma Assert (Status = Cairo_Status_Success);
end XorPattern;


  

You may also check:How to resolve the algorithm 9 billion names of God the integer step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Spelling of ordinal numbers step by step in the VBA programming language
You may also check:How to resolve the algorithm Determine if a string has all unique characters step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Mad Libs step by step in the Scala programming language
You may also check:How to resolve the algorithm GUI component interaction step by step in the Elena programming language