Skip to content

Latest commit

 

History

History
311 lines (200 loc) · 14.8 KB

README.md

File metadata and controls

311 lines (200 loc) · 14.8 KB

Color Static (C++ Edition)

Random color animations by character frames for fun in the command line.

ColorStatic Logo

Twitter URL


About

Description and information

Fun command line program to generate a random colorful "Static"/"Matrix" (like?) style animation in a command line.

This is a C++ version of the Bash version I wrote.

This is a first version and a vague idea, I plan to completely re-write this in a 2nd version.

This program displays random color animations by character frames for some fun in the command line. The default frames provided by the program, especially at a low font size, looks like old television static (to me at least).

There are several options and cool things you can do; change speed (delay), use all kinds of character frames, marquee text, change width (COLUMNS) and height (LINES) (use width to do the math to adjust for strings in your frames so that your scroll-back history doesn't extend too far.

Screens of basic demo

Click to toggle screenshot previews:

One frame scrolled (zoomed) out to tiny font.
One frame scrolled (zoomed) out to small font.
One frame scrolled (zoomed) out to small medium.

Motivation

Some time ago (more than a few handfuls of years?) I ran across this tv static style loop example in a script and another generic matrix (with a little 'm') style script and I have since been fascinated with fun, quirky, and geeky things in the command line; no matter how redundant and time wasting.

This was inspired by my Bash script version as I wanted to make it faster and more cross-platform (only cross terminal for now) and so I thought I'd write it in C++.

Disclaimer

I did not come up with this initial concept of looping this command; this is, of course, inherit in the printf command and only the creators can claim it and I'm really not sure who to give credit to; though I would gladly do so.

IF YOU HAVE INFORMATION ON WHERE THE CONCEPT OF THIS ORIGINAL IDEA CAME FROM THEN PLEASE LET ME KNOW SO I CAN GIVE PROPER CREDIT, because I still can't remember where I originally seen it.

Please create an issue here and I will add an accreditation section.

Having said that, 99.99% of the code and everything here is my creation.

MD5 Information

This information is generated in a GitHub Action immediately after the successful build of this project.

Current Linux MD5

Linux MD5

Current Debian MD5

Debian MD5

Code Quality

This is to help guide me as a spend time re-factoring (then finally re-writing) this. An A is great, but I'd much prefer an A++ (pun intended).

Name Code Quality
colorstatic @ CodeFactor.io colorstatic Code

Usage

Various Tips

  • Frames can be comma delimited lists of anything as long as your terminal can display your list; from single characters to unicode strings.
  • If your frames are longer than single characters then it is a good idea to set the --column width to the size of the current terminal width: $COLUMNS minus the width of your longest strings length in your frames list minus 1 (sometimes), so for example: colorstatic -f 'word,word2, , , ' --columns $((($COLUMNS - 5) - 1)) in Bash shell so that no words ever extend over the edge of screen to overextend the scroll-back history way too far.
  • The more repeat instances of spaces (or any other character or string for that matter) in the Frames list will give a better likelyhood of seeing spaces (or that character or string); so -f 'A, , , , , ' would make it 5 times more likely you'd see a space rather than an 'A'.

Environment

This is a command line tool for use in command lines in Linux for now, but I plan to make it cross-platform for Windows and MacOS as well in version 2.

Install or portable

This can be installed to /usr/bin with the .deb Debian package installer that also provides Bash Completetion for options/switches and some hi-color icons if for if you want to create a .desktop shortcut file. I have also provided a portable executable pre-compiled binary that you can place and run from anywhere you like. You can also compile and install from the source folder (linux) with the provided make file with a very simple make command: make && sudo make install && sudo make clean to build, install, and clean up the source folder.

Files

All source packages, .deb package installer, and pre-compiled binary can be found at the current Release Page.

Examples

The examples are better viewed in my YouTube demonstrations since they are animated, but here's a few that shows what it will look like to type them out. This is a non-exhaustive list.

Basic Execution

Basic execution with all defaults. This method allows it to change character width and height upon terminal resizing.

 $ colorstatic

Quarter Screen with a Delay

Set it to a quarter of the current terminal size and slow it down.

 $ colorstatic --lines $((LINES/2)) --columns $((COLUMNS/2)) --delay 500
 # or
 $ colorstatic -l $((LINES/2)) -c $((COLUMNS/2)) -d 500
 # In a script you should use `$(tput lines)` and `$(tput cols)`
 # in place of LINES and COLUMNS

Using Alternative Characters

By default the displayed characters will be: █,░,▒,▓, , but you can use whatever string or array of characters you like as long as you can display them correctly in your terminal.

You can do this with the -f,--frames switch.

 $ colorstatic --frames '\,/'
 # or create array of all decimal ints and lower and upper
 # case Latin based characters 
 $ chars="$(printf '%d,' {0..9};printf '%s,' {a..z} {A..Z})"
 $ colorstatic --frames "$chars"

Help Screen

 $ colorstatic --help
                                                  
 USAGE: colorstatic [SWITCH [PARAMETER]...]...    
 'ColorStatic' - Random color animations by       
 character frames in the command line. Press      
 [Enter] or [Ctrl+C] to quit this program.        
                                                  
 SWITCH: optional                                 
     -h, --help    This HELP message.             
     -d, --delay   Delay between frames in        
                   milliseconds.                  
     -c, --columns Force number of columns.       
     -l, --lines   Force number of lines.         
     -f, --frames  A comma delimited string or    
                   array of characters to be used 
                   as random frames. Defaults to: 
                   ' ,█,░,▒,▓'                    
     -m, --mono    Monochrome mode, disable       
                   random colors.                 
                                                  
 PARAMETER:                                       
     Delay      Number in integer milliseconds.   
     Columns    Number in integers.               
     Lines      Number in integers.               
     Frames     String array of characters        
                delimited by a comma; e.g.:       
                ' ,#,@,^,*' or:                   
                "${BASH_ARRAY[@]}" etc...         
                                                  
 ERRORS:                                          
     1   Error in delay parameter.                
     2   Error in columns parameter.              
     3   Error in lines parameter.                
     4   Error in frames parameter.               
                                                  

Find video demonstrations with versions of these examples in the list of videos below in the Media section: YouTube Videos.


Media

Screenshots

Help Screen

Help Screen

Main Static

Main Static

Latin Based Chacters and digits.

Latin Based Characters

Linux Bash

Linux Bash

Tiny Font Size

Tiny Font Size

Small Font Size

Small Font Size

Medium Font Size

medium Font Size

YouTube Videos

Some of these are for the Bash version, but it's essentially the same thing just the new version is faster.

Thumbnail Link - Newest to Oldest
Demo 4 https://www.youtube.com/watch?v=nB1RVuVL5CI
Demo 3 https://youtu.be/GyNQpkrmv50
Demo 2 https://youtu.be/-R8tEdHDCpE
Demo 1 https://youtu.be/jSZO-oy7xqI

License Info

License Excerpt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


Support Me If You Like

If you like this project and care to donate to my PayPal:

PayPal Donation

Or Buy Me A Coffee if your prefer:

Buy Me A Coffee