Compare commits
No commits in common. "7b11d014af30ecb8a830b8a2a56aca4130ec2c0b" and "f5ec4fe4014e90f7369613147efe71fec1492890" have entirely different histories.
7b11d014af
...
f5ec4fe401
2 changed files with 39 additions and 153 deletions
|
@ -26,8 +26,6 @@ pixelfloot was built during the 37c3. in its actual state, its just a mess. I ho
|
|||
- for drawing big areas, like 1280x720, use LARGE mode: `LARGE=true ./pixelfloot.sh floot images/xphg.jpg`
|
||||
- default field size are 64k lines. You can adjust it with LOLFIELDSIZE:
|
||||
`LOLFIELDSIZE=16000 LARGE=true ./pixelfloot.sh floot images/xphg.jpg`
|
||||
- drawing an gif file with proper animation: `LARGE=true ./pixelfloot.sh floot images/dancing_banana.gif`
|
||||
- Adjust the speed with FRAMETICKTIME in seconds: `FRAMETICKTIME=0.03 LARGE=true ./pixelfloot.sh floot images/shaking_cat.gif`
|
||||
|
||||
```shell
|
||||
$ ./pixelfloot.sh help
|
||||
|
@ -55,7 +53,6 @@ IPFLOOT(string), FLOOTPORT(int), USECACHE(bool), FLOOTFORKS(int)
|
|||
SIZE(int), TEXT(string), FONTSIZE(int), BGCOLOR(hex), COLOR(hex)
|
||||
BORDERCOLOR(hex), X(int), Y(int), X_MAX(int), Y_MAX(int), H(int), W(int)
|
||||
RESIZE(int), ALPHACOLOR(hex), BOUNCESTEP(int), LARGE(bool)
|
||||
ANIMATION(bool), FRAMETICKTIME(float)
|
||||
```
|
||||
|
||||
Running on my Ryzen 4700G with [wellenbrecher](https://github.com/bits0rcerer/wellenbrecher) 1280x720 and three workers,
|
||||
|
|
189
pixelfloot.sh
189
pixelfloot.sh
|
@ -10,16 +10,11 @@ test -z "$IPFLOOT" && IPFLOOT="130.185.104.31"
|
|||
test -z "$FLOOTPORT" && FLOOTPORT="1234"
|
||||
|
||||
########################################################################
|
||||
FNAME="$(echo $2 | sed -e 's/\..*$//' -e 's/^images\///')"
|
||||
IMGFILE="$2"
|
||||
# remove file extension
|
||||
FNAME="${2%.*}"
|
||||
# remove everything before the slash, so we get the filename without
|
||||
# path and extension
|
||||
FNAME="${FNAME##*/}"
|
||||
PPMFILE="$FNAME.ppm"
|
||||
HEXPPM="images/$FNAME.hexppm"
|
||||
PIXLIST="/tmp/$FNAME.pixlist"
|
||||
ANIFILE="/tmp/$FNAME"
|
||||
SHUFMODE="$3"
|
||||
|
||||
FLOOTSRUNNING=0
|
||||
|
@ -42,20 +37,7 @@ test -z "$BOUNCESTEP" && BOUNCESTEP=2
|
|||
# /dev/shm/foo to store frame counter
|
||||
#
|
||||
# GifFileFormat - gif, jpg, png || detect which fileformat IMGFILE is
|
||||
#test -z "$ANIMATION" && ANIMATION="false"
|
||||
#
|
||||
# loadLOL loads every single frame into an array field WHEN ANIMATION is true
|
||||
# loadLOL sets No of frames in LOLFIELDS
|
||||
#
|
||||
# flootworker looks in while loop which value in /dev/shm/frametick is.
|
||||
# /dev/shm/frametick contains which frame from LOL to draw.
|
||||
# function frametick() gets started in background when ANIMATION is true
|
||||
# and gets started before the flootworker get started
|
||||
# frametick writes the no of frame to draw into /dev/shm/frametick
|
||||
# to not draw too fast, there is a sleep in frametick which waits for
|
||||
# FRAMETICKTIME seconds. Values are float, down to lowest value 0.001
|
||||
# Only one of ANIMATION or LARGE can be true, not both.
|
||||
FRAMETOPICK_SHM="/dev/shm/pxlflt-frametopick"
|
||||
test -z "$ANIMATION" && ANIMATION="false"
|
||||
## END ANIMATION
|
||||
|
||||
|
||||
|
@ -66,13 +48,6 @@ declare -a PIXMAP
|
|||
declare -a LOL
|
||||
declare -a LOLPID
|
||||
|
||||
## TODOS
|
||||
#
|
||||
# - Put OFFSET into /dev/shm/ so each worker do not have to count OFFSET
|
||||
# for itself and we prevent worker from drifting apart when drawing.
|
||||
# - get dimensions of pic with "identify" (imagemagick part)
|
||||
# - get dimensions of the pixelflut board
|
||||
|
||||
|
||||
# colors for colored output 8)
|
||||
RED="\e[31m"
|
||||
|
@ -252,12 +227,6 @@ done
|
|||
|
||||
|
||||
convertimg() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
CONVERTFILE="$IMGFILE"
|
||||
else
|
||||
CONVERTFILE="$1"
|
||||
fi
|
||||
|
||||
if [ -n "$RESIZE" ]
|
||||
then
|
||||
|
@ -265,7 +234,7 @@ convertimg() {
|
|||
|
||||
fi
|
||||
|
||||
convert $CONVERTFILE $BORDER $RESIZE txt: | tail -n +2 | awk '{print $1 $3}' | sed -e 's/\,/ /' -e 's/\:/ /' -e 's/\#//' -e 's/^/PX /'
|
||||
convert $IMGFILE $BORDER $RESIZE txt: | tail -n +2 | awk '{print $1 $3}' | sed -e 's/\,/ /' -e 's/\:/ /' -e 's/\#//' -e 's/^/PX /'
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,24 +287,6 @@ xymode() {
|
|||
|
||||
}
|
||||
|
||||
frametick() {
|
||||
test -z "$FRAMETICKTIME" && FRAMETICKTIME=0.1
|
||||
#LOLFIELDS=12
|
||||
i=0
|
||||
while true
|
||||
do
|
||||
echo "$i" > $FRAMETOPICK_SHM
|
||||
if [ "$i" -gt $LOLFIELDS ]
|
||||
then
|
||||
i=0
|
||||
else
|
||||
i=$(($i+1))
|
||||
fi
|
||||
sleep $FRAMETICKTIME
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
flootworker()
|
||||
{
|
||||
while true
|
||||
|
@ -348,17 +299,6 @@ flootworker()
|
|||
do
|
||||
echo "${LOL[$i]}"
|
||||
done
|
||||
elif [ $ANIMATION ]
|
||||
then
|
||||
xymode
|
||||
echo "$OFFSET"
|
||||
echo "${LOL[$(<${FRAMETOPICK_SHM})]}"
|
||||
#~ i=0
|
||||
#~ while [ $i -le $1 ]
|
||||
#~ do
|
||||
#~ echo "${LOL[$i]}"
|
||||
#~ i=$(($i+1))
|
||||
#~ done
|
||||
else
|
||||
xymode
|
||||
echo "$OFFSET
|
||||
|
@ -379,52 +319,30 @@ checkfile() {
|
|||
|
||||
loadLOL() {
|
||||
|
||||
# when LARGE true, then we slize the large pixlist into smaller pieces
|
||||
# max 64k each one
|
||||
if [ $LARGE ]
|
||||
then
|
||||
# when LARGE true, then we slize the large pixlist into smaller pieces
|
||||
# max 64k each one
|
||||
if [ $LARGE ]
|
||||
then
|
||||
LOL_org="$(echo "$LOL_org" | shuf)"
|
||||
test -z "$LOLFIELDSIZE" && LOLFIELDSIZE=64000
|
||||
# line counter
|
||||
L=1
|
||||
LINES="$(echo "$LOL_org" | wc -l )"
|
||||
LOLFIELDS="$(( ( $LINES / $LOLFIELDSIZE ) ))"
|
||||
message "LARGE mode: slicing ${YELLOW}${IMGFILE}${ENDCOLOR} - ${YELLOW}${LINES}${ENDCOLOR} into ${YELLOW}$((${LOLFIELDS}+1))${ENDCOLOR} fields"
|
||||
message "LARGE mode: slicing ${YELLOW}${IMGFILE}${ENDCOLOR} - ${YELLOW}${LINES}${ENDCOLOR} into ${YELLOW}${LOLFIELDS}${ENDCOLOR} fields"
|
||||
|
||||
i=0
|
||||
while [ $i -le $LOLFIELDS ]
|
||||
do
|
||||
LN=$(($L+$LOLFIELDSIZE+1))
|
||||
message "field ${YELLOW}${i}/${LOLFIELDS}${ENDCOLOR}, lines ${YELLOW}${L}${ENDCOLOR} - ${YELLOW}${LN}${ENDCOLOR}"
|
||||
LOL[$i]="$(echo "$LOL_org" | sed -n "${L},$(($LN-1))p;${LN}q" )"
|
||||
L=$LN
|
||||
|
||||
i=$(($i+1))
|
||||
LN=$(($L+$LOLFIELDSIZE+1))
|
||||
message "field ${YELLOW}${i}${ENDCOLOR}, lines ${YELLOW}${L}${ENDCOLOR} - ${YELLOW}${LN}${ENDCOLOR}"
|
||||
LOL[$i]="$(echo "$LOL_org" | sed -n "${L},$(($LN-1))p;${LN}q" )"
|
||||
L=$LN
|
||||
|
||||
i=$(($i+1))
|
||||
done
|
||||
|
||||
elif [ $ANIMATION ]
|
||||
then
|
||||
|
||||
i=0
|
||||
while [ $i -lt $LOLFIELDS ]
|
||||
do
|
||||
if [ -z "$ALPHACOLOR" ]
|
||||
then
|
||||
message "load and shuffle pixels for frame ${YELLOW}$((${i}+1))/${LOLFIELDS}${ENDCOLOR}"
|
||||
LOL[$i]="$(convertimg ${ANIFILE}-${i}.png | shuf)"
|
||||
else
|
||||
message "load and shuffle pixels for frame ${YELLOW}$((${i}+1))/${LOLFIELDS}${ENDCOLOR}, remove aplha color ${YELLOW}${ALPHACOLOR}${ENDCOLOR}"
|
||||
LOL[$i]="$(convertimg ${ANIFILE}-${i}.png | grep -v $ALPHACOLOR | shuf)"
|
||||
fi
|
||||
|
||||
#echo "${LOL[$i]}" | head
|
||||
i=$(($i+1))
|
||||
done
|
||||
# ani
|
||||
#~ echo ani ani
|
||||
#~ exit 1
|
||||
|
||||
else
|
||||
else
|
||||
for i in $(seq 1 $FLOOTFORKS)
|
||||
do
|
||||
if [ -z "$ALPHACOLOR" ]
|
||||
|
@ -437,7 +355,7 @@ loadLOL() {
|
|||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
@ -487,49 +405,32 @@ floot() {
|
|||
;;
|
||||
|
||||
*)
|
||||
if [ $ANIMATION ]
|
||||
# generate a tmp file, as i have trouble atm to figure out
|
||||
# why free space get lost when i generate the pixlist directly
|
||||
# in ram
|
||||
if [ $USECACHE ]
|
||||
then
|
||||
checkfile $IMGFILE
|
||||
message "ANIMATION mode, checking if ${YELLOW}${IMGFILE}${ENDCOLOR} is an GIF"
|
||||
if [ "$(file $IMGFILE |awk '{print $2}')" == "GIF" ]
|
||||
then
|
||||
LOLFIELDS="$(identify $IMGFILE | wc -l )"
|
||||
message "splitting ${YELLOW}${IMGFILE}${ENDCOLOR} up into ${YELLOW}${LOLFIELDS}${ENDCOLOR} frame images"
|
||||
convert -coalesce $IMGFILE ${ANIFILE}.png || error
|
||||
else
|
||||
message error "Other filetypes then ${YELLOW}GIF${ENDCOLOR} are not supported at the moment for ${YELLOW}ANIMATION${ENDCOLOR}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ $USECACHE ]
|
||||
then
|
||||
checkfile $PIXLIST
|
||||
message "using cache from ${YELLOW}$PIXLIST${ENDCOLOR}"
|
||||
LOL_org="$(< $PIXLIST)"
|
||||
else
|
||||
checkfile $IMGFILE
|
||||
message "convertimg image file ${YELLOW}${IMGFILE}${ENDCOLOR}"
|
||||
LOL_org="$(convertimg)"
|
||||
#convertimg > $PIXLIST
|
||||
fi
|
||||
checkfile $PIXLIST
|
||||
message "using cache from ${YELLOW}$PIXLIST${ENDCOLOR}"
|
||||
LOL_org="$(< $PIXLIST)"
|
||||
else
|
||||
checkfile $IMGFILE
|
||||
message "convertimg image file ${YELLOW}${IMGFILE}${ENDCOLOR}"
|
||||
LOL_org="$(convertimg)"
|
||||
#convertimg > $PIXLIST
|
||||
fi
|
||||
message "prepare worker .."
|
||||
#set -x
|
||||
loadLOL
|
||||
#set +x
|
||||
message "${GREEN}DONE!${ENDCOLOR}"
|
||||
|
||||
message "prepare worker ${YELLOW}$i${ENDCOLOR} .."
|
||||
#set -x
|
||||
loadLOL
|
||||
#set +x
|
||||
message "${GREEN}DONE!${ENDCOLOR}"
|
||||
;;
|
||||
esac
|
||||
|
||||
message "starting $FLOOTFORKS workers"
|
||||
|
||||
if [ $ANIMATION ]
|
||||
then
|
||||
frametick &
|
||||
fi
|
||||
|
||||
|
||||
message "starting ${YELLOW}${FLOOTFORKS}${ENDCOLOR} workers"
|
||||
|
||||
|
||||
while true
|
||||
do
|
||||
for i in $(seq $FLOOTFORKS)
|
||||
|
@ -538,7 +439,7 @@ floot() {
|
|||
if [ -z ${LOLPID[$i]} ] || ! ps -p ${LOLPID[$i]} > /dev/null
|
||||
then
|
||||
message "worker ${YELLOW}$i${ENDCOLOR} is not running, starting it"
|
||||
if [ $LARGE ] || [ $ANIMATION ]
|
||||
if [ $LARGE ]
|
||||
then
|
||||
flootworker $LOLFIELDS &
|
||||
LOLPID[$i]=$!
|
||||
|
@ -602,22 +503,11 @@ case $1 in
|
|||
|
||||
;;
|
||||
esac
|
||||
|
||||
for imgmgckCMD in convert identify
|
||||
do
|
||||
if ! command -v $imgmgckCMD > /dev/null
|
||||
then
|
||||
message error "imagemagick ${YELLOW}${imgmgckCMD}${ENDCOLOR} not found"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $LARGE ] && [ $ANIMATION ]
|
||||
if ! command -v convert > /dev/null
|
||||
then
|
||||
message error "${YELLOW}LARGE${ENDCOLOR} and ${YELLOW}ANIMATION${ENDCOLOR} cannot be used at the same time. Please use only one of them."
|
||||
message error "${YELLOW}convert${ENDCOLOR} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
message "all requirements satisfied ${GREEN}:)${ENDCOLOR}"
|
||||
floot
|
||||
;;
|
||||
|
@ -646,7 +536,6 @@ case $1 in
|
|||
echo "SIZE(int), TEXT(string), FONTSIZE(int), BGCOLOR(hex), COLOR(hex)"
|
||||
echo "BORDERCOLOR(hex), X(int), Y(int), X_MAX(int), Y_MAX(int), H(int), W(int)"
|
||||
echo "RESIZE(int), ALPHACOLOR(hex), BOUNCESTEP(int), LARGE(bool), LOLFIELDSIZE(int)"
|
||||
echo "ANIMATION(bool), FRAMETICKTIME(float)"
|
||||
|
||||
exit 1
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue