EDIT: deleted earlier post as i solved my problem for the most part.
I kept running into problems with variable inputs. I’m putting tiled shape on hold because of this - Is there like a way to output numbers of variables? · Issue #145 · dtschump/gmic · GitHub This feature would solve all of my issue with rep_tiles_shape including processing speed, and enabling empty spaces between 1-7
I guess I’ll have to be back with concrete texture or maybe replicate scatter.
Current code if any one wants it
#@cli shape: 0<=_shape
#@cli : Create shape. Variable are defined by the shape chosen.
shape:
v - _gmic_s="$?" v +
_$0 $"*"
_shape:
v - form="$1"
if {isnum("$1")} if {isint("$1")} form=${arg\ 1+$1,australia,barbedwire,circle,crosshair,cupid,diamond,dragonfly,fern,flip,gear,gumleaf,heart,information,kookaburra,mail,mapleleaf,paint_splat,paw,phone,polygon,rooster,shopping_cart,snowflake,star} fi fi
v + e[^-1] "Create shape '"$form"' for shape-based effect."$_gmic_s"." v -
shape_$form ${2--1}
#@cli rep_tiles_shape : _negative_number,_file_location,0<fill_ratio<=1,0<=_subpixel_level<=1,0<=_interpolation<=5,0<=_flip_orientation<=2,_rotation,_shape_size<0,_tile_width,_tile_height : \
# 0<=_shape_id<=24,0<fill_ratio<=1,0<=_subpixel_level<=1,0<=_interpolation<=5,0<=_flip_orientation<=2,_rotation,_shape_size<0,...,_tile_width<0,_tile_height<0 : (+)
#@cli : When $1 is either a name of a shape or a integer number that is between 0 and 24 inclusive, then the formatting of the command becomes the second one.
#@cli : After $2, the last 2 variables are always tile_height, and tile_width! Removing variables between fill_ratio, and shape_size will be omitted, and internally, the command will use respective values found in other commands used by rep_tiles_shape. That means, those variables are used, but not specified by the users, and as mentioned, the last 2 variables are generally _tile_width, and _tile_height.
#@cli : Note - It is advisible to omit $7. If there are 9 variables, then $8 becomes one variable used by a shape id which enables dynamic shape editing.
rep_tiles_shape:
#local filter#
apply_parallel "r {ceil(w/abs(${-2}))*abs(${-2})},{ceil(h/abs(${-1}))*abs(${-1})},100%,100%,0,1,.5,.5"
apply_parallel "_rep_tiles_shape $*"
_rep_tiles_shape:
#local filter#
use_shape={isnum("$1")&&isint("$1")?$1+1:1}
if $use_shape at "rep_shape_blend_average ${1--3}",${-2--1}
else at "rep_shape_blend_average_input_file ${2--3}",${-2--1} fi
rep_shape_blend_average_input_file:
#local filter#
skip ${2=1}
i "${1}" rep_shape_blend_average -1,${2--1}
rep_shape_blend_average:
#local filter#
skip ${2=1},${3=.5},${4=4},${5=0},${6=0}
(${2--1}) nset={w#-1+1} k[0]
if iv#0!=0
if $!>2 v + "Cannot use more than two 2 layer at once!" v - fi
shape="$1"
fill_ratio=$2
sub={$3+1}
interpolation={$4+1}
# flip_shape=$5 #
# rotate_shape=$6 #
use_shape={isnum("$1")&&isint("$1")?$1+1:1}
if $use_shape<0&&$!>2 v + error "Cannot use 2 or more layer at once with shape option!" v - fi
if $sub<1 v + error "Invalid subpixel level!" v - fi
if $interpolation<1 v + error "Invalid interpolation level!" v - fi
if $use_shape
if $nset>=7 shape $shape,{max(w,h)*$sub},${7--1}
else shape $shape,{max(w,h)*$sub} fi
else if s#1>2 to_graya. fi n. 0,1 compose_channels. * fi
if $5!=0
if $5==1 mirror. x
elif $5==2 mirror. y
fi fi
if {abs($6)%360!=0} rotate. $6,1 fi #A way to make this faster for tiles would be appreciated!#
autocrop.
shape_image_ratio={w#1/h#1}
target_image_ratio={w#0/h#0}
resize_width={$target_image_ratio>$shape_image_ratio?w#1*(h#0/h#1):w#0}
resize_height={$target_image_ratio>$shape_image_ratio?h#0:h#1*(w#0/w#1)}
r. {$resize_width*$fill_ratio},{$resize_height*$fill_ratio},1,1,$interpolation,0,.5,.5
r. {w#0},{h#0},1,1,0,0,.5,.5
cut. 0,1
avg={ia#1}
..
f. i*i0#1 f... i*(1-i0#1)
repeat {s#0}
sh... $>
sh.. $>
f. is/($avg*w*h)
f.. is/((1-$avg)*w*h)
rm[^0-2]
done
f[0] i#2*i0#1+i*(1-i0#1)
k[0]
fi