animation wip-2
This commit is contained in:
parent
6641771171
commit
06ff88d9c2
1 changed files with 79 additions and 34 deletions
107
pixelfloot.sh
107
pixelfloot.sh
|
@ -15,6 +15,7 @@ IMGFILE="$2"
|
||||||
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
|
||||||
|
@ -50,7 +51,7 @@ test -z "$BOUNCESTEP" && BOUNCESTEP=2
|
||||||
# to not draw too fast, there is a sleep in frametick which waits for
|
# 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
|
# FRAMETICKTIME seconds. Values are float, down to lowest value 0.001
|
||||||
# Only one of ANIMATION or LARGE can be true, not both.
|
# Only one of ANIMATION or LARGE can be true, not both.
|
||||||
FRAMETICK_SHM="/dev/shm/frametick"
|
FRAMETOPICK_SHM="/dev/shm/pxlflt-frametopick"
|
||||||
## END ANIMATION
|
## END ANIMATION
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,6 +62,13 @@ 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"
|
||||||
|
@ -302,10 +310,18 @@ xymode() {
|
||||||
|
|
||||||
frametick() {
|
frametick() {
|
||||||
test -z "$FRAMETICKTIME" && FRAMETICKTIME=0.1
|
test -z "$FRAMETICKTIME" && FRAMETICKTIME=0.1
|
||||||
|
LOLFIELDS=12
|
||||||
|
i=0
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
echo lol
|
echo "$i" #> $FRAMETOPICK_SHM
|
||||||
exit 1
|
if [ "$i" -ge $LOLFIELDS ]
|
||||||
|
then
|
||||||
|
i=0
|
||||||
|
else
|
||||||
|
i=$(($i+1))
|
||||||
|
fi
|
||||||
|
sleep $FRAMETICKTIME
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -322,6 +338,16 @@ flootworker()
|
||||||
do
|
do
|
||||||
echo "${LOL[$i]}"
|
echo "${LOL[$i]}"
|
||||||
done
|
done
|
||||||
|
elif [ $ANIMATION ]
|
||||||
|
then
|
||||||
|
xymode
|
||||||
|
echo "$OFFSET"
|
||||||
|
i=0
|
||||||
|
while [ $i -le $1 ]
|
||||||
|
do
|
||||||
|
echo "${LOL[$i]}"
|
||||||
|
i=$(($i+1))
|
||||||
|
done
|
||||||
else
|
else
|
||||||
xymode
|
xymode
|
||||||
echo "$OFFSET
|
echo "$OFFSET
|
||||||
|
@ -342,10 +368,10 @@ 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
|
||||||
|
@ -357,15 +383,20 @@ loadLOL() {
|
||||||
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}${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
|
||||||
|
|
||||||
else
|
elif [ $ANIMATION ]
|
||||||
|
then
|
||||||
|
# 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" ]
|
||||||
|
@ -378,7 +409,7 @@ loadLOL() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,21 +459,32 @@ floot() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
# generate a tmp file, as i have trouble atm to figure out
|
if [ $ANIMATION ]
|
||||||
# why free space get lost when i generate the pixlist directly
|
|
||||||
# in ram
|
|
||||||
if [ $USECACHE ]
|
|
||||||
then
|
then
|
||||||
checkfile $PIXLIST
|
checkfile $IMGFILE
|
||||||
message "using cache from ${YELLOW}$PIXLIST${ENDCOLOR}"
|
message "ANIMATION mode, checking if ${YELLOW}${IMGFILE}${ENDCOLOR} is an GIF"
|
||||||
LOL_org="$(< $PIXLIST)"
|
if [ "$(file $IMGFILE |awk '{print $2}')" == "GIF" ]
|
||||||
|
then
|
||||||
|
LOLFIELDS="$(identify $IMGFILE | echo $(( $(wc -l) - 1 )) )"
|
||||||
|
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
|
else
|
||||||
checkfile $IMGFILE
|
if [ $USECACHE ]
|
||||||
message "convertimg image file ${YELLOW}${IMGFILE}${ENDCOLOR}"
|
then
|
||||||
LOL_org="$(convertimg)"
|
checkfile $PIXLIST
|
||||||
#convertimg > $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 ${YELLOW}$i${ENDCOLOR} .."
|
message "prepare worker ${YELLOW}$i${ENDCOLOR} .."
|
||||||
#set -x
|
#set -x
|
||||||
loadLOL
|
loadLOL
|
||||||
|
@ -533,11 +575,14 @@ case $1 in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if ! command -v convert > /dev/null
|
for imgmgckCMD in convert identify
|
||||||
then
|
do
|
||||||
message error "${YELLOW}convert${ENDCOLOR} not found"
|
if ! command -v $imgmgckCMD > /dev/null
|
||||||
exit 1
|
then
|
||||||
fi
|
message error "imagemagick ${YELLOW}${imgmgckCMD}${ENDCOLOR} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [ $LARGE ] && [ $ANIMATION ]
|
if [ $LARGE ] && [ $ANIMATION ]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in a new issue