Happy New Year Greetings in Brainfuck Style

    I would like to congratulate the readers of the blog Happy New Year. But not just like that, but by writing congratulations on Brainfuck.

    The first congratulation displays a message in the form of ASCII-Art.

    image


    Because To display the text, a limited dictionary of 5 characters was used, including line break, then this dictionary is formed at the beginning of the program, and then we move the memory pointer through the dictionary and display the characters. Thus, it was possible to sufficiently reduce the size of the program. It remains only to draw up the text of the program in the form of a New Year's greetings.
    The text of the resulting program can be viewed here .


    Appetite, as they say, comes with eating. Having spent about forty minutes on the first congratulation, I realized that this would not be enough for me, especially since the implementation of the congratulation turned out to be banal. Therefore, I set about my second congratulation. I wanted to make an animated card. To implement the idea, we will use ESC-sequences, which allow us to turn a text screen into almost a graphic station.

    The video shows the result of the program.



    If you turn on YouTube’s snowflakes while watching, the demonstration will become even more spectacular.

    Here also at the beginning a dictionary of characters is formed, from which the image of the Christmas tree is derived. Then in the center of the screen the Christmas tree is "drawn".

    Next, let's deal with an iridescent garland. The position of the "bulbs" is static, so we will simply display them in different colors. A total of 7 colors are used. In escape codes, their numbers are in order. Therefore, each new character will be displayed in color, following in order. Upon reaching the senior number, we begin numbering from the beginning. If we begin to output the “bulbs” of the garland, shifting the color number by 1 from the previous cycle, we get the effect of running lights.

    The text of the program is sufficiently documented so as not to dwell on the detailed description of the program. View the program code here .

    PS. For those who do not have a terminal with support for ESC sequences, I recommend downloading the DosBox emulator and running a precompiled program there . The archive also contains a compiler for Brainfuck.


    Upd . It was thought, if not to organize a mini contest in the framework of the blog "abnormal programming" for the most incredible New Year's greetings? There is only one condition - the congratulation should correspond to the subject of the blog. The winner is determined by the number of votes cast for a decision. There are no prizes besides universal honor and respect.

    Also popular now: