Monthly Challenge - #2 Februari 2015 - Console Canvas

Monthly Challenge - #2 Februari 2015 - Console Canvas

Basic Rules:

-Use the forum image uploader to prevend dead images after a few months.

-No libraries unless stated otherwise.

-You have to create it yourself, this means not uploading someone else his code cause it fits the challenge. However, you can be inspired by somone else his code.

-You have to share your code so others can see how it works.

-If it uses data input then you have to share the data as well (please keep it small).

-The change of crashing should be minimal.

Basic Tips:

-This is processing, so instead of "hello world" it's hello visual output. So try yo make it visual appealing.

-There is no code limit, but this does not mean 5000 lines of code is a good idea. Others might want to learn from your code. It might be much more helpfull to do something really cool in a pretty basic sketch. Less is more. However, if you have a cool idea, do whatever it takes.

-Post videos (and screenshots) if it has motion.

Previous Editions:

#1 Januari 2015 - Thread Threat http://forum.processing.org/two/discussion/8826/monthly-challenge-1-januari-2015-thread-threat

=============================

#2 Februari 2015 - Console Canvas

Compared to the previous edition I think this one is a bit easier for most people. You have to use the console as a canvas. Animations are a plus.

If you want red letters use:

System.err.println("something");

Be aware that the order can be buggy if you use System.err.println(); I think you can prevent this with using delays.

