Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Let Me Concentrate

Name: Anonymous 2012-10-13 9:16

                                      ████    ████                     
                                      ████  ██████                     
                                    ████  ██████                       
                                    ████  ██████                       
                                  ████████████    ██████               
                                  ██████████  ██████████               
                              ▓▓▓▓██████████████████                   
            ▓▓▓▓        ▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓██████                       
          ▓▓▒▒▒▒██  ▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████                     
        ▓▓▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██                   
        ██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██                 
      ██▒▒▒▒▒▒██▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒██               
    ██▒▒▒▒▒▒▒▒▓▓░░░░░░▓▓▒▒▒▒▒▒▒▒▒▒▓▓░░░░░░▒▒▓▓▒▒▒▒▒▒▒▒████             
  ██▒▒▒▒▒▒▒▒██░░░░██░░▒▒▓▓▒▒▒▒▒▒▓▓░░░░██░░░░▒▒▓▓▒▒▒▒██▒▒▒▒██           
  ██▒▒▒▒▒▒▒▒██░░░░░░░░▒▒▓▓▒▒▒▒▒▒██░░░░░░░░░░▒▒██▒▒████▒▒▒▒▒▒██         
██▒▒▒▒▒▒▒▒▒▒██▓▓░░░░▒▒▒▒██████▒▒▒▒▓▓░░░░░░▒▒▓▓▒▒██▒▒▒▒▒▒▒▒▒▒██         
██▒▒▒▒▒▒▒▒▒▒██▒▒▓▓▓▓▓▓██░░░░▒▒████▒▒▓▓████▓▓▒▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒██       
██▒▒▒▒▒▒▒▒▒▒▓▓██▒▒████░░░░░░▒▒▒▒▓▓████▓▓▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒██       
██▓▓▒▒▒▒▒▒▓▓▓▓████░░██░░░░░░██▒▒▓▓▓▓▓▓▓▓██▒▒▒▒▓▓▓▓██▒▒▒▒▒▒▒▒▒▒▓▓██     
  ██▓▓▓▓▓▓▓▓▓▓▓▓██░░▓▓░░░░▓▓▒▒▒▒▒▒▓▓▓▓▓▓██▓▓▓▓▓▓▓▓██▒▒▒▒▒▒▒▒▒▒▓▓██     
  ██▓▓▓▓▓▓▓▓▓▓██░░░░░░░░░░░░░░▒▒▒▒▓▓▓▓██▓▓▓▓▓▓████▓▓▒▒▒▒▒▒▒▒▓▓▓▓██     
    ██▓▓▓▓▓▓████░░░░░░░░░░░░░░▒▒▓▓▓▓▓▓████████▓▓██▓▓▓▓▒▒▒▒▓▓▓▓▓▓██     
      ████▓▓██░░░░░░░░░░░░░░▒▒▒▒▓▓▓▓██▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓██       
          ██░░░░░░░░░░░░░░░░▒▒▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██       
        ██░░░░░░░░░░░░░░░░▒▒▒▒▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██         
        ██▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██         
          ██▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██      ████ 
          ██████▓▓▓▓▓▓▓▓▓▓██████▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██  ████▒▒▒▒██
          ██▒▒▒▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████▒▒▒▒▒▒▒▒██
        ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▒▒██ 
        ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▓▓██ 
        ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓██   
        ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓██   
          ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓██     
          ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓██       
            ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████         
              ██▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██             
                ████▓▓▒▒▒▒▓▓▒▒▓▓▒▒▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓████               
              ████▓▓██████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████                 
          ████▒▒▒▒▓▓▓▓▓▓▓▓████████████████████▓▓▓▓▓▓▓▓██               
        ██▒▒▒▒▓▓▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓██      ██▓▓▓▓▓▓▒▒▓▓▓▓▓▓████           
          ████▒▒▒▒██▒▒▒▒▓▓██████      ██▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓██         
            ████████▓▓▓▓████          ██▒▒▒▒▒▒██▒▒▒▒▓▓▓▓▓▓▓▓██         
                  ██████                ████████▓▓▒▒▒▒██████           
                                                ████████               
                                                                       

Name: Anonymous 2012-10-13 13:30

>>30
That's nice, I hope you haven't done that manually.

Actually a fair bit is done manually, I have to find some pixel/gif art on the web, crop, desaturate, adjust light and contrast, and export the optimized image as ASCII .pgm file.
Then I just filter it on stdout with naive printfs.


/*
 * ============================================================
 *
 *       Filename:  pgm2char.c
 *          Usage:  cat file.pgm | ./pgm2char
 *
 *    Description:  Take an image file in PGM format as input
 *                  and output ``utf8 art'' graphics on stdout
 *                  █ U+2588 FULL BLOCK
 *                  ░ U+2591 LIGHT SHADE
 *                  ▒ U+2592 MEDIUM SHADE
 *                  ▓ U+2593 DARK SHADE
 *
 *       Compiler:  gcc
 *
 *         Author:  Anonymous
 *        Comment:  - Code looks very much like K&R Level 1,
 *                  and that's precisely what it was:
 *                  some shit done as exercise
 *                  while reading Chapter I.
 *                  - Conversion to .pgm is done with Gimp,
 *                  Some other program might add comment lines
 *                  that will break execution.
 *                  You're on your own.
 *
 * ============================================================
 */



#include <stdio.h>
#include <stdlib.h>

#define MAXDIGIT 5

char WIDTH[MAXDIGIT];
char HEIGHT[MAXDIGIT];
int W;
int H;
char dark[] = "██";
char darkshade[] = "▓▓";
char mediumshade[] = "▒▒";
char lightshade[] = "░░";
char light[] = "  ";
int main()
{
  int i, c;
  int linecount = 0;
  int columncount = 0;
  char pixel[2];
  int pixelvalue; 

  printf("[sub][sub][sub][sub][m]");

  /* skip .pgm file comment (2 lines, here) */
  while ((c = getchar()) != '\n');
  while ((c = getchar()) != '\n');
 
  i=0;
  while ((c = getchar()) != ' ') {
    WIDTH[i++] = c;
  }
  i=0;
  while ((c = getchar()) != '\n') {
    HEIGHT[i++] = c;
  }

  W = atoi(WIDTH);
  H = atoi(HEIGHT);

  /* skip another line */
  while ((c = getchar()) != '\n');

  /* output pixel values as rectangle characters */
  while (linecount < H) {
    i = 0;
    while ((c = getchar()) != '\n') {
      pixel[i++] = c;
    }
    pixelvalue = atoi(pixel);
    i = 0;
    while (i < 3) {
      pixel[i++] = '\0';
    }
    if (pixelvalue > 204)
      printf(light);
    if (pixelvalue > 153 && pixelvalue <= 204)
      printf(lightshade);
    if (pixelvalue > 102  && pixelvalue <= 153)
      printf(mediumshade);
    if (pixelvalue > 51 && pixelvalue <= 102)
      printf(darkshade);
    if (pixelvalue <= 51)
      printf(dark);

    if (columncount == W - 1) {
      printf("\n");
      columncount = 0;
      linecount++;
    }
    else columncount++;   
  }

  printf("[/m][/sub][/sub][/sub][/sub]");
  return(0);
}


Now the same thing in one line of your favorite script language

Name: Anonymous 2012-10-13 14:14

>>31
Not bad for the K&R beginner! After you reach file IO, you may want to check the bitmap specs, as it's fairly easy to get pixel values out from .bmp files. Aside from parsing, everything should be same.

Name: >>32 2012-10-13 14:17

for the
for a*

Name: Anonymous 2012-10-13 14:32

>>32
I've finished reading the book since and got to play with libpng on a little project. Getting pixel values from PNGs is not too hard either. Reading what I wrote back then, those atoi()s and uninitialized arrays scare me.

Name: Anonymous 2012-10-13 17:00

>>31
Looks awesome. I wonder if I can make a quick KSH script to use ImageMagick to do your manual work.

Name: Anonymous 2012-10-13 17:29

