G'MIC exercises

I cobbled together a filter (for command line ATM, not plugin) for the sunbeam thread. It is kind of buggy and gross but maybe we could salvage something from it. :blush: The convolve becomes more expensive as dimensions increase, so I made the decision to resize, which contributes to the ugliness.

Edit: For those who aren’t familiar with G’MIC scripting or cannot bear to read the crude code, the filter has 5 parameters:

$1 → length of beam (not to scale; larger value means longer beam).
$2 → diagonal direction (choose: 0,1,2,3).
$3,$4,$5 → colour of beam.

beams_test: skip ${1==1}&&{2==0}&&{3==104}&&{4==220}&&{5==255}
  r={w} r2dx 200,1
  +l
    +l repeat {$1*20}
      +l.
        if {$2==1} shift -1,1
        elif {$2==2} shift -1,-1
        elif {$2==3} shift 1,-1
        else shift 1,1
        fi
      endl
      + c 0,1
    done endl
    100%,100%,100%,100%
    if {$2==1||$2==3} gaussian. 10,1,-45
    else gaussian. 10,1,45
    fi
    convolve.. . rm. + c 0,255
  endl
  l.
    s c *... $3 *.. $4 *. $5 / 255 a c c 10%,100% n 0,255 * 3
  endl
  +f.. min(I)>0?I:I#1 k.
  r2dx $r,1

The image again for your convenience:

1 Like