A thing I made...

Modern Muzzleloading Forum

Help Support Modern Muzzleloading Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

anonymouscowherd

Well-Known Member
*
Joined
Sep 29, 2022
Messages
814
Reaction score
1,961
Made this as a proof of concept for something, turned around and got approval to make something to honor the graduates that term at the college I work for and that something ended up winning its category ("Digitally created art") at a national graphic design contest that year.

No AI.... well, whatever state the right combo of alcohol and caffeine gets me in...

Anyway, the PoC - See if you can figure out how I did it...

peacocktale.png
 
hera set argus eyes on the tail of a bird , you set text on a peacock .
i like the chinese version better
 
If you shrink the image down, it gives a good hint....
peacocktale.png


And how I did it -
In code, open the image for reading. Start a loop for rows Y, start a loop for columns X. Grab pixel at X,Y coordinate, determine color, grab character from plain text file and wrap it with the appropriate HTML tags to print that character in that color. Increment X counter, read next pixel, etc. If out of X pixels to read, reset counter for loop, increment counter for Y loop and start over on next row.

Once you have pretty HTML (easier to play with font styles, spacing, etc there instead of as a big graphic) you copy/paste the formatting and all to a new Illustrator or similar file, slap borders or whatever on, and export as PDF and send to a printer...

Code:
<?php
$img = imagecreatefrompng("smpeacock.png");
$words=file("grad.txt");
$wi=0;
$we=0; 
$w = imagesx($img);
$h = imagesy($img);
for($y=0;$y<$h;$y++) {
  for($x=0;$x<$w;$x++) {
    $rgb = imagecolorat($img, $x, $y);
    $r = ($rgb >> 16) & 0xFF;
    $g = ($rgb >> 8) & 0xFF;
    $b = $rgb & 0xFF;  
    $rgbhtml="#".str_repeat("0",2-strlen(dechex($r))).dechex($r).str_repeat("0",2-strlen(dechex($g))).dechex($g).str_repeat("0",2 - strlen(dechex($b))).dechex($b);
    if(substr($words[$wi],$we,1)==" "){
      echo "<font color=$rgbhtml>&middot;</font>";
    }else{  
      echo "<font color=$rgbhtml>".htmlspecialchars(substr($words[$wi],$we,1))."</font>";
    }
    $we++;
    if($we==strlen($words[$wi])){
      $we=0;
      $wi++;
      if($wi==count($words)){
	$wi=0;
      }
    }
  }
  echo "\r\n";
} 
?>
 
Back
Top