>>35
If your font has the 2580-259F unicode block elements  ["▗", "▖", "▄", "▝", "▐", "▞", "▟", "▘", "▚", "▌", "▙", "▀", "▜", "▛"] you can take some random line drawing and make this:


                                                                          
                                                                      ▄▖  
                             ▄                                       ▞▟▌  
                             ▙▙▄▖                               ▗▄▄▀▀▛▛▘  
                            ▀ ▌ ▝▀▚▄▄                       ▗▄▞▀▘    ▌▌   
                            ▀ ▖     ▝▀█▄                 ▗▄▛▘        ▚█▌  
                            ▀▟▘         ▀▚▖            ▄▞▘            ▐▌  
                             █            ▝▄▖        ▄▛              ▟▛▘  
                            ▀▜▖             ▝▖▗▄  ▄▄▛               ▄▜    
                           ▝ ▐▌              ▟▛ █▀▞▀                █▟▖   
                            █▗▌             ▗▘    ▌ ▄               █▗▘   
                             ▚▌         ▝▜█▀▀█▛▘▀▀▀▜▄              ▐██    
                             ▟▙▖      ▄▞▘             ▀▄▖          ▌▀     
                             ▌▐▌   ▗▄▀                  ▝▚         ▟      
                             ▚▐▙  ▗▀▘                     ▀▚       ▀█     
                             ▝▚▟ ▄▘                         ▚▖    ▐▄▀     
                              ▐▌█ ▀                  ▄▖      ▝   ▐▙▀      
                              ▐▛▘                      ▀▚     ▚  ▗▟▖      
                             ▗▘ ▞   ▐                    ▝▄    █ ▐▛▌      
                            ▄▘▞▘    ▐        ▖   ▗         ▚    ▘▖▗       
                           ▐▀▐ ▗    ▐     ▖  ▘    ▌         ▚▖  ▝██       
               ▄▖          ▘▄▘▗▖     ▌    ▌  ▝▘▖  ▝▚      ▄ ▚▞▖  ▚▞▖      
       ▐▀▀▀▀▀▀▘▌          ▝▐  ▌   ▗ ▐▌    ▌   ▐▘    ▖      ▌ ▐▚  ▝▚▚      
       ▐       ▌         ▝▘▌ ▐▘   ▖▐▌▗█   █   ▝█▄▄▀▀▜▀▀    ▝▖ ▚█  ▝▞▄     
       ▐      ▗▀▘▄       ▚▟  ▝    ▛▛▜▞█▖  █▄  ▐▀█▖   █▚     ▘ ▝▄▌  ▚▀▖    
       ▐      ▐  ▐      ▐▞▜  ▌   ▄ ▘ ▝▀▙  ▐ ▖  ▙▀▟▖   ▛▖    ▐▌ ▀█▝▘▐▄▗    
       ▝      ▞  ▛▀▄    ▙▗▖  ▌   █▐  ▝ ▜▖ ▐ ▐  ▙█▛▀▀██▙▌     ▗  ▜▌▐ █▌▚▖  
       ▌      ▌ ▗   █▌  ▌▐▌  ▌   █▞▟█▀▄▝█▌▝█ ▚▄▚█    █▜█▌    ▐  ▐▚▖▖▀▞▞▚  
       ▌      ▘▗▞  ▗▘  █ ▐▌  ▌  ▐ ▛▌▐  ▌▚▞▖█ ▝▜▐█     ▟▛▚    ▐▖  ▟▌▚ ▌▐▌▚ 
       ▌     █ ▝▘ ▄▘   ▀ ▐▌  ▌  ▗ ▌▜▌▌ ▌  ▝▄▌  ▚█▌   █▀▌▐    ▐▚  ▌▗▐ ▚ ▝▖▀▖
       ▌     █ ▌ ▗▀      ▝▘  ▗  ▐█▜  ▌ ▐    ▚   ▀▙   █ ██    ▝▟█ ▌ ▝▄▐  ▝▄▝
            ▗ ▐  ▞        ▐  █  ▐█▐  ▐ ▐     ▘   ▐▄▄▞  ▐▌▖  ▐▌█ ▌▘  █▐▖   ▚
            ▐ ▝ ▐         ▝▖ ▌▌ ▐█▌▌ ▝▀▀               █▌▌  ▙▖██▐   ██▚▖  
      ▗     ▐ ▌▐▌          ▘ ▌▟▌▐ ▌▌                   ▜▌▌ ▞▝▜▛█ ▟▌ ███▛▖ 
     ▗▟▖    ▐▄▘▌           ▐ ▙▘▐▐▀▘▙▖    ▗             ▟█ ▄▌▙▟ ▀▌▀▘ ██▝▚▝▄
    ▄▛▚ ▀▖  ▐█▐             █▛▗▟▚▄ █▌    ▝            ▚▐█▞ █▞▘  ▌   █▐ ▝▄█
   █ ▗▖▚ ▛  ▐█▌             ▄▙▜▙▛█▀▚▟▖     ▄▄▄▄▄      ▐▜▛▚█▀▌   ▌   █▐  ▝▄▚
  ▞   ▐▝▄▘▜███▘            ▗▄▀▞▜▌ ▘▐▌▐▄    ▀▌  ▐      ▝    ▛    ▌   █▐    ▜
 ▗▘ ▞▗▖▌▀▌▝▘               █  █▌▌  ▐▌ █▚    ▘  ▐      ▌    ▌▗▖  ▌  ▗▀▖    
