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`
|
- 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:
|
- default field size are 64k lines. You can adjust it with LOLFIELDSIZE:
|
||||||
`LOLFIELDSIZE=16000 LARGE=true ./pixelfloot.sh floot images/xphg.jpg`
|
`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
|
```shell
|
||||||
$ ./pixelfloot.sh help
|
$ ./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)
|
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)
|
BORDERCOLOR(hex), X(int), Y(int), X_MAX(int), Y_MAX(int), H(int), W(int)
|
||||||
RESIZE(int), ALPHACOLOR(hex), BOUNCESTEP(int), LARGE(bool)
|
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,
|
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"
|
test -z "$FLOOTPORT" && FLOOTPORT="1234"
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
FNAME="$(echo $2 | sed -e 's/\..*$//' -e 's/^images\///')"
|
||||||
IMGFILE="$2"
|
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"
|
PPMFILE="$FNAME.ppm"
|
||||||
HEXPPM="images/$FNAME.hexppm"
|
HEXPPM="images/$FNAME.hexppm"
|
||||||
PIXLIST="/tmp/$FNAME.pixlist"
|
PIXLIST="/tmp/$FNAME.pixlist"
|
||||||
ANIFILE="/tmp/$FNAME"
|
|
||||||
SHUFMODE="$3"
|
SHUFMODE="$3"
|
||||||
|
|
||||||
FLOOTSRUNNING=0
|
FLOOTSRUNNING=0
|
||||||
|
@ -42,20 +37,7 @@ test -z "$BOUNCESTEP" && BOUNCESTEP=2
|
||||||
# /dev/shm/foo to store frame counter
|
# /dev/shm/foo to store frame counter
|
||||||
#
|
#
|
||||||
# GifFileFormat - gif, jpg, png || detect which fileformat IMGFILE is
|
# GifFileFormat - gif, jpg, png || detect which fileformat IMGFILE is
|
||||||
#test -z "$ANIMATION" && ANIMATION="false"
|
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"
|
|
||||||
## END ANIMATION
|
## END ANIMATION
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,13 +48,6 @@ declare -a PIXMAP
|
||||||
declare -a LOL
|
declare -a LOL
|
||||||
declare -a LOLPID
|
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)
|
# colors for colored output 8)
|
||||||
RED="\e[31m"
|
RED="\e[31m"
|
||||||
|
@ -252,12 +227,6 @@ done
|
||||||
|
|
||||||
|
|
||||||
convertimg() {
|
convertimg() {
|
||||||
if [ -z "$1" ]
|
|
||||||
then
|
|
||||||
CONVERTFILE="$IMGFILE"
|
|
||||||
else
|
|
||||||
CONVERTFILE="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$RESIZE" ]
|
if [ -n "$RESIZE" ]
|
||||||
then
|
then
|
||||||
|
@ -265,7 +234,7 @@ convertimg() {
|
||||||
|
|
||||||
fi
|
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()
|
flootworker()
|
||||||
{
|
{
|
||||||
while true
|
while true
|
||||||
|
@ -348,17 +299,6 @@ flootworker()
|
||||||
do
|
do
|
||||||
echo "${LOL[$i]}"
|
echo "${LOL[$i]}"
|
||||||
done
|
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
|
else
|
||||||
xymode
|
xymode
|
||||||
echo "$OFFSET
|
echo "$OFFSET
|
||||||
|
@ -379,52 +319,30 @@ checkfile() {
|
||||||
|
|
||||||
loadLOL() {
|
loadLOL() {
|
||||||
|
|
||||||
# when LARGE true, then we slize the large pixlist into smaller pieces
|
# when LARGE true, then we slize the large pixlist into smaller pieces
|
||||||
# max 64k each one
|
# max 64k each one
|
||||||
if [ $LARGE ]
|
if [ $LARGE ]
|
||||||
then
|
then
|
||||||
LOL_org="$(echo "$LOL_org" | shuf)"
|
LOL_org="$(echo "$LOL_org" | shuf)"
|
||||||
test -z "$LOLFIELDSIZE" && LOLFIELDSIZE=64000
|
test -z "$LOLFIELDSIZE" && LOLFIELDSIZE=64000
|
||||||
# line counter
|
# line counter
|
||||||
L=1
|
L=1
|
||||||
LINES="$(echo "$LOL_org" | wc -l )"
|
LINES="$(echo "$LOL_org" | wc -l )"
|
||||||
LOLFIELDS="$(( ( $LINES / $LOLFIELDSIZE ) ))"
|
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
|
i=0
|
||||||
while [ $i -le $LOLFIELDS ]
|
while [ $i -le $LOLFIELDS ]
|
||||||
do
|
do
|
||||||
LN=$(($L+$LOLFIELDSIZE+1))
|
LN=$(($L+$LOLFIELDSIZE+1))
|
||||||
message "field ${YELLOW}${i}/${LOLFIELDS}${ENDCOLOR}, lines ${YELLOW}${L}${ENDCOLOR} - ${YELLOW}${LN}${ENDCOLOR}"
|
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" )"
|
LOL[$i]="$(echo "$LOL_org" | sed -n "${L},$(($LN-1))p;${LN}q" )"
|
||||||
L=$LN
|
L=$LN
|
||||||
|
|
||||||
i=$(($i+1))
|
i=$(($i+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
elif [ $ANIMATION ]
|
|
||||||
then
|
|
||||||
|
|
||||||
i=0
|
else
|
||||||
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
|
|
||||||
for i in $(seq 1 $FLOOTFORKS)
|
for i in $(seq 1 $FLOOTFORKS)
|
||||||
do
|
do
|
||||||
if [ -z "$ALPHACOLOR" ]
|
if [ -z "$ALPHACOLOR" ]
|
||||||
|
@ -437,7 +355,7 @@ loadLOL() {
|
||||||
fi
|
fi
|
||||||
done
|
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
|
then
|
||||||
checkfile $IMGFILE
|
checkfile $PIXLIST
|
||||||
message "ANIMATION mode, checking if ${YELLOW}${IMGFILE}${ENDCOLOR} is an GIF"
|
message "using cache from ${YELLOW}$PIXLIST${ENDCOLOR}"
|
||||||
if [ "$(file $IMGFILE |awk '{print $2}')" == "GIF" ]
|
LOL_org="$(< $PIXLIST)"
|
||||||
then
|
else
|
||||||
LOLFIELDS="$(identify $IMGFILE | wc -l )"
|
checkfile $IMGFILE
|
||||||
message "splitting ${YELLOW}${IMGFILE}${ENDCOLOR} up into ${YELLOW}${LOLFIELDS}${ENDCOLOR} frame images"
|
message "convertimg image file ${YELLOW}${IMGFILE}${ENDCOLOR}"
|
||||||
convert -coalesce $IMGFILE ${ANIFILE}.png || error
|
LOL_org="$(convertimg)"
|
||||||
else
|
#convertimg > $PIXLIST
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
message "prepare worker .."
|
|
||||||
#set -x
|
message "prepare worker ${YELLOW}$i${ENDCOLOR} .."
|
||||||
loadLOL
|
#set -x
|
||||||
#set +x
|
loadLOL
|
||||||
message "${GREEN}DONE!${ENDCOLOR}"
|
#set +x
|
||||||
|
message "${GREEN}DONE!${ENDCOLOR}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
message "starting $FLOOTFORKS workers"
|
||||||
|
|
||||||
if [ $ANIMATION ]
|
|
||||||
then
|
|
||||||
frametick &
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
message "starting ${YELLOW}${FLOOTFORKS}${ENDCOLOR} workers"
|
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
for i in $(seq $FLOOTFORKS)
|
for i in $(seq $FLOOTFORKS)
|
||||||
|
@ -538,7 +439,7 @@ floot() {
|
||||||
if [ -z ${LOLPID[$i]} ] || ! ps -p ${LOLPID[$i]} > /dev/null
|
if [ -z ${LOLPID[$i]} ] || ! ps -p ${LOLPID[$i]} > /dev/null
|
||||||
then
|
then
|
||||||
message "worker ${YELLOW}$i${ENDCOLOR} is not running, starting it"
|
message "worker ${YELLOW}$i${ENDCOLOR} is not running, starting it"
|
||||||
if [ $LARGE ] || [ $ANIMATION ]
|
if [ $LARGE ]
|
||||||
then
|
then
|
||||||
flootworker $LOLFIELDS &
|
flootworker $LOLFIELDS &
|
||||||
LOLPID[$i]=$!
|
LOLPID[$i]=$!
|
||||||
|
@ -602,22 +503,11 @@ case $1 in
|
||||||
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
if ! command -v convert > /dev/null
|
||||||
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 ]
|
|
||||||
then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
message "all requirements satisfied ${GREEN}:)${ENDCOLOR}"
|
message "all requirements satisfied ${GREEN}:)${ENDCOLOR}"
|
||||||
floot
|
floot
|
||||||
;;
|
;;
|
||||||
|
@ -646,7 +536,6 @@ case $1 in
|
||||||
echo "SIZE(int), TEXT(string), FONTSIZE(int), BGCOLOR(hex), COLOR(hex)"
|
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 "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 "RESIZE(int), ALPHACOLOR(hex), BOUNCESTEP(int), LARGE(bool), LOLFIELDSIZE(int)"
|
||||||
echo "ANIMATION(bool), FRAMETICKTIME(float)"
|
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue