-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstar_field
81 lines (67 loc) · 2.17 KB
/
star_field
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
#
# star_field [options] XxY output_image
#
# Generate a random 'hex' star field (tilable) of the size given.
#
# Options:
# -r angle of rotation of the hex star (def=15)
# -b how bright (percentage) should the stars be (def=100)
#
####
#
# WARNING: Input arguments are NOT tested for correctness.
# This script represents a security risk if used ONLINE.
# I accept no responsiblity for misuse. Use at own risk.
#
# Anthony Thyssen March 2006
#
PROGNAME=`type $0 | awk '{print $3}'` # search for executable on path
PROGDIR=`dirname $PROGNAME` # extract directory of program
PROGNAME=`basename $PROGNAME` # base name of program
Usage() { # output the script comments as docs
echo >&2 "$PROGNAME:" "$@"
sed >&2 -n '/^###/q; /^#/!q; s/^#//; s/^ //; 3s/^/Usage: /; 2,$ p' \
"$PROGDIR/$PROGNAME"
exit 10;
}
# defaults
angle=15
bright=100
while [ $# -gt 0 ]; do
case "$1" in
--help|--doc*) Usage ;;
-r) shift; angle=$1 ;; # rotation angle
-b) shift; bright=$1 ;; # How bright (percentage)
--) shift; break ;; # end of user options
-*) Usage "Unknown option \"$1\"" ;;
*) break ;; # end of user options
esac
shift # next option
done
[ $# -lt 2 ] && Usage "Too few arguments."
[ $# -gt 2 ] && Usage "Too many arguments."
size="$1"
output="$2"
# clean up the arguments
while expr "$angle" \< 0 >/dev/null; do
angle=`expr $angle + 60`
done
while expr "$angle" \> 60 >/dev/null; do
angle=`expr $angle - 60`
done
a1=$angle
a2=`expr $a1 + 60`
a3=`expr $a1 + 120`
b1=`expr $a1 + 180`
b2=`expr $a2 + 180`
b3=`expr $a3 + 180`
bright=`( echo 'scale=2'; echo "$bright" / 100; ) | bc`
# Do the task (slow)...
magick -size "$size" xc: -fx 'rand()' -virtual-pixel tile \
-colorspace Gray -sigmoidal-contrast 120x0% -negate -blur 0x.3 \
\( -clone 0 -motion-blur 0x10+$a1 -motion-blur 0x10+$b1 \) \
\( -clone 0 -motion-blur 0x10+$a2 -motion-blur 0x10+$b2 \) \
\( -clone 0 -motion-blur 0x10+$a3 -motion-blur 0x10+$b3 \) \
-compose screen -background black -flatten -normalize \
-evaluate multiply $bright "$output"