▗▖  ▌▝▚▘ ▚ ▝              ▐▘ ▗██   ▐▌▗▀ ▚▄     ▘    ▄▀▘   █ ▐▌  ▌  ▐▄▐▖   
▝▚  ▝▀▀ ▄▘  ▚             ▝  ▐▜█   ▌ ▟ ▘  ▚▄      ▖▝ █    ▀ ▞▜  ▘  ▌ ▜█▙  
 ▝▖  ▝▀▄▀   ▐                ▐▄▞   ▌▗▌█    ▄▛▄▄▄▀▘  ▗▀   ▐  ▌▝ █  ▐▖  ▐▛▙ 
  ▚    ▝▄   ▖                ▝▜▌  ▗▙▞▙▀   ▗█▗▄▄▌    ▐    ▞ ▐▐▌ █ ▐█▚  ▝▚▝█▖
  ▝▄        ▌                ▄▘▐▀▀▛▞▚▜   ▗█ ▘  ▌    ▞    ▌ ▛▖ ▐ ▗▜███   ▝▀▟
    ▖      ▗▚                ▐▜▌  ▙▌▐▞ ▀▘    ▗▟▘  ▗▞█▄▄▄▄▚█▚▘▗▛ ▞ ▗▝ ▚    ▗
    ▐      ▐ ▄              ▄▘  ▀▀▐▗▟▌       ▌    ▌▗▘ ▞  ▙▀▟▗▟▚▀  ▐█▀▖▚▖  
     ▌    ▗▞  ▖            ▗▀▖    ▐▟▙▌      ▗▖   ▗▀▀▝▀▙▄▟▘ ▘▜█▖    ▛▄▟▞▜▖ 
     ▐▌   ▐▌ ▄▌            ▞█     ▐▝▜▌      ▐▝▘  ▛▖     ▝   ▟▛▝█▙▄▖▗▀▀▞▚▐▄
      ▗   ▞▘ █▐          ▗▞▞      ▞▐▛▌      ▖  ▗▀▗     ▐▌  ▗▚▄▀▄▞▞▘▝▄▗▌▝▖▀▙
     ▐▛▖ ▗▘ ▗▄▛▖         ▞▀       ▌▝▜▌      ▌ ▗▘ ▌    ▖▝▘  ▄▜█▄▀ ▝▚ ▀▞▘ ▝▄▜
     ▝▘▌ ▞    ▘▌       ▄▞▞▘     ▘█ ▐▛▌      ▌▐▛▗█     ▌▌ ▗▀▚▛▘    ▝▖ ▌▚▄▖ █
     ▌ ▜▄▘     ▐▌    ▗▞█▞      ▝▐  █▙▌      ▙▚▄▀▄    ▄▚▗▟▜▄▞       ▌ ▝▄▞▚ ▝
    ▗▘ ▐▀       ▐▖ ▗▟▛▀█      ▞▚▘ ▞▗▞▚    ▗▄▘▛▚▜     █▐▛▚▘            ▚▖▟ 
    ▐  ▞  ▗▄▖    ▜▀▘  ▞      ▝▗▟▄█ ▝▚▟ ▗▟▛▗▀▞▐▛▖    ▝█▙▀▀          ▐  ▝▜▝▄
    ▞ ▗▘  ▐▌▌     █  ▗▘     ▄▚█▛▛    █▀▘▌ ▟█ ▞▚     ███            ▝   ▝▖ ▚
    ▌ ▝   ▌▐       ▚▗▖     ▞▄▀▛▜     ▘  ▙▄█ ▗▚▞    ▐▞██▌           ▌    ▚ 
   ▄▘▐▌  ▗▚▞       ▝▌    ▗▞▞█▞▐▌        ▌▐▘▀█▝▘   ▗▞▌▀▛           ▗▌     █▟
   █ ▌   ▝█▌       ▗    ▗▚▞▌▀▌▐▌       ▞▐▛  ▌▌   ▐▀▜▄█▄▖         ▗▞▌      ▙
   █▗              ▞    ▞▌ ▚ ▚▐▌      █▘▝▘ ▄▘▘   ▟▚▖▐▄▖▝▀▄      ▗█▌▐      ▝
  ▐ ▝              ▌  ▗▀▞ ▝▟▄▝▟▙     ▞ ▘   █▐    ▌▀▘▟▄▟   ▀▖    ▟ ▐▄▄     
  ▐ ▌  ▗▄▄        ▄   ▛▄▘   ▀▖▚▞▖   ▝ ▀    █▐  ▗█▚▄▞▐█     ▝  ▗██  ▐▄▖    
  ▝▄▘  ▐ ▌        █  ▐▐▀▌     ▀▜▚ ▗▞▘▐    ▐ █▐▛▘▀▄▌  ▄▌   ▄ ▌▗▘█▀  ▐ ▐    
  ▌█   ▞ ▘          ▟█▌ ▌     ▐▙██▀  ▌    ▐ █▘  ▄▘    ▟  ▐ ▌▐▌ █▄   █ ▙▖  
  ▙▀   ▌█        ▐ ▗▜▛▌ ▘      ▗▞   ▐     ▐█▘  ▛      ▝▖  █▐▟▛ ██    ▀▞▚  


It's only 2 colors, but 4x the resolution.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List