Comments

  • edited February 2015

    I'll start. (by the way, what are these for? are you collecting them or anything?)

    A quine is a program that prints itself to the console. This is tricky, because that means the program must somehow contain itself without creating some kind of infinite nest.

    If you've never tried to write a quine program, I recommend trying to do it before continuing reading!

    Anyway, here is a quine done in Processing, adapted from the Java example here:

    void setup(){
        char q = 34;      
        String[] l = {    
        "void setup(){",
        "    char q = 34;",
        "    String[] l = {",
        "    ",
        "    };",
        "    for(int i = 0; i < 3; i++)",
        "        println(l[i]);",
        "    for(int i = 0; i < l.length; i++)",
        "        println(l[3] + q + l[i] + q + ',');",
        "    for(int i = 4; i < l.length; i++)",
        "        println(l[i]);",
        "}",
        };
        for(int i = 0; i < 3; i++)
            println(l[i]);
        for(int i = 0; i < l.length; i++)
            println(l[3] + q + l[i] + q + ',');
        for(int i = 4; i < l.length; i++)
            println(l[i]);
    }
    
  • edited February 2015

    Quines are easy! Here's mine:

    That program actually won the "worst abuse of the rules" prize in the International Obfuscated C Code Contest.

    Edit: the post I'm replying to seems to have been deleted! :c

  • edited February 2015

    Quines are easy! Here's mine:

    Here's another good one:

    Syntax error, maybe a missing semicolon?
    
  • (by the way, what are these for? are you collecting them or anything?)

    It's just for fun. And I hope that the whole series turn into some nice collection of inspiration for people. The current direction is to have things a litle 'outside the box'. Hence the treading in an unusual way and now the console as canvas.

  • edited February 2015

    This is a combination of challenge one and two ( hope that is allowed)

    The presence of the threads is to allow different functions to run on the same line and maintain to their rules as they print. Also adding a slight animated effect

    https://github.com/illestknock/ChallengesforProcessing/blob/master/First&Secondchallenge.pde

  • Sure it is :) The rules are more guidelines.

  • This idea of Challenges was a great concept. I will try submitting something else later in the month

  • Yeah, I have an idea for this challenge as well. Now I need to find time :)

    Ideas for new challenges can be posted here: http://forum.processing.org/two/discussion/comment/33611/#Comment_33611

  • And here's an Ouroboros program. The output of this Processing code is Java code, and the output of that Java code is this Processing code.

    void setup(){
        char q = 34;
        String[] l = {
        "    ",
        "=============<<<<<<<< Processing Code >>>>>>>>=============",
        "void setup(){",
        "    char q = 34;",
        "    String[] l = {",
        "    ",
        "    };",
        "    for(int i = 15; i <= 20; i++)",
        "        println(l[i]);",
        "    for(int i = 0; i < l.length; i++)",
        "        println(l[0] + q + l[i] + q + ',');",
        "    for(int i = 21; i < l.length; i++)",
        "        println(l[i]);",
        "}",
        "=============<<<<<<<< Java Code >>>>>>>>==========",
        "public class Quine",
        "{",
        "  public static void main(String... args )",
        "  {",
        "    char q = 34;",
        "    String[] l = {",
        "    };",
        "    for(int i = 2; i <= 4; i++)",
        "        System.out.println(l[i]);",
        "    for(int i = 0; i < l.length; i++)",
        "        System.out.println( l[0] + q + l[i] + q + ',' );",
        "    for(int i = 5; i <= 13; i++)",
        "        System.out.println(l[i]);",
        "  }",
        "}",
    
        };
        for(int i = 15; i <= 20; i++)
            println(l[i]);
        for(int i = 0; i < l.length; i++)
            println(l[0] + q + l[i] + q + ',');
        for(int i = 21; i < l.length; i++)
            println(l[i]);
    }
    
  • And all I could come up with is

    println("itself");

  • Here is the code that can be seen through the github link. It uses the threads from the first challenge and incorporates the console canvas idea from the second one.

    void setup() {
      thread("printingtriplestars");
      thread("randomcharacters");
      size(255*3, 255*2);
    }
    
    void draw() {
      delay(50);
      background(mouseX/3, mouseY/2, random(255));
    
      char numbersign = '#';
      char slash = '/';
      char plus = '+';
      char minus = '-';
      int counter = 0;
    
      //using the normal window as a coordinate system to dictate what character will be printing and adding tabs to control spacing
      if (mouseX > 510)
      {
        print("\t", numbersign);
      }
      if (mouseX > 255)
      {
        print("\t", plus);
      }
      if (mouseY < 255)
      {
        print("\t", minus);
      }
      if (mouseY < 385)
      {
        print("\t", slash);
      } 
      if (mouseX < mouseY)
      {
        print("\t", "\t");
      } else
      {
        print("\t", "\t", "\t");
      }
    } 
    
    //prints the triple stars
    void printingtriplestars() {
      println("***");
      delay(50);
      print("\t");
      printingtriplestars();
    }
    
    //uses the modulo sign so it can keep going through the array even when has pass
    void randomcharacters()
    {
      char rotational [] = {
        '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '/', '*'
      };
      int counter = 0;
      for (int i=0; i < 1000; i++) {
        print("\b" + rotational[counter]);
        delay(50);
        counter =  ++counter % rotational.length;
      }
    }
    
  • This is small code that will constantly print out the chosen value in the array. Random functions makes it look cryptic

    void setup()
    {
    
    }
    
    void draw()
    {
      char rotational [] = {
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'
      };
      float ranx = random(11);
      int  randx = round(ranx);
      print("\t", rotational[randx]);
    
    }
    
  • Just blatantly ripped off one of the examples.

    /*
     * Upon start, it prompts a file browser to select an image which is then "printed" to the console.
     * Don't let this image be null!
     *
     * Idea from the AsciiVideo example in the Video library of Processing by Ben Fry.
     * by CMB
     *
     */
    
    
    
    
    
    int ideRes = 1348;    //The x size of the IDE console output, in pixels (so it fits nicely)
    int charSize = 7;     //the x width of the IDE letters
    
    boolean resizeImage = true;    //Should the image be resized?
    int newSizeX = ideRes/charSize;
    int newSizeY = 0;    //Put to 0 to maintain aspect ratio
    
    
    
    
    String letterOrder =
    " .`-_':,;^=+/\"|)\\<>)iv%xclrs{*}I?!][1taeo7zjLu" +
    "nT#JCwfy325Fp6mqSghVd4EgXPGZbYkOA&8U$@KHDBWNMR0Q";
    char[] letters;
    
    
    void setup()
    {
      selectInput("Select an image.", "imageSelected");
      letters = new char[256];
      for (int i = 0; i < 256; i++) {
        int index = int(map(i, 0, 256, 0, letterOrder.length()));
        letters[i] = letterOrder.charAt(index);
      }
    }
    
    void imageSelected(File file)
    {
      if (file == null)
      {
        String message = "This file was null!";
        int p = 0; 
        boolean direction = true;
        while (true)
        {
          delay(250);
          println();
          for (int i = 0; i < message.length (); i++)
          {
            print(i==p? message.charAt(i) : " ");
          }
          if (direction) p++;
          else p--;
          if (direction && p >= message.length()) direction = false;
          if (!direction && p <= 0) direction = true;
        }
      }
    
    
      PImage img = loadImage(file.getAbsolutePath());
      if (resizeImage) img.resize(newSizeX, newSizeY);
    
      img.loadPixels();
      for (int j = 0; j < img.height; j++)
      {
        for (int i = 0; i < min (img.width, ideRes/charSize); i++)
        {
          print(letters[(int) brightness(img.pixels[i+img.width*j])]);
        }
        println();
      }
    }
    
  • Nice one colouredmirrorball.

    I wan't to do something similar but with smooth edges like this:

    .d88b. db d8b db d88888b d8888b. d888888b db db db db d888888b .d88b. d8888b. .8P Y8. 88 I8I 88 88' 88 8D~~88~~' 8b d8' 88 8888' .8P Y8. 88 8D 88 88 88 I8I 88 88ooooo 88oobY' 888bd8' 88 88 88 88 88 88oodD' 88 88 Y8 I8I 88 88~~~~~ 888b 88 88 88 88 88 88 88 88~~~8P d8' 8b d8'8b d8' 88. 8888. 88 88 88b d88 .88. 8b d8' 88Y88'Y8 8b8'8d8' Y88888P 88 YD YP YP ~Y8888P' Y888888P `Y88P' 88

    I think the forum will fuck this one up :)

  • Hey- where's the March challenge? :p

  • Thx for pushing me :) I will put it up today. I think march topic is nicer.

Sign In or Register to comment.