#!/bin/sh # #------------------------------------------+ # Rewrote it like powershell. | # 2022/01/25 H.Kamifuji (Ja) | #------------------------------------------+ # # 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=1000) # #### # # 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 # Param( [String]$size, [String]$output, [Int]$r = 15, [Int]$b = 1000 ) if ( $output -eq "" ) { Write-Host "Usage : star_field [-r angle] [-b bright] size output " Exit } $angle = $r $bright = $b / 100.0 $a1 = $angle $a2 = $a1 + 60 $a3 = $a1 + 120 $b1 = $a1 + 180 $b2 = $a2 + 180 $b3 = $a3 + 180 # Do the task (slow)... $im6 = (gcm montage).Definition 2> -null $im7 = (gcm magick).Definition 2> -null if ( $im7 ) { $method = 1 $magick = "magick" } elseif ( $im6 ) { $method = 2 $magick = "" } else { echo "ImageMagick cannot be found and cannot be executed." Exit } switch ( $method ) { # Execute by ImageMagick7.x 1 { magick convert -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" } # Execute by ImageMagick6.x 2 { convert -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" } }