Ok, some progress on Color Modulo Here (There are some bugs which I haven’t figured out):
#@cli rep_colmt: (eq. to rep_color_modulo_texture)
rep_colmt: rep_color_modulo_texture $*
#@cli rep_color_modulo_texture: 0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize }, \
# 0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize }, \
# 0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize }, \
# 0<=_modulo_method<=5,_maxmod>0,_endmodvalue>0,0<=_angle<=360,_value_shift>0,_centered= { 0=Not centered | 1=Centered },_negate_mod= { 0=normal | 1=inverted },_normalize_bool= { 0=Do not Normalize | 1=Normalize }, \
# _diagonal_flip= { 0=not flipped | 1 = flipped },_subpixel_processing_level>0,0<=_interpolation<=5,0<=_colorspacemode<=11,_contain_alpha= { 0=no_alpha | 1=alpha }, \
# 0<=_channel_num<=4,0<=_channel_num<=4,0<=_channel_num<=4,0<=_channel_num<=4
#@cli: Inspired by MadJik's Color Modulo Texture for Paint.NET, this is a extension of that filter converted into G'MIC form. New features is being able to change color space, allow alpha, anti-aliasing...
rep_color_modulo_texture:
repeat $! l[$>]
lcmod_1=$38
lcmod_2=$39
lcmod_3=$40
lcmod_4=$41
cs=$36
alp=$37
diag=$33
interpolation=$35
subpixel=$34
subpixel+=1
tc={$cs!=3?3+$alp:4}
iw={w}
ih={h}
maxv={max(w,h)}
sd={min(w,h)/max(w,h)}
sx={w<h?$sd:1}
sy={h<w?$sd:1}
msx={.5*$sx}
msy={.5*$sy}
center=1
f 0 r {$interpolation?$subpixel*100:100}%,{$interpolation?$subpixel*100:100}%,100%,$tc
($lcmod_1,$lcmod_2,$lcmod_3,$lcmod_4)
l.
s x ti=$! remove_duplicates
if $!!=$ti v + error "Invalid channel inputs!" v - fi a x
endl
repeat $tc sh[0] {i(#1,$>,0)} done rm[1]
f[1] ang=pi*($4/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IX=ix*cos(ang)-iy*sin(ang);IX+=!$6?$msx;IX*=$maxv;ix=IX;ix abs[1] modf[1] $1,$2,{$3/$2}
if {$8&&($1<2)} +[1] {$3<$2?$3} fi
if $7 negate[1] fi
temp={im#1} -[1] $temp modf[1] 4,{iM#1},$5 +[1] $temp
f[2] ang=pi*($12/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IY=ix*sin(ang)+iy*cos(ang);IY+=!$14?$msx;IY*=$maxv;iy=IY;iy abs[2] modf[2] $9,$10,{$11/$10}
if {$16&&($9<2)} +[2] {$11<$10?$11} fi
if $15 negate[2] fi
temp={im#2} -[2] $temp modf[2] 4,{iM#2},$13 +[2] $temp
f[3] ang=pi*($20/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IX=ix*cos(ang)-iy*sin(ang);IY=ix*sin(ang)+iy*cos(ang);IX+=!$22?$msx;IX*=$maxv;IY+=!$22?$msx;IY*=$maxv;ix=IX;iy=IY;($diag?(abs(ix)+abs(iy)):abs(abs(ix)-abs(iy))) modf[3] $17,$18,{$19/$18}
if {$24&&($17<2)} +[3] {$19<$18?$19} fi
if $23 negate[3] fi
temp={im#3} -[3] $temp modf[3] 4,{iM#3},$21 +[3] $temp
if $tc==4
f[4] ang=pi*($28/180);ix=(x/w)-.5;iy=(y/h)-.5;ix*=$sx;iy*=$sy;IX=ix*cos(ang)-iy*sin(ang);IY=ix*sin(ang)+iy*cos(ang);IX+=!$30?$msx;IX*=$maxv;IY+=!$30?$msx;IY*=$maxv;ix=IX;iy=IY;(!$diag?(abs(ix)+abs(iy)):abs(abs(ix)-abs(iy))) modf[4] $25,$26,{$27/$26}
if {$32&&($25<2)} +[4] {$27<$26?$27} fi
if $31 negate[4] fi
temp={im#4} -[4] $temp modf[4] 4,{iM#4},$29 +[4]
fi
k[0]
if $interpolation&&($subpixel>=2) r $iw,$ih,100%,100%,$interpolation fi
if $cs!=3
if $cs!=0 sh 0,2 fi
if $cs==1 ryb2rgb.
elif $cs==2 cmy2rgb.
elif $cs==4 hsi82rgb.
elif $cs==5 hsl82rgb.
elif $cs==6 hsv82rgb.
elif $cs==7 lab82rgb.
elif $cs==8 lch82rgb.
elif $cs==9 yiq82rgb.
elif $cs==10 yuv82rgb.
elif $cs==11 xyz82rgb.
fi
if $cs!=0 rm. fi
else
cmyk2rgb
fi
endl done
#@gui Color Modulo Texture : rep_colmt_gui,rep_colmt_gui_preview(0)
#@gui : note = note("This filter is inspired by <i><a href="https://forums.getpaint.net/topic/7186-madjik-all-plugins-last-updated-2018-04-07/">MadJik's<small><small>.</small></small></a></i> PDN plugin named <i>Color Modulo</i>. G'MIC version exclusive features : Modulo Method, Angle, Value Shift, Negate."), sep = separator()
#@gui : note = note("<b>Color Setting</b>")
#@gui : 1.Color Space=choice(3,"RGB-8","RYB-8","CMY-8","CMYK-8","HSI-8","HSL-8","HSV-8","LAB-8","LCH-8","YIQ-8","YUV-8","XYZ-8")
#@gui : 2.Alpha (Inapplicable to CMYK) = bool(0)
#@gui : sep = separator()
#@gui : note = note("<b>Main Texture Generation</b>")
#@gui : note = note("Channel #1")
#@gui : 3.Modulo Method = choice(3,"Modulo","Modulo-Continuous","Divisive Modulo","Divisive Modulo-Continuous")
#@gui : 4.Max Number = float(255,.1,255)
#@gui : 5.Modulo Result Number = float(128,.1,255)
#@gui : 6.Angle = float(0,-180,180)
#@gui : 7.Value Shift = float(0,0,255)
#@gui : 8.Centered? = bool(0)
#@gui : 9.Negate Value? = bool(0)
#@gui : 10.Normalize based on min? = bool(0)
#@gui : note = note("Channel #2")
#@gui : 11.Modulo Method = choice(3,"Modulo","Modulo-Continuous","Divisive Modulo","Divisive Modulo-Continuous")
#@gui : 12.Max Number = float(255,.1,255)
#@gui : 13.Modulo Result Number = float(128,.1,255)
#@gui : 14.Angle = float(0,-180,180)
#@gui : 15.Value Shift = float(0,0,255)
#@gui : 16.Centered? = bool(0)
#@gui : 17.Negate Value? = bool(0)
#@gui : 18.Normalize based on min? = bool(0)
#@gui : note = note("Channel #3")
#@gui : 19.Modulo Method = choice(3,"Modulo","Modulo-Continuous","Divisive Modulo","Divisive Modulo-Continuous")
#@gui : 20.Max Number = float(255,.1,255)
#@gui : 21.Modulo Result Number = float(128,.1,255)
#@gui : 22.Angle = float(0,-180,180)
#@gui : 23.Value Shift = float(0,0,255)
#@gui : 24.Centered? = bool(0)
#@gui : 25.Negate Value? = bool(0)
#@gui : 26.Normalize based on min? = bool(0)
#@gui : note = note("Channel #4")
#@gui : 27.Modulo Method = choice(3,"Modulo","Modulo-Continuous","Divisive Modulo","Divisive Modulo-Continuous")
#@gui : 28.Max Number = float(255,.1,255)
#@gui : 29.Modulo Result Number = float(128,.1,255)
#@gui : 30.Angle = float(0,-180,180)
#@gui : 31.Value Shift = float(0,0,255)
#@gui : 32.Centered? = bool(0)
#@gui : 33.Negate Value? = bool(0)
#@gui : 34.Normalize based on min? = bool(0)
#@gui : sep = separator(), note = note("<b>Additional Texture Generation Option</b>")
#@gui : 35. Diagonal Flip? = bool(0)
#@gui : sep = separator(), note = note("<b>Channel Order</b>\n\nPick numbers to order the channels")
#@gui : 36.First Channel = choice(0,"Channel 1","Channel 2","Channel 3","Channel 4")
#@gui : 37.Second Channel = choice(1,"Channel 1","Channel 2","Channel 3","Channel 4")
#@gui : 38.Third Channel = choice(2,"Channel 1","Channel 2","Channel 3","Channel 4")
#@gui : 39.Fourth Channel = choice(3,"Channel 1","Channel 2","Channel 3","Channel 4")
#@gui : sep = separator(), note = note("<b>Processing Value</b>")
#@gui : 40.Subpixel Level = int(0,0,3)
#@gui : 41.Interpolation = choice(2,"None","Nearest","Average","Linear","Grid","Bicubic","Lanczos")
#@gui : sep = separator(), note = note("<small>Author : <i>Reptorian</i> Latest update: <i>2019/07/18</i>.</small>")
rep_colmt_gui: rep_colmt ${3-34},$35,${40-41},${1-2},${36-39}
rep_colmt_gui_preview: rep_colmt_gui $*