Skip to content

Commit

Permalink
Adds screenshot generator script and screenshots
Browse files Browse the repository at this point in the history
Adds a script to generate screenshots and screencasts.
Integrated two of such screenshots into the readme.
  • Loading branch information
hoijui authored and abishekvashok committed Nov 4, 2017
1 parent be5567e commit 0cc3b18
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -32,6 +32,16 @@ open issues and if possible solve them in PRs via Github.
_Note: cmatrix is probably not particularly portable or efficient, but it wont hog
**too** much CPU time_

### Captures

#### Screenshots

![Special Font & bold](data/img/capture_bold_font.png?raw=true "cmatrix -bx")

#### Screencasts

![Movie-Like Cast](data/img/capture_orig.gif?raw=true "cmatrix -xba")

### Maintainers
- Abishek V Ashok (@abishekvashok) <abishekvashok@gmail.com> [Core]

Expand Down
Binary file added data/img/capture_bold_font.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/img/capture_orig.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions takeScreenshots
@@ -0,0 +1,77 @@
#!/bin/bash
# Produces a bunch of `cmatrix` screenshots and screencasts.
# This script requires X and the following:
#apt-get install rxvt byzanz

# NOTE We use rxvt, as we can get a screenshot without fuss (scrollbars, menu, ...),
# it is fairly simple,
# and it supports X fonts (unlike xterm and uxterm).
TERM_EMULATOR_BASE="rxvt +sb"

CAPTURES_DIR="data/img"

# Function to take a single cmatrix screenshot (takes about 3.5s to execute)
# or optionally, a screncast of choosable length.
function captureCMatrix()
{
CAPTURE_FILE="$1"
CMATRIX_OPTIONS="$2"
# If 0 (default if no 3rd param is given),
# we make a screenshot instead of a screencast.
SCREENCAST_DURATION="${3:-0}"

if [ ${SCREENCAST_DURATION} -gt 0 ]
then
let KILL_DELAY="${SCREENCAST_DURATION} + 1"
CAPTURE_FILE="${CAPTURE_FILE}.gif"
else
KILL_DELAY=3
CAPTURE_FILE="${CAPTURE_FILE}.png"
fi
WINDOW_TITLE="CMatrix capture ${CAPTURE_FILE}"

# NOTE the "-PIPE" prevents output of the "Terminated: ..." message
( cmdpid=$BASHPID; ( sleep ${KILL_DELAY}; kill -PIPE $cmdpid ) & exec ${TERM_EMULATOR_BASE} -name "${WINDOW_TITLE}" -title "${WINDOW_TITLE}" -e bash -c "
if [ ${SCREENCAST_DURATION} -gt 0 ]
then
# Take screencast (animated GIF)
# Get this windows X-window-info
myXwininfo=\$(xwininfo -name \"${WINDOW_TITLE}\")
# Extract location and size
read X < <(awk -F: '/Absolute upper-left X/{print \$2}' <<< \"\$myXwininfo\")
read Y < <(awk -F: '/Absolute upper-left Y/{print \$2}' <<< \"\$myXwininfo\")
read W < <(awk -F: '/Width/{print \$2}' <<< \"\$myXwininfo\")
read H < <(awk -F: '/Height/{print \$2}' <<< \"\$myXwininfo\")
# Record a screencast as gif
byzanz-record -c --delay=0 --duration=${SCREENCAST_DURATION} --x=\$X --y=\$Y --width=\$W --height=\$H "${CAPTURE_FILE}" &
else
# Take screen-shot (PNG image)
# Take screenshot in 2 seconds
( sleep 2 ; xwd -nobdrs -name \"${WINDOW_TITLE}\" -silent | xwdtopnm 2> /dev/null | pnmtopng 2> /dev/null > ${CAPTURE_FILE} ) &
fi
# Run cmatrix until the process gets killed
cmatrix ${CMATRIX_OPTIONS}
" )
}

CMD_CS="captureCMatrix"
CAPTURE_FILE_BASE="${CAPTURES_DIR}/capture_"
mkdir -p "${CAPTURES_DIR}"

# Capture a screen session ("video"/animated GIF)
${CMD_CS} "${CAPTURE_FILE_BASE}orig" "-xba" "5"
${CMD_CS} "${CAPTURE_FILE_BASE}rainbow" "-xbar" "5"

# From here on, we take several screenshots with different arguments.
${CMD_CS} "${CAPTURE_FILE_BASE}default" ""
${CMD_CS} "${CAPTURE_FILE_BASE}bold" "-b"
${CMD_CS} "${CAPTURE_FILE_BASE}bold_font" "-bx"
for color in green red blue white yellow cyan magenta black
do
${CMD_CS} "${CAPTURE_FILE_BASE}bold_C_${color}" "-b -C ${color}"
done
${CMD_CS} "${CAPTURE_FILE_BASE}bold_rainbow" "-b -r"

0 comments on commit 0cc3b18

Please sign in to comment.