matrix flow dots
alias matrix {
mtrwin
fps on
startani $1 40
}
alias mtrwin {
window -pdohB +dL @matrix 100 100 50 50
drawfill @matrix 1 99 10 10
}
alias startani {
.timermfd -om 0 1 matrixflowdots
%maxdots = $1
%lft = $2
%maxy = 47
%maxx = 47
}
alias matrixflowdots {
if (%fps != $null) inc %fps
var %i = 0
:num
inc %i
if ($gettok(%dot. [ $+ [ %i ] ],1,32) == $null) {
if ($int($rand(1,100)) > 50) {
;format x y life speed size
%dot. [ $+ [ %i ] ] = $int($rand(0,%maxx)) 0 %lft $int($rand(1,4)) $rand(1,10)
}
}
var %x = $gettok(%dot. [ $+ [ %i ] ],1,32), %y = $gettok(%dot. [ $+ [ %i ] ],2,32), %life = $gettok(%dot. [ $+ [ %i ] ],3,32), %speed = $gettok(%dot. [ $+ [ %i ] ],4,32), %size = $gettok(%dot. [ $+ [ %i ] ],5,32)
if %x != $null drawline @matrix 1 1 %x %y %x $calc(%y + %size)
if (%life > 0) {
inc %y %speed
dec %life
if (%y <= %maxy) { drawline @matrix 9 1 %x %y %x $calc(%y + %size) | %dot. [ $+ [ %i ] ] = %x %y %life %speed %size }
else { unset %dot. [ $+ [ %i ] ] }
}
else { unset %dot. [ $+ [ %i ] ] }
if (%i < %maxdots) goto num
}
alias stop {
.timermfd off
close -@ @matrix
unset %dot*
if %fps != $null fps off
}
alias fps {
if ($1 = on) timerfps 0 1 show
if ($1 = off) { timerfps off | %fps = $null }
}
alias show {
if (%fps = $null) %fps = 0
echo -s FPS= %fps | %fps = 0
}
menu @matrix {
sclick:{ .timermove -m 0 0 move_win $calc($mouse.dx - $window($active).dx) $calc($mouse.dy - $window($active).dy) }
}
alias move_win {
if ($mouse.key !& 1) .timermove off | else window $active $calc($mouse.dx - $1) $calc($mouse.dy - $2)
}