You are not logged in.

#1 2011-11-11 03:20:58

eqyiel
Member
From: Australia
Registered: 2011-09-29
Posts: 9

DIY ASCII animation splash screen!

I don't startx automatically, but I like flashing colours and ASCII art. Hence, I decided to make some ascii animations to spruce up my tty at logon.

Obligatory video link (watch in HD, the frames flash by too fast to look good at 360p)

Here's how I did it, there are probably better ways, but I'm here to learn as well.  Please share with me your ineffable wisdom with me.  Limitations: requires a directory full of .jpegs, only works from sysinit_end to shutdown_start unless you hard-code the art into the function file a la 2.b (due to parsing of the jpeg files in a mounted dir).

0. Install jp2a from the AUR.

1. Use ffmpeg to extract .jpeg frames from a small portion of the video

ffmpeg -i foo.avi -t 40 -ss 00:00:00.00 foo-%d.jpeg

Where -t is the duration to be extracted in seconds, and -ss is the point at which to start recording (hh:mm:ss.ms).  Doesn't have to be .avi!

2a. the easy way

For startup / shutdown splashes, create a file in functions.d:  /etc/rc.d/functions.d/animation

Modify this here to include your directory with the pictures and the maximum number of lines your tty can display without distorting the output.

add_hook sysinit_end evasplash1
add_hook shutdown_start evasplash2

}
evasplash1() {
        for f in /home/eqyiel/scripts/evasplash1/*.jpeg
                do
                jp2a --colors --height=55 $f
                echo -ne '\033[55F'
                sleep 0.01
        done
        echo -ne '\033[55E'
}
evasplash2() {
        for f in /home/eqyiel/scripts/evasplash2/*.jpeg
                do
                jp2a --colors --height=55 $f
                echo -ne '\033[55F'
                sleep 0.0001
                done
        echo -ne '\033[55E'
}

Pay special attention to --height and the two escape codes, \033[55F and \033[55E.

--height is the maximum height in lines of your tty
'\033[55F' means "position the cursor 55 lines above where it is right now or at the top of the screen if there are <55 lines to the top"
'\033[55E' means "position the cursor 55 lines below where it is right now or at the bottom of the screen if there are <55 lines to the bottom"
The escape codes must be expressed in literals and echo needs the -e switch to enable interpretation of backslash escapes.

You may want to test this out in a shell script before rebooting your computer, a la:

#!/bin/bash
while [ 1 ]
do
        for f in /home/eqyiel/scripts/evasplash1/*.jpeg
                do jp2a --colors --height=55 $f
                echo -ne '\033[55F'
                sleep 0.01
                done
        echo -ne '\033[55E'

done

For a login splash, just add the code to the end of your /etc/profile:

for f in /home/eqyiel/scripts/dbsplash/*.jpeg
do jp2a --colors --height=55 $f
echo -ne '\033[55F'
sleep 0.0001
done
echo -ne '\033[55E'

2b. the hard way (for the truly masochistic)

Use jp2a to extract raw ANSI data from the .jpeg frames you have created:

for f in *.jpeg; do jp2a -v --colors --height=55 $f > $f.txt; done

This will create a whole bunch of files full of ANSI escape sequences.  Now, open up your preferred editor and import the files one by one, stitching them together in this fashion:

#!/bin/bash

while [ 1 ]
do
        sleep=.1
        echo -ne '╔═══╗
║*  ║
║   ║
║   ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║ * ║
║   ║
║   ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║  *║
║   ║
║   ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║   ║
║*  ║
║   ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║   ║
║ * ║
║   ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║   ║
║  *║
║   ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║   ║
║   ║
║*  ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║   ║
║   ║
║ * ║
╚═══╝
'
        sleep $sleep
        echo -ne '\033[5F╔═══╗
║   ║
║   ║
║  *║
╚═══╝
'
        echo -ne '\033[5F'
        sleep=.1

done

You'll need to transpose it to the notation in functions.d, with the functions() {listed like this}. I'm thinking there's an easier way to do this with the directory full of .txt files, like a clever `cat`, please tell me how if you know.

Note:
The "archlinux" /etc/issue prompt was made by Ali Gündüz or "gnufs" as he is known on this board.
I played no part in the creation of Dragon Ball or Evangelion, I only extracted a few frames from each to test this idea.
See:
http://aligunduz.org/
https://bbs.archlinux.org/search.php?ac … r_id=26003
Inspired by:
https://bbs.archlinux.org/viewtopic.php?id=50845
http://www.youtube.com/watch?v=cfuVLYysY2Q
http://www.youtube.com/watch?v=3shEw8UWETA

Offline

#2 2011-11-11 16:30:19

guelfi
Member
From: /home/guelfi
Registered: 2011-07-01
Posts: 111

Re: DIY ASCII animation splash screen!

Wow, that looks really cool, even if it needs a bit work. Now I just need a nice video to play big_smile

Offline

#3 2011-11-11 18:01:09

eqyiel
Member
From: Australia
Registered: 2011-09-29
Posts: 9

Re: DIY ASCII animation splash screen!

Please share your creations and script if you decide to try it!  "recordmydesktop" in community + arch virtualbox is great for grabbing tty video.

Offline

Board footer

Powered by FluxBB