Working on a Tile Placing tool for G'MIC-QT

2020-04-18-194015_269x95_scrot

Platform Also

1 Like

Brings back memories.

gmic rep_rpgtiler_noniso.gmic rep_rpgtiler_noniso d9c7f209792f69b337e038c59c61b00319c48afa.png

It needs another parameter?

@afre @David_Tschumperle I’m stuck on a roadblock that will prevent me from releasing Version 3 of the filter. I can’t seem to get the echo message to show up on either shortcut command or full name command, and I prefer having a block somewhere to manipulate than having to copy and paste a block to another. Instructions on usage is way below.

#@cli rep_tiler_n: eq. to 'rep_tiler_nonisometric' : (+)
rep_tiler_n: rep_tiler_nonisometric $*
#@cli rep_tiler_nonisometric: { filename | [tileset] },__min_tile>=3,increment>=0,_tileset_iw_width>=1,_tileset_ih_width>=1,{ filename | [placed_tiles] },_preserve_bgout={ 0=eliminate_bg | 1=preserve_bg },_drgba_r>=0,_drgba_g>=0,_drgba_b>=0,_gridcol>=0,_trackpadcol>=0 
#@cli : Launch the interactive non-isometric RPG Tiling toolkit. Mandatory variables are the first 3 ones!
#@cli : More info: The interactive RPG Tiling toolkit is a near final version. Final version will have tiledata import and export. Perhaps with a master developer editor to make overworld art.\n
#@cli : (eq. to 'rep_tiler_n').\n
#@cli : Note: This is meant to enable artists to make artwork based on non-isometric RPG games or even world. It is not meant to be a tool to aid into making RPG games. If you want that, then you need to look into other solutions. Of course, there might be the off-chance that this tool is suitable for you.\n 
#@cli : '{ filename | [tileset] }' can be either location of the tileset in text form, or as a image argument. If using image argument, you must do rep_tiler_nonisometric[target] [tile] to make it work.
#@cli : '__min_tile' defines the size of tiles.
#@cli : 'increment' defines the maximum possible selection length by number of tiles added by 1. 0 means maximum possible selection length by tile within axis is exactly 1.
#@cli : '_tileset_iw_width' defines the width of tileset visible within interactive window.
#@cli : '_tileset_ih_width' defines the width of tileset visible within interactive window.
#@cli : '_preserve_bgout' can be used to keep or erase image after painting tiles.
#@cli : '{ filename | [placed_tiles] }' can be either location of the tile in text form, or as a image argument. If using image argument, you must do rep_tiler_nonisometric[target] [tile] to make it work.
#@cli : '_dbrga_r' is the color of transparent background. If a value is assigned to this, then transparent areas are replaced with colored background instead of a checkerboard.
#@cli : '_dbrga_g' is the color of transparent background. If a value is assigned to this, then transparent areas are replaced with colored background instead of a checkerboard.
#@cli : '_dbrga_b' is the color of transparent background. If a value is assigned to this, then transparent areas are replaced with colored background instead of a checkerboard.
#@cli : '_gridcol' defines the color of grid within interactive window. Only grayscale value.
#@cli : '_trackpadcol' defines the color of tracker pad within interactive window. Only grayscale value.\n
#@cli : Default values: '_tileset_iw_width=16','_tileset_ih_width=16','_preserve_bgout=0','_drgba_r=','_drgba_g=','_drgba_b=','_gridcol=0','_trackpadcol=0'
rep_tiler_nonisometric:
skip ${4=16},${5=16},${6=},${7=0},${8=},${9=},${10=},${11=0},${12=50}
include_background_image=${"is_image_arg $1"}
include_tile_img=${"is_image_arg $6"}
include_tile_loc={!isint($6)||!isnum($6)} 

__min_tile={abs($2)}
if $__min_tile<3 error "$"2>=3==F"" fi
max_increment={abs($3)}

tile_width=$__min_tile
tile_height=$__min_tile

gridcol={abs($11)}
trackpadcol={abs($12)}
__trackpadcol_alt=$trackpadcol

m "tiler_noniso_message : __rep_tiler_nonisometric_instructions" 

if narg($8)||narg($9)||narg($10)
    if narg($8) __r_col={min(abs($8),255)} else __r_col=0 fi
    if narg($9) __g_col={min(abs($9),255)} else __g_col=0 fi
    if narg($10) __b_col={min(abs($10),255)} else __b_col=0 fi

    m "xalp : drgba $__r_col,$__g_col,$__b_col"
else
    m "xalp : drgba"
fi

m "xalpa: xalp to_a"

m "out2display : skip ${""1=},${""2=},${""3=},${""4=1},${""5=1},${""6=},${""7=},${""8=},${""9=},${""10=} if narg($""1) if $""1 $__bg rv blend alpha fi fi xalp if narg($""6) if narg($""2)&&narg($""3)&&narg($""4)&&narg($""5) {$""4},{$""5},1,{s#0},i(#-1,$""2+x,$""3+y) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],$""2,$""3 rm. if narg($""8)&&narg($""9)&&narg($""10) if $""8==0||$""8>2 {$""4},{$""5},1,{s#0},i(#0,$__nw+($__min_tile*$""9)-$""2+x-$""4,$""3+y) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],{$__nw+($__min_tile*$""9)-$""2-$""4},$""3 rm. fi if $""8==1||$""8>2 {$""4},{$""5},1,{s#0},i(#0,$""2+x,$__nh+($__min_tile*$""10)-$""3+y-$""5) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],$""2,{$__nh+($__min_tile*$""10)-$""3-$""5} rm. fi if $""8==2||$""8>2 {$""4},{$""5},1,{s#0},i(#0,$__nw+($__min_tile*$""9)-$""2+x-$""4,$__nh+($__min_tile*$""10)-$""3+y-$""5) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],{$__nw+($__min_tile*$""9)-$""2-$""4},{$__nh+($__min_tile*$""10)-$""3-$""5} rm. fi fi fi fi if narg($""7) f[0] begin(ww=w-1;hh=h-1;);(x%$__min_tile==0||y%$__min_tile==0)||(x==ww||y==hh)?$""7:i fi"

m "pass2tile : skip ${""4=2} pass$""1 $""4 f[0] i(#-1,$""2+x,$""3+y) rm."

m "tile2canvas : skip ${""4=0} pass$""1 0 +f. i(#0,$""2+x,$""3+y) if !$""4 rv[-2,-1] fi blend[-2,-1] alpha j[0] [-1],$""2,$""3 rm."

m "tile2canvas_r : +f. 0 j[0] [-1],$""1,$""2 rm. tile2canvas[0] [-1],$""1,$""2,$""3"

if $!==1
    ttw={ceil(w#0/$__min_tile)}
    tth={ceil(h#0/$__min_tile)}
    isw={$ttw}
    ish={$tth}
    $ttw,1,1,1 iscl={$ttw-1} store. __isc
    $tth,1,1,1 isrl={$tth-1} store. __isr
    __nw={$ttw*$__min_tile}
    __nh={$tth*$__min_tile}
    ttw-=2
    tth-=2
    r $__nw,$__nh,100%,100%,0,0,.5,.5 to_a 
    +store[0] obg
    xalpa
    cs={s#-1}
    +store[0] __bg
    if narg($6)
        if include_tile_img pass$6
        else include_tile_loc i $6
        fi
        rm[0]
        if ((w#-1!=$__nw)||(h#-1!=$__nw))||(s#-1!=$cs)
            error "Invalid Tile Image!"
        fi
        start=1
    else
        f 0
        start=0
    fi
    +store[0] current_image
    +store[0] undo_image
    e[] "\nEntering non-isometric RPG Tiling Tool!"
else
    error "$!==1=F"
fi

m "tile2canvas_sym : pass$""1 0 +f. i(#0,$""2+x,$""3+y) if $""8==0||$""8==3 [1] if $""7 mirror. x fi +f. i(#0,$__nw+($__min_tile*$""9)-$""4-$""2+x,$""3+y) fi if $""8==1||$""8==3 [1] if $""7 mirror. y fi +f. i(#0,$""2+x,$__nh+($__min_tile*$""10)-$""5-$""3+y) fi if $""8==2||$""8==3 [1] if $""7 rotate. 180 fi +f. i(#0,$__nw+($__min_tile*$""9)-$""4-$""2+x,$__nh+($__min_tile*$""10)-$""5-$""3+y) fi if $""8==3 if !$""6 rv[-8,-7] rv[-6,-5] fi blend[-8,-7] alpha blend[-6,-5] alpha fi if !$""6 rv[-4,-3] rv[-2,-1] fi blend[-4,-3] alpha blend[-2,-1] alpha if $""8==3 j[0] [-4],$""2,$""3 j[0] [-3],{$__nw+($__min_tile*$""9)-$""4-$""2},$""3 j[0] [-2],$""2,{$__nh+($__min_tile*$""10)-$""5-$""3} j[0] [-1],{$__nw+($__min_tile*$""9)-$""4-$""2},{$__nh+($__min_tile*$""10)-$""5-$""3} k[0] else j[0] [-2],$""2,$""3 if $""8==0 j[0] [-1],{$__nw+($__min_tile*$""9)-$""4-$""2},$""3 elif $""8==1 j[0] [-1],$""2,{$__nh+($__min_tile*$""10)-$""5-$""3} elif $""8==2 j[0] [-1],{$__nw+($__min_tile*$""9)-$""4-$""2},{$__nh+($__min_tile*$""10)-$""5-$""3} fi rm[-2,-1] fi"

m "tile2canvas_r_sym : +f. 0 j[0] [-1],$""1,$""2 if $""6==3||$""6==0 j[0] [-1],{$__nw+($__min_tile*$""7)-$""3-$""1},$""2 fi if $""6==3||$""6==1 j[0] [-1],$""1,{$__nh+($__min_tile*$""8)-$""4-$""2} fi if $""6==3||$""6==2 j[0] [-1],{$__nw+($__min_tile*$""7)-$""3-$""1},{$__nh+($__min_tile*$""8)-$""4-$""2} fi rm. if $""5&&($""6==3||$""6==0) +mirror[1] x fi if $""5&&($""6==3||$""6==1) +mirror[1] y fi if $""5&&($""6==3||$""6==2) +rotate[1] 180 fi if $""6==3 tile2canvas[0] [{$""5?-4:1}],$""1,$""2 tile2canvas[0] [{$""5?-3:1}],{$__nw+($__min_tile*$""7)-$""3-$""1},$""2 tile2canvas[0] [{$""5?-2:1}],$""1,{$__nh+($__min_tile*$""8)-$""4-$""2} tile2canvas[0] [{$""5?-1:1}],{$__nw+($__min_tile*$""7)-$""3-$""1},{$__nh+($__min_tile*$""8)-$""4-$""2} k[0,1] else tile2canvas[0] [1],$""1,$""2 if $""6==0 tile2canvas[0] [{$""5?2:1}],{$__nw+($__min_tile*$""7)-$""3-$""1},$""2 elif $""6==1 tile2canvas[0] [{$""5?2:1}],$""1,{$__nh+($__min_tile*$""8)-$""4-$""2} elif $""6==2 tile2canvas[0] [{$""5?2:1}],{$__nw+($__min_tile*$""7)-$""3-$""1},{$__nh+($__min_tile*$""8)-$""4-$""2} fi k[0,1] fi"

m "addsym2display : tlx={w#0/2+($""2/2)*$""3-2} tly={h#0/2+($""2/2)*$""4-2} px={w#0/2-2} py={h#0/2-2} if $""1<2 if $""1==0 4,{h#0},1,{s#0},begin(ww=w-1;dp=$""1<2?0:1;lp=dp+1;);x==0||x==ww?dp:lp elif $""1==1 {w#0},4,1,{s#0},begin(hh=h-1;dp=$""1<2?0:1;lp=dp+1;);y==0||y==hh?dp:lp fi *. 255 if $""1==0 j[0] [-1],$tlx,0 else j[0] [-1],0,$tly fi k[0] else ntlx={$tlx+3} ntly={$tly+3} f[0] ((x>=$tlx&&x<=$ntlx)||(y>=$tly&&y<=$tly+3))?((x==$tlx||x==$ntlx)||(y==$tly||y==$ntly)?0:255):i fi"

m "filter_to_selected_row_column: if $__altmode_orientation $__isr f[0] i(#-1,floor((y+$__pmin*$__min_tile)/$__min_tile),0,0,0)?i:0 else $__isc f[0] i(#-1,floor((x+$__pmin*$__min_tile)/$__min_tile),0,0,0)?i:0 fi k[0]"

m "out2display_alt : skip ${""1=},${""2=},${""3=},${""4=},${""5=} if $__altmode_orientation?$__vmax_y:$__vmax_x sh {s-1} if $__altmode_orientation $__isr f.. i(#-1,floor(y/$__min_tile),0,0,0)?i:i*.625 else $__isc f.. i(#-1,floor(x/$__min_tile),0,0,0)?i:i*.625 fi rm[-2,-1] fi if narg($""1) if $""1 $__bg rv blend alpha fi fi xalp if narg($""2) if $__altmode_orientation $__isr {w#0},{h#0},1,1,i(#-1,floor(y/$__min_tile),0,0,0)?1:0 else $__isc {w#0},{h#0},1,1,i(#-1,floor(x/$__min_tile),0,0,0)?1:0 fi f. ($__altmode_orientation?i(#-2,floor(y/$__min_tile),0,0,0):i(#-2,floor(x/$__min_tile),0,0,0))?!(i&&(j(-2,-2,0,0)&&j(-2,-1,0,0)&&j(-2,0,0,0)&&j(-2,1,0,0)&&j(-2,2,0,0)&&j(-1,-2,0,0)&&j(-1,-1,0,0)&&j(-1,0,0,0)&&j(-1,1,0,0)&&j(-1,2,0,0)&&j(1,-2,0,0)&&j(1,-1,0,0)&&j(1,0,0,0)&&j(1,1,0,0)&&j(1,2,0,0)&&j(2,-2,0,0)&&j(2,-1,0,0)&&j(2,0,0,0)&&j(2,1,0,0)&&j(2,2,0,0)&&j(0,-2,0,0)&&j(0,-1,0,0)&&j(0,1,0,0)&&j(0,2,0,0))) if narg($""3) f. !($__altmode_orientation?i(#-2,floor(x/$__min_tile),0,0,0):i(#-2,floor(y/$__min_tile),0,0,0))?(i?(j(-1,0)||j(0,-1))):i fi rm.. f[0] i(#-1,x,y,z,0)?(xor(i(#-1,x,y,z,0)*$__trackpadcol_alt,i)>128?0:255):i rm. fi if narg($""4)||narg($""5) if $__altsymmetry_mode if $__altmode_orientation {w#0},{$__min_tile},1,{s#0},i(#0,x,$""5+y) {w#0},{$__min_tile},1,{s#0},i(#0,x,$__nh+($__altsymmetry_posy-1)*$__min_tile-$""5+y) f[-2,-1] begin(ww=w-1;hh=h-1;);(x<(2+narg($""3))||x>ww-2)||(y<(2+narg($""3))||y>hh-2)?(xor($__trackpadcol_alt,i)>128?0:255):i j... [-2],0,$""5 j... [-1],0,{h#0+($__altsymmetry_posy-1)*$__min_tile-$""5} else {$__min_tile},{h#0},1,{s#0},i(#0,$""4+x,y) {$__min_tile},{h#0},1,{s#0},i(#0,$__nw+($__altsymmetry_posx-1)*$__min_tile-$""4+x,y) f[-2,-1] begin(ww=w-1;hh=h-1;);(x<(2+narg($""3))||x>ww-2)||(y<(2+narg($""3))||y>hh-2)?(xor($__trackpadcol_alt,i)>128?0:255):i j... [-2],$""4,0 j... [-1],{w#0+($__altsymmetry_posx-1)*$__min_tile-$""4},0 fi rm[-2,-1] else if $__altmode_orientation {w#0},{$__min_tile},1,{s#0},i(#0,x,$""5+y) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""3))||x>ww-2)||(y<(2+narg($""3))||y>hh-2)?(xor($__trackpadcol_alt,i)>128?0:255):i j.. [-1],0,$""5 else {$__min_tile},{h#0},1,{s#0},i(#0,$""4+x,y) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""3))||x>ww-2)||(y<(2+narg($""3))||y>hh-2)?(xor($__trackpadcol_alt,i)>128?0:255):i j.. [-1],$""4,0 fi rm. fi fi if narg($""3) f. begin(ww=w-1;hh=h-1;);(x%$__min_tile==0||y%$__min_tile==0)||(x==ww||y==hh)?$""3:i fi"

m "out2display_alt_perp : skip ${""3=},${""4=} if narg($""3) if $""3 $__bg rv blend alpha fi fi xalp if $__altmode_orientation $__isr {w#0},{$__pdiff*$__min_tile},1,1,i(#-1,floor(y/$__min_tile)+$__pmin,0,0,0) f. i?(!(j(-2,-2)&&j(-2,-1)&&j(-2,0)&&j(-2,1)&&j(-2,2)&&j(-1,-2)&&j(-1,-1)&&j(-1,0)&&j(-1,1)&&j(-1,2)&&j(0,-2)&&j(0,-1)&&j(0,1)&&j(0,2)&&j(1,-2)&&j(1,-1)&&j(1,0)&&j(1,1)&&j(1,2)&&j(2,-2)&&j(2,-1)&&j(2,0)&&j(2,1)&&j(2,2))?(xor($__trackpadcol_alt,i(#0,x,$""2+y))>128?0:255):i(#0,x,$""2+y)):i(#0,x,$""2+y); j[0] [-1],0,$""2 else $__isc {$__pdiff*$__min_tile},{h#0},1,{s#0},i(#-1,floor(x/$__min_tile)+$__pmin,0,0,0) f. i?(!(j(-2,-2)&&j(-2,-1)&&j(-2,0)&&j(-2,1)&&j(-2,2)&&j(-1,-2)&&j(-1,-1)&&j(-1,0)&&j(-1,1)&&j(-1,2)&&j(0,-2)&&j(0,-1)&&j(0,1)&&j(0,2)&&j(1,-2)&&j(1,-1)&&j(1,0)&&j(1,1)&&j(1,2)&&j(2,-2)&&j(2,-1)&&j(2,0)&&j(2,1)&&j(2,2))?(xor($__trackpadcol_alt,i(#0,$""1+x,y))>128?0:255):i(#0,$""1+x,y)):i(#0,$""1+x,y); j[0] [-1],$""1,0 fi rm[-2,-1] if narg($""4) f. begin(ww=w-1;hh=h-1;);(x%$__min_tile==0||y%$__min_tile==0)||(x==ww||y==hh)?$""4:i fi"

m "keeperase_rowcolumn : if $__altmode_orientation $__isr if $""1 f.. i(#-1,floor(y/$__min_tile),0,0,0)?i:0 else f.. i(#-1,floor(y/$__min_tile),0,0,0)?0:1 fi else $__isc if $""1 f.. i(#-1,floor(x/$__min_tile),0,0,0)?i:0 else f.. i(#-1,floor(x/$__min_tile),0,0,0)?0:i fi fi rm."

m "shift_rowcolumn : if $__altmode_orientation $__isr f[0] i(#-1,floor(y/$__min_tile),0,0,0)?j(-$""1,0,0,0,0,$__shiftboundary+($__shiftboundary?1)):i else $__isc f[0] i(#-1,floor(x/$__min_tile),0,0,0)?j(0,-$""2,0,0,0,$__shiftboundary+($__shiftboundary?1)):i fi rm."

m "place_rowcolumn : if $__altmode_orientation if $__altplace_replacemode $__isr pass$""1 0 {w#-1},{h#-1},1,1,i(#-2,floor(y/$__min_tile)+$__pmin,0,0,0) j[0] [-2],0,$""3,0,0,1,[-1],1 else pass$""1 0 {w#0},{h#0},1,{s#0},j(#-1,0,-$""3) rm.. if $__altplacebackmode rv fi blend alpha fi else if $__altplace_replacemode $__isc pass$""1 0 {w#-1},{h#-1},1,1,i(#-2,floor(x/$__min_tile)+$__pmin,0,0,0) j[0] [-2],$""2,0,0,0,1,[-1],1 else pass$""1 0 {w#0},{h#0},1,{s#0},j(#-1,-$""2,0) rm.. if $__altplacebackmode rv fi blend alpha fi fi k[0]"

tiler_noniso_message

if $include_background_image
    pass$1 0
else
    i $1
fi

l.
    xr={ceil(w#-1/(abs($4)*$__min_tile))}
    yr={ceil(h#-1/(abs($5)*$__min_tile))}
    split_tiles. {-abs($4)*$__min_tile},{-abs($5)*$__min_tile}
    mw=${-max_w}
    mh=${-max_h}
    ti={$!}
endl

$__min_tile,$__min_tile,1,4,0
fti={$!}

$__bg
+xalp.

dw0c={w#0}
dh0c={h#0}

dwm0=0
dwm1=0
dwm2=0

d2rw=196

w[-1] {w#0},{h#0},0,"Canvas"
rm[-2,-1]
+xalp[1] 
w1[-1] {w#1},{h#1},0,"Tileset" rm.
w2[-1] $d2rw,$d2rw,0,"Tile"

+store. switchmode_tile

fti={$!}

mode=0

    icx=0
    icy=0
    ci=0
    lr=0
    tb=0
    tbc=0
    ni=1

    cutcopymode=0
    erasemode=0
    replacemode=0
    editmode=0

    symmetrymode=0
    symmetryaxis=0
    symmetrybound=0
    symmetry_posx=0
    symmetry_posy=0

    canvas_background=1
    canvas_gridmode=0
    canvas_tracker=1

    tileset_gridmode=0

    select_from_tileset=0

    resize_tile_from_tileset=0
    resize_tile_from_canvas=0
    transform_tile=0
    switch_tile_set=0

    tile_placement_mode=0

    current_csx=-1
    current_csy=-1
    optinsert=1

#mode=1#

    activated_switched_twice=0
    modeswitched=0
    mainaltmode=1
    viewselectionbox=1
    selectionboxmode=0
    deselectmode=0
    activate_deselect_select=0
    movemode=0
    delmode=0
    transfermode=0

    rowcolumnshiftmode=0
    shiftplacecount=0
    __shiftboundary=1
    altrcx1=-1
    altrcy1=-1
    altrcx2=-1
    altrcx2=-1
    
    
    current_acsx=-1
    current_acsy=-1
    altx=-1
    alty=-1
    tempaltx=-1
    tempalty=-1
    activate_altpreview=0
    activate_altpass2tile=0

    __altsymmetry_mode=0
    __altsymmetry_posx=0
    __altsymmetry_posy=0
    __altmode_orientation=0
    
    __vmax_x=0
    __vmax_y=0
    pmax=0
    __pmin=0
    __pdiff=0
    
    place_rowcolumn_mode=0
    __altplacebackmode=0
    __altplace_replacemode=1

do
    main_w_title="Canvas"
    if $start
        if $mode main_w_title.=" [Row/Column Editing Mode]" 
        else main_w_title.=" [Main Editing Mode] -" fi
    fi
    
    modeswitched=0
    if {*,SPACE}" || "{*1,SPACE}" || "{*2,SPACE}" && "$start mode+=1 mode={$mode%2} modeswitched=1 wait 100 fi
    
    if $modeswitched
        +store. temp_switch_tile
        $switchmode_tile
        rv[-2,-1]
        rm.
        $temp_switch_tile
        store. switchmode_tile
        if $mode
            +out2display. , w2[-1] {w#-1},{h#-1},-1,-1,"Tile" rm.
            w1[] 0
        else
            +out2display. , w2[-1] {$d2rw+($d2rw*$icx)},{$d2rw+($d2rw*$icy)} rm.
            +out2display[$ni] , w1[-1] {w#$ni+$dwm1*w#$ni},{h#$ni+$dwm1*h#$ni} rm.
        fi
    fi
    
    if $start&&$mode
        if {*,G} canvas_gridmode+=1   canvas_gridmode={$canvas_gridmode%2} wait 100 activate_altpreview=1 fi
        if {*,Q} canvas_background+=1 canvas_background={$canvas_background%2} wait 100 activate_altpreview=1 fi
        if {*,A} canvas_tracker+=1 canvas_tracker={$canvas_tracker%2} wait 100 activate_altpreview=1 fi
        if {*,S} __altsymmetry_mode+=1 __altsymmetry_mode={$__altsymmetry_mode%2} wait 200 activate_altpreview=1 fi
        if {*,E} mainaltmode+=1 mainaltmode={$mainaltmode%2} wait 200 activate_altpreview=1 fi
        if {*,V} viewselectionbox+=1 viewselectionbox={$viewselectionbox%2} wait 200 activate_altpreview=1 fi
        
        if $mainaltmode if {*,D} deselectmode+=1 deselectmode={$deselectmode%2} wait 200 activate_altpreview=1 activate_deselect_select=1 fi fi

        undo_state=0
        if {*,Z} undo_state=1 fi
        if $undo_state
            +store[0] temp_undo
            $undo_image
            rv[0,-1]
            rm.
            activate_altpreview=1
            $temp_undo
            store. undo_image
        fi
        
        if {*,T} rowcolumnshiftmode+=1 rowcolumnshiftmode={$rowcolumnshiftmode%2} wait 200 activate_altpreview=1 if $shiftplacecount shiftplacecount=0 fi fi
        if {*,M} __shiftboundary+=1 __shiftboundary={$__shiftboundary%3} wait 200 fi
        if {*,W} w[] 1 w2[] 1 fi
        
        if {*2,ARROWLEFT}" || "{*2,ARROWRIGHT} mirror. x transform_tile=1 wait 100
        elif {*2,ARROWUP}" || "{*2,ARROWDOWN} mirror. y transform_tile=1 wait 100
        fi
        
        if $transform_tile
            +out2display. , w2[-1] rm.
            transform_tile=0
        fi
        
        if !$mainaltmode
            if {*,B} __altplace_replacemode+=1 __altplace_replacemode={$__altplace_replacemode%2} wait 200 fi
            if !$__altplace_replacemode&&{*,F} __altplacebackmode+=1 __altplacebackmode={$__altplacebackmode%2} wait 200 fi
        fi
        
        if {*,R}
            if $__altmode_orientation
                $__isr f. 0 store. __isr __vmax_y=0
            else
                $__isc f. 0 store. __isc __vmax_x=0
            fi
            activate_altpreview=1 
        fi
        
        if $mainaltmode&&!$rowcolumnshiftmode
            if $__altsymmetry_mode
                if $__altmode_orientation
                    if {*,ARROWUP} __altsymmetry_posy-=1  __altsymmetry_posy={max(-$tth,$__altsymmetry_posy)} activate_altpreview=1 wait 200 fi
                    if {*,ARROWDOWN} __altsymmetry_posy+=1 __altsymmetry_posy={min($tth,$__altsymmetry_posy)} activate_altpreview=1 wait 200 fi
                    if {*,ARROWLEFT}||{*,ARROWRIGHT} __altmode_orientation=0 activate_altpreview=1 wait 200 fi
                    if {*,J} __altsymmetry_posy=0 activate_altpreview=1 wait 200 fi
                else
                    if {*,ARROWLEFT} __altsymmetry_posx-=1  __altsymmetry_posx={max(-$ttw,$__altsymmetry_posx)} activate_altpreview=1 wait 200 fi
                    if {*,ARROWRIGHT} __altsymmetry_posx+=1 __altsymmetry_posx={min($ttw,$__altsymmetry_posx)} activate_altpreview=1 wait 200 fi
                    if {*,ARROWUP}||{*,ARROWDOWN} __altmode_orientation=1 activate_altpreview=1 wait 200 fi
                    if {*,J} __altsymmetry_posx=0 activate_altpreview=1 wait 200 fi
                fi
            else
                    if {*,ARROWLEFT}||{*,ARROWRIGHT}||{*,ARROWUP}||{*,ARROWDOWN} __altmode_orientation+=1 __altmode_orientation={$__altmode_orientation%2} activate_altpreview=1 wait 200 fi
            fi
        elif $mainaltmode&&$rowcolumnshiftmode
            if {*,ARROWLEFT}||{*,ARROWRIGHT} __altmode_orientation+=1 __altmode_orientation={$__altmode_orientation%2} activate_altpreview=1 wait 200 fi
        fi
        
        if $mainaltmode&&!$rowcolumnshiftmode
            if $deselectmode main_w_title.=" - [Deselection]"
            else main_w_title.=" - [Selection]"
            fi
        elif $mainaltmode&&$rowcolumnshiftmode
            main_w_title.=" - [Shift] (Boundary Condition - "
            if $__shiftboundary==0 main_w_title.="None)"
            elif $__shiftboundary==1 main_w_title.="Periodic)"
            else main_w_title.="Mirror)"
            fi
        else
            main_w_title.=" - [Place] "
            if $__altplace_replacemode
                main_w_title.="(Replacement Mode)"
            else
                if $__altplacebackmode main_w_title.="(Background)"
                else main_w_title.="(Foreground)"
                fi
            fi
        fi
        
        if $viewselectionbox&&$canvas_gridmode
            canvas_set=$canvas_background,$viewselectionbox,$gridcol,        
        elif $viewselectionbox
            canvas_set=$canvas_background,$viewselectionbox,,
        elif $canvas_gridmode
            canvas_set=$canvas_background,,$gridcol,
        fi
        
        x,y,b,ww,wh={*,x,y,b,w,h}
        
        if $b" && "$x>=0" && "$y>=0" && "$x<w#0" && "$y<h#0" && "!{*,G}
            acsx={floor($x/$__min_tile)} acsy={floor($y/$__min_tile)}
            if $mainaltmode&&!$rowcolumnshiftmode
                if ($__altmode_orientation?(($current_acsy!=$acsy)||$__vmax_y==0):(($current_acsx!=$acsx)||$__vmax_x==0))||$activate_deselect_select
                    if !$deselectmode
                        if !$__altmode_orientation
                            $__isc
                            f. x==$acsx?1:i
                            if $__altsymmetry_mode f. begin(ww=w-1;ww+=$__altsymmetry_posx;);x==(ww-$acsx)?1:i; fi
                            __vmax_x={iM#-1}
                            __pmin={find([crop(#-1)],1,0,1)}
                            pmax={find([crop(#-1)],1,$iscl,-1)}
                            __pdiff={$pmax-$__pmin+1}
                            store. __isc
                        else
                            $__isr
                            f. x==$acsy?1:i
                            if $__altsymmetry_mode f. begin(ww=w-1;ww+=$__altsymmetry_posy;);x==(ww-$acsy)?1:i; fi
                            __vmax_y={iM#-1}
                            __pmin={find([crop(#-1)],1,0,1)}
                            pmax={find([crop(#-1)],1,$isrl,-1)}
                            __pdiff={$pmax-$__pmin+1}
                            store. __isr
                        fi
                    else
                        if !$__altmode_orientation
                            $__isc
                            f. x==$acsx?0:i
                            if $__altsymmetry_mode f. begin(ww=w-1;ww+=$__altsymmetry_posx;);x==(ww-$acsx)?0:i; fi
                            __vmax_x={iM#-1}
                            __pmin={find([crop(#-1)],1,0,1)}
                            pmax={find([crop(#-1)],1,$iscl,-1)}
                            __pdiff={$pmax-$__pmin+1}
                            store. __isc
                        else
                            $__isr
                            f. x==$acsy?0:i
                            if $__altsymmetry_mode f. begin(ww=w-1;ww+=$__altsymmetry_posy;);x==(ww-$acsy)?0:i; fi
                            __vmax_y={iM#-1}
                            __pmin={find([crop(#-1)],1,0,1)}
                            pmax={find([crop(#-1)],1,$isrl,-1)}
                            __pdiff={$pmax-$__pmin+1}
                            store. __isr
                        fi
                    fi
                    activate_altpreview=1
                    activate_altpass2tile=1
                fi
            elif $mainaltmode&&$rowcolumnshiftmode
                if $shiftplacecount==0
                    altrcx1={$acsx*$__min_tile} 
                    altrcy1={$acsy*$__min_tile} 
                    activate_altpreview=1
                    shiftplacecount+=1
                elif $shiftplacecount==1
                    altrcx2={$acsx*$__min_tile} 
                    altrcy2={$acsy*$__min_tile} 
                    activate_altpreview=1
                    shift_rowcolumn[0] {$altrcx2-$altrcx1},{$altrcy2-$altrcy1}
                    if $__altmode_orientation
                        if abs($altrcy2-$altrcy1)
                            +store[0] undo_image
                        fi
                    else
                        if abs($altrcx2-$altrcx1)
                            +store[0] undo_image
                        fi                   
                    fi
                    shiftplacecount=0
                fi 
                wait 100
            else
                place_rowcolumn[0] [-1],{min($acsx,$isw-$__pdiff)*$__min_tile},{min($acsy,$ish-$__pdiff)*$__min_tile}
                +store[0] undo_image
            fi
            current_acsx=$acsx current_acsy=$acsy
        fi
        
        if $__altmode_orientation?$__vmax_y>0:$__vmax_x>0
            if $activate_altpass2tile
                if !$__altmode_orientation
                    r. {$__pdiff*$__min_tile},{h#0}
                    pass2tile. [0],{$__pmin*$__min_tile},0
                else
                    r. {w#0},{$__pdiff*$__min_tile}
                    pass2tile. [0],0,{$__pmin*$__min_tile}
                fi
                filter_to_selected_row_column.
                +out2display. , w2[-1] {w#-1},{h#-1},-1,-1,"Tile" rm.
            fi
            activate_altpass2tile=0
            if {*,K}||{*,C} keeperase_rowcolumn[0] 1 wait 200 activate_altpreview=1 fi
            if {*,X} keeperase_rowcolumn[0] 0 wait 200 activate_altpreview=1 fi
        else
            r. 1,1
            f. 0
            +out2display. , w2[-1] {$d2rw},{$d2rw},-1,-1,"Tile" rm.
            mainaltmode=1
            rowcolumnshiftmode=0
            deselectmode=0
        fi
        
        if $mainaltmode
            if !$rowcolumnshiftmode
                if {$x>=0" && "$y>=0" && "$x<w#0" && "$y<h#0" && "$canvas_tracker}" && "($canvas_tracker||$activate_altpreview)
                    altx={floor($x/$__min_tile)*$__min_tile} alty={floor($y/$__min_tile)*$__min_tile}
                    if ($__altmode_orientation?($alty!=$tempalty):($altx!=$tempaltx))||$activate_altpreview
                        canvas_set.=$altx,$alty
                        +out2display_alt[0] $canvas_set if $__altsymmetry_mode addsym2display. $__altmode_orientation,$__min_tile,$__altsymmetry_posx,$__altsymmetry_posy fi w[-1] {w#0},{h#0},0,$main_w_title rm.
                    fi
                    tempaltx=$altx tempalty=$alty
                else
                    +out2display_alt[0] $canvas_set if $__altsymmetry_mode addsym2display. $__altmode_orientation,$__min_tile,$__altsymmetry_posx,$__altsymmetry_posy fi w[-1] {w#0},{h#0},0,$main_w_title rm.
                fi
                activate_altpreview=0
            else
                if $x>=0" && "$y>=0" && "$x<w#0" && "$y<h#0
                    if $activate_altpreview
                        altx={floor($x/$__min_tile)*$__min_tile} alty={floor($y/$__min_tile)*$__min_tile}
                        if $shiftplacecount
                            if !$__altmode_orientation?($alty!=$tempalty):($altx!=$tempaltx)
                                +shift_rowcolumn[0] {$altx-$altrcx1},{$alty-$altrcy1} 
                                out2display_alt. $canvas_set 
                                w[-1] {w#0},{h#0},0,$main_w_title rm.
                                fi
                            tempaltx=$altx tempalty=$alty
                        else
                            +out2display_alt[0] $canvas_set 
                            w[-1] {w#0},{h#0},0,$main_w_title rm.
                            activate_altpreview=0
                        fi
                    fi
                fi
            fi
        else
            if $canvas_gridmode
                    perp_end=$canvas_background,$gridcol
            else
                    perp_end=$canvas_background
            fi
            if $x>=0" && "$y>=0" && "$x<w#0" && "$y<h#0
                altx={min(floor($x/$__min_tile),$isw-$__pdiff)*$__min_tile} alty={min(floor($y/$__min_tile),$ish-$__pdiff)*$__min_tile}
                if $__altmode_orientation?($alty!=$tempalty):($altx!=$tempaltx)
                    +out2display_alt_perp[0] $altx,$alty,$perp_end w[-1] {w#0},{h#0},0,$main_w_title rm.
                fi
                tempaltx=$altx tempalty=$alty
            fi
        fi
        
    else
        if {*,G} canvas_gridmode+=1   canvas_gridmode={$canvas_gridmode%2} fi
        if {*,Q} canvas_background+=1 canvas_background={$canvas_background%2} fi
        if {*,A} canvas_tracker+=1 canvas_tracker={$canvas_tracker%2} fi
        
        undo_state=0
        canvas_set=""
        
        if {*,W}" || "{*1,W}" || "{*2,W} w[] w1[] w2[] fi
        
        if {*,Z} undo_state=1 fi
        
        if {*,F} tile_placement_mode+=1 tile_placement_mode={$tile_placement_mode%2} fi
        if {*,R}" || "{*1,R}" || "{*2,R} 
            replacemode+=1 replacemode={$replacemode%2} optinsert=1 
        fi
        
        if {*,S} symmetrymode+=1 symmetrymode={$symmetrymode%2} optinsert=1 fi
        
        if $symmetrymode
            if {*,B} symmetryaxis+=1 symmetryaxis={$symmetryaxis%4} wait 200 fi
            if {*,M} symmetrybound+=1 symmetrybound={$symmetrybound%2} wait 200  fi
            if {*,J} symmetry_posx=0 symmetry_posy=0 wait 200 fi
            if {*,ARROWLEFT} symmetry_posx-=1 wait 200 fi
            if {*,ARROWRIGHT} symmetry_posx+=1 wait 200 fi
            if {*,ARROWUP} symmetry_posy-=1 wait 200 fi
            if {*,ARROWDOWN} symmetry_posy+=1 wait 200 fi
            symmetry_posx={$symmetry_posx>=0?min($ttw,$symmetry_posx):max(-$ttw,$symmetry_posx)}
            symmetry_posy={$symmetry_posy>=0?min($tth,$symmetry_posy):max(-$tth,$symmetry_posy)}
        fi
        
        if $canvas_gridmode
            if $canvas_tracker canvas_endset=,$trackpadcol,$gridcol,
            else canvas_endset=,,$gridcol,
            fi
        else
            if $canvas_tracker canvas_endset=,$trackpadcol,
            else canvas_endset=",,"
            fi
        fi
        if {*,C}" || "{*,X}
            if {*,X} cutcopymode=1
            else cutcopymode=2
            fi
        fi
        
        if {*,D}" || "{*1,D}" || "{*2,D}
            erasemode+=1 
            erasemode={$erasemode%2} 
            if $erasemode  +f. 0 w2[-1] {$d2rw+($d2rw*$icx)},{$d2rw+($d2rw*$icy)} rm. 
            else +out2display. , w2[-1] {$d2rw+($d2rw*$icx)},{$d2rw+($d2rw*$icy)} rm.
            fi
            optinsert=1
        fi
        
        x,y,b,ww,wh={*,x,y,b,w,h}
        x1,y1,b1,ww1,wh1={*1,x,y,b,w,h}
        x2,y2,b2,ww2,wh2={*2,x,y,b,w,h}
        
        if $start
            if $undo_state
                +store[0] temp_undo
                $undo_image
                rv[0,-1]
                rm.
                $temp_undo
                store. undo_image
            fi
            
            if {{*2,CTRLLEFT}" || "{*2,CTRLRIGHT}}" && "{{*2,ARROWLEFT}" || "{*2,ARROWRIGHT}}
                mirror. x transform_tile=1
                wait 100
            elif {{*2,CTRLLEFT}" || "{*2,CTRLRIGHT}}" && "{{*2,ARROWUP}" || "{*2,ARROWDOWN}}
                mirror. y transform_tile=1
                wait 100
            elif {*2,ARROWLEFT}||{*2,ARROWRIGHT}
                temp_tile_width=$tile_width
                temp_tile_height=$tile_height
                temp_icx=$icx
                temp_icy=$icy
                icx=$temp_icy
                icy=$temp_icx
                tile_width=$temp_tile_height
                tile_height=$temp_tile_width
                
                if {*2,ARROWRIGHT} rotate. 90 else rotate. -90 fi
                transform_tile=1
                
                wait 100
            fi
            
            if $transform_tile
                +out2display. , w2[-1] {$d2rw+($d2rw*$icx)},{$d2rw+($d2rw*$icy)} rm.
                transform_tile=0
                optinsert=1
            fi
            
            if {{{*1,CTRLLEFT}" || "{*1,CTRLRIGHT}}" && "{*1,ARROWRIGHT}}
                if $select_from_tileset
                    icx+=1
                    icx={min($icx,$max_increment)}
                    tile_width={$__min_tile+($icx*$__min_tile)}
                fi
                        
                if $select_from_tileset resize_tile_from_tileset=1 fi
                
                wait 500
            elif {{{*1,CTRLLEFT}" || "{*1,CTRLRIGHT}}" && "{*1,ARROWLEFT}}
                if $select_from_tileset
                    icx-=1
                    icx={max($icx,0)}
                    tile_width={$__min_tile+($icx*$__min_tile)}
                fi
                        
                if $select_from_tileset resize_tile_from_tileset=1 fi
                
                wait 500
            elif {{{*1,CTRLLEFT}" || "{*1,CTRLRIGHT}}" && "{*1,ARROWDOWN}}
                if $select_from_tileset
                    icy+=1
                    icy={min($icy,$max_increment)}
                    tile_height={$__min_tile+($icy*$__min_tile)}
                fi
                        
                if $select_from_tileset resize_tile_from_tileset=1 fi
                
                wait 500
            elif {{{*1,CTRLLEFT}" || "{*1,CTRLRIGHT}}" && "{*1,ARROWUP}}
                if $select_from_tileset
                    icy-=1
                    icy={max($icy,0)}
                    tile_height={$__min_tile+($icy*$__min_tile)}
                fi
                        
                if $select_from_tileset resize_tile_from_tileset=1 fi
                
                wait 500
            elif {*1,ARROWRIGHT}
                select_from_tileset=0
                lr+=1
                lr={$lr%$xr}
                ci={($lr+$tb)%$ti}
                ni={$ci+1}
                switch_tile_set=1
                wait 625
            elif {*1,ARROWLEFT}
                select_from_tileset=0
                lr-=1
                lr={$lr%$xr}
                ci={($lr+$tb)%$ti}
                ni={$ci+1}
                switch_tile_set=1
                wait 625
            elif {*1,ARROWDOWN}
                select_from_tileset=0
                tbc+=1
                tbc={$tbc%$yr}
                tb={$tbc*$xr}
                ci={($lr+$tb)%$ti}
                ni={$ci+1}
                switch_tile_set=1
                wait 625
            elif {*1,ARROWUP}
                select_from_tileset=0
                tbc-=1
                tbc={$tbc%$yr}
                tb={$tbc*$xr}
                ci={($lr+$tb)%$ti}
                ni={$ci+1}
                switch_tile_set=1
                wait 625
            fi
            
            if $switch_tile_set
                +out2display[$ni] , w1[-1] {w#$ni+$dwm1*w#$ni},{h#$ni+$dwm1*h#$ni} rm.
                switch_tile_set=0
            fi
            
            if $resize_tile_from_tileset
                    r. $tile_width,$tile_height,100%,100%,0
                    pass2tile. [$ni],$tsx,$tsy
                    +out2display. , w2[-1] {$d2rw+($d2rw*$icx)},{$d2rw+($d2rw*$icy)} rm.
                    if $tileset_gridmode
                        +out2display[$ni] 0,$tsx,$tsy,$tile_width,$tile_height,$trackpadcol,$gridcol
                    else
                        +out2display[$ni] 0,$tsx,$tsy,$tile_width,$tile_height,$trackpadcol
                    fi
                    w1[-1] rm.
                    resize_tile_from_tileset=0
            fi
            
            if $b" && "$x>=0" && "$y>=0" && "$x<w#0" && "$y<h#0
                csx={floor($x/$__min_tile)*$__min_tile} csy={floor($y/$__min_tile)*$__min_tile}
                if !$cutcopymode&&!$erasemode
                    if (($current_csx!=$csx)||($current_csy!=$csy))||$optinsert
                        +store[0] undo_image
                        if $replacemode 
                            if $symmetrymode
                                tile2canvas_r_sym[0,-1] $csx,$csy,$tile_width,$tile_height,$symmetrybound,$symmetryaxis,$symmetry_posx,$symmetry_posy
                            else
                                tile2canvas_r[0,-1] $csx,$csy,$tile_placement_mode
                            fi
                        else
                            if $symmetrymode 
                                tile2canvas_sym[0] [-1],$csx,$csy,$tile_width,$tile_height,$tile_placement_mode,$symmetrybound,$symmetryaxis,$symmetry_posx,$symmetry_posy
                            else 
                                tile2canvas[0] [-1],$csx,$csy,$tile_placement_mode
                            fi
                        fi
                    fi
                    optinsert=0
                elif $cutcopymode&&!$erasemode
                    if $cutcopymode==1 
                        +store[0] undo_image
                        pass2tile. [0],$cx,$cy {w#-1},{h#-1},1,{s#-1} j[0] [-1],$cx,$cy rm.
                    else 
                        pass2tile. [0],$csx,$csy optinsert=0
                    fi
                    +out2display. , w2[-1] {$d2rw+($d2rw*$icx)},{$d2rw+($d2rw*$icy)} rm. 
                    cutcopymode=0
                    optinsert=1
                else
                    +store[0] undo_image
                    cutcopymode=0
                    if (($current_csx!=$csx)||($current_csy!=$csy))||$optinsert
                        if $symmetrymode
                            $tile_width,$tile_height,1,{s#0}
                            j[0] [-1],$csx,$csy 
                            if $symmetryaxis==3||$symmetryaxis==0 j[0] [-1],{$__nw+($__min_tile*$symmetry_posx)-$tile_width-$csx},$csy fi 
                            if $symmetryaxis==3||$symmetryaxis==1 j[0] [-1],$csx,{$__nh+($__min_tile*$symmetry_posy)-$tile_height-$csy} fi 
                            if $symmetryaxis==3||$symmetryaxis==2 j[0] [-1],{$__nw+($__min_tile*$symmetry_posx)-$tile_width-$csx},{$__nh+($__min_tile*$symmetry_posy)-$tile_height-$csy} fi 
                            rm.
                        else
                            $tile_width,$tile_height,1,{s#0} j[0] [-1],$csx,$csy rm.
                        fi
                    fi
                fi
                current_csx=$csx current_csy=$csy
            fi
        
        fi
        
        if $b1" && "$x1>=0" && "$y1>=0" && "$x1<w#1" && "$y1<h#1
            cutcopymode=0
            start=1
            optinsert=1
            select_from_tileset=1
            erasemode=0
            tsx={floor($x1/$__min_tile)*$__min_tile} tsy={floor($y1/$__min_tile)*$__min_tile}
            pass2tile. [$ni],$tsx,$tsy
            +out2display. , w2[-1] rm.
            
            if $tileset_gridmode
                +out2display[$ni] 0,$tsx,$tsy,$tile_width,$tile_height,$trackpadcol,$gridcol
            else
                +out2display[$ni] 0,$tsx,$tsy,$tile_width,$tile_height,$trackpadcol
            fi
            w1[-1] rm.
            
            wait 50
        fi
        
        if !$start
            if $canvas_gridmode
                +out2display[0] $canvas_background,0,0,1,1,,$gridcol
            else
                +out2display[0] $canvas_background
            fi
            if $symmetrymode addsym2display. $symmetryaxis,$__min_tile,$symmetry_posx,$symmetry_posy fi
            w[-1] rm.
        else
            if $x>=0" && "$y>=0" && "$x<w#0" && "$y<h#0
                cx={floor($x/$__min_tile)*$__min_tile} cy={floor($y/$__min_tile)*$__min_tile}
                canvas_set=$canvas_background,$cx,$cy,$tile_width,$tile_height
                canvas_set.=$canvas_endset
                if $symmetrymode
                    if $canvas_gridmode canvas_set.=$symmetryaxis,$symmetry_posx,$symmetry_posy
                    else canvas_set.=,$symmetryaxis,$symmetry_posx,$symmetry_posy
                    fi
                fi
                +out2display[0] $canvas_set
                if $symmetrymode addsym2display. $symmetryaxis,$__min_tile,$symmetry_posx,$symmetry_posy fi
                w[-1]
                rm.
            else
                if $canvas_gridmode
                    +out2display[0] $canvas_background,0,0,1,1,,$gridcol
                else
                    +out2display[0] $canvas_background
                fi
                if $symmetrymode addsym2display. $symmetryaxis,$__min_tile,$symmetry_posx,$symmetry_posy fi
                w[-1] rm.
            fi
        fi
        
        if $start
            if $erasemode main_w_title.=" (Eraser Mode) - " 
            else 
                if $cutcopymode
                    if $cutcopymode==2 main_w_title.=" (Copy Mode) - " 
                    else main_w_title.=" (Cut Mode) - " 
                    fi
                else
                    if $replacemode main_w_title.=" (Replacement Mode) - " 
                    else 
                        if $tile_placement_mode main_w_title.=" (Place Tile [Background]) - " 
                        else main_w_title.=" (Place Tile [Foreground]) - " 
                        fi
                    fi
                fi
            fi

            if $canvas_tracker main_w_title.="(Tracker)" fi
            if $canvas_gridmode main_w_title.="(Grid)" fi
            if $symmetrymode 
                if $symmetryaxis==0  
                    if $symmetrybound main_w_title.="(Symmetry-X (Mirror))"
                    else main_w_title.="(Symmetry-X (Periodic))"
                    fi
                elif $symmetryaxis==1 
                    if $symmetrybound main_w_title.="(Symmetry-Y (Mirror))"
                    else main_w_title.="(Symmetry-Y (Periodic))"
                    fi
                elif $symmetryaxis==2 
                    if $symmetrybound main_w_title.="(Symmetry-XY (Corner) (Mirror))"
                    else main_w_title.="(Symmetry-XY (Corner)(Periodic))"
                    fi
                else                  
                    if $symmetrybound main_w_title.="(Symmetry-XY (Reflected) (Mirror))"
                    else main_w_title.="(Symmetry-XY (Reflected) (Periodic))"
                    fi
                fi
            fi
        fi    
        w[] -1,-1,-1,-1,$main_w_title
    fi
    wait 100
while {*}" && "!{*,ESC}
uncommand xalp,xalpa,out2display,pass2tile,tile2canvas,tile2canvas_r,tile2canvas_sym,tile2canvas_r_sym,addsym2display,filter_to_selected_row_column,out2display_alt,out2display_alt_perp,keeperase_rowcolumn,shift_rowcolumn,place_rowcolumn,tiler_noniso_message
w1[] 0
w2[] 0
k[0]
if $7 $obg rv blend alpha fi

__rep_tiler_nonisometric_instructions:
e[] "\n Instruction on how to work with interactive windows.\n
 \ ---------------------------------------------------------\n\n
 \ MAIN EDITING MODE\n\n
 \ - On any window - \n
 \   * D: Switch between Place/Eraser Mode\n
 \   * R: Activate Replace Mode\n
 \   * W: Restore All Windows\n
 \   * SPACEBAR: Switch Mode\n\n
 \ - On Canvas window - \n
 \   * C: Activate Copy Mode On/Off\n
 \   * X: Activate Cut Mode On/Off\n
 \   * Z: Undo Canvas Changes\n
 \   * F: Activate/Deactivate Background Tile Layering Mode\n
 \   * G: Activate Canvas Grid Mode On/Off\n
 \   * Q: Remove/Restore Background\n
 \   * A: Enable/Disable Tracker\n
 \   * S: Activate Symmetry Mode\n\n
 \   -- On Canvas [Symmetry Mode] --\n
 \     * B: Switch Axis in Symmetry Mode\n
 \     * M: Switch between Periodic/Mirror mode in Symmetry Mode\n
 \     * J: Symmetry Line to Center\n
 \     * ARROWKEY: Move Symmetry Line\n\n
 \ - On Tileset window - \n
 \   * CTRL+ARROWKEY: Resize Tile Selection Box\n
 \   * ARROWKEY: Scroll through tileset\n\n
 \ - On Tile window - \n
 \   * CTRL+ARROWKEY: Mirror alongside axis\n
 \   * ARROWKEY: Rotate Tile\n
 \   * MOUSE BUTTON: Switch between Place/Eraser Mode\n\n
 \ ROW/COLUMN EDITING MODE\n\n
 \ - On any window - \n
 \   * W: Restore All Windows\n
 \   * SPACEBAR: Switch Mode\n\n
 \ - On Canvas window - \n
 \   * Z: Undo Canvas Changes\n  
 \   * T: Enable Row/Column Shifting\n
 \   * E: Activate Row/Column Perpendicular Place Mode\n
 \   * V: View Selection Box\n
 \   * G: Activate Canvas Grid Mode On/Off\n
 \   * Q: Remove/Restore Background\n
 \   * A: Enable/Disable Tracker\n
 \   * S: Activate Symmetry Mode (Works only on Selection Mode)\n\n
 \   -- On Canvas [Selection Mode] --\n
 \     * C: Keep Selected Row/Column\n
 \     * X: Delete Selected Row/Column\n
 \     * D: Select/Deselect Row/Column\n
 \     * R: Clear Selection\n
 \     * Mouse Button: Select or Deselect\n
 \     * ARROWKEY: Switch between row/column manipulation mode\n\n
 \   -- On Canvas [Selection Mode](Symmetry Mode)--\n
 \     * J: Symmetry Line to Center\n
 \     * ARROWKEY: Switch between row/column manipulation mode or move symmetry line\n\n
 \   -- On Canvas [Row/Column Shifting Mode] --\n
 \     * Mouse Button (First Click): Activate Shifting\n
 \     * Mouse Button (Second Click): Finalize Shifting\n 
 \     * ARROWKEY: Switch between row/column manipulation\n\n
 \   -- On Canvas [Place Mode] --\n
 \     * B: Switch between Replacement/Placement Mode\n
 \     * F: In Placement Mode, switch between background/foreground placement mode\n
 \     * Mouse Button: Place Row/Column\n\n  
 \ - On Tile window - \n
 \   * ARROWKEY: Flip Row/Column\n
 \ ---------------------------------------------------------\n"

Where do you want to echo?

You mean you want to cut and paste too?

All I want is the echo block found at bottom of the pasted text to show up on my cmd window if I use either the shortcut or long name. If I paste the e[] block only on one, it’ll work on that command only. You’d note my attempt with merging command, and unmerged version didn’t work. I just want only one copy of e[] block.

Could you place the code into a gist or pastebin so that it is easy to view or copy? Not the easiest to read inline because it is so amazingly long. Also, if you could, only paste the relevant parts. Such a huge block kills the motivation to help.

Without looking at the code, perhaps raising the verbosity in the shortcut command may help.

Here’s the trimmed code - https://pastebin.com/di0QQuti

I’ll try verbosity then

Adding a v 0 before the echo will force the message to display.

@afre @David_Tschumperle
Working with verbosity solved it. Thank you.

Also, @David_Tschumperle : I sent you a PM.

As the question may interest others, I propose to answer here. @Reptorian asked for having a tileset on the G’MIC server so that his filter can download it.
This raises the more general question of filters that requires external data.

My opinion on that is:

  1. In the case your data are small enough, then it’s probably easier to embed the image data directly in your .gmic file. For this, it’s convenient to use commands img2base64 and base642img that encodes the image content as a base64 string. In the case of the tileset, the image is relatively small (320x128 RGBA), so it’s probably the best solution. You can do either:
$ gmic tileset.png img2base64 0 e "${}"

Then copy-paste the long string that displays on the console, and use base642img to retrieve the image:

$ gmic base642img MiB1bnNpZ25lZF9jaGFyIGxpdHRsZV9lbmRpYW4KMSA1ODY1IDE...

If it’s a bit large, then you can even use base642img not to have a representation of the image pixels, but of the .png binary file instead:

$ gmic it tileset.png img2base64 0 e "${}"

And get the file back with :

$ gmic base642img .... ot tileset.png

(you can output it as ${-path_tmp}tileset.png for instance).

  1. If your image data are large, then it’s better to host it on a server. I’m not very keen on the idea of hosting all these filter data directly on the G’MIC server, because I have a “personal pages” subscription type for web hosting, with relatively little disk space (it’s much cheaper).
    It’s better to try to find a server where you can put your data permanently, and where you’ll have more facilities to update them if needed. But of course, if you really need it, we can think about hosting your filter data on gmic.eu.
1 Like

@bazza @afre @David_Tschumperle @hover @chris and others…

Thank you guys for the support.

I have updated this filter to version 3 (huge changes as in 844 additions and 344 deletions) and I believe this thread can be concluded though I’m leaving it open for bug report specifically for this tool or if anyone wants to upgrade this to version 4 which will be about tiledata import/export.

1 Like

You could make a puzzle out of this. Scramble and rotate the tiles, place in tile set window and the user solves the puzzle on the canvas.

If user input image isn’t specified, take an image from sample. Throw a timer in for good measure. Doable!

I guess one can write a command to scramble tiles of original image.

The command should work as followed.

  1. Find the ceil of width/height divided by tile size. I’ll name them nx, and ny.
  2. Resize the original image using the found numbers multiplied by the tile size. Interpolation must be zero!
  3. Create a series of 1x1 pixels containing relative coordinate.
  4. Scramble them.
  5. Create a new image with the nx,ny.
  6. j[new_image] [1x1 series],x,y.

Now you have a way to create a puzzle automatically.

It been a while since I posted here. I have added 3 neumann mode to row/column editing tool. They’re modes useful for platformer as they address problems with periodic shifting and mirror shifting.

Neumann-Periodic: The last or first tile gets repeated and the position is one and the same.

Neumann-Mirror: The last or first tile gets repeated, but however the position is flipped for every new tiles in a periodic fashion.

Neumann-Alternating: The last or first tile gets repeated, but however the position is alternating.

Two bugs down to go after I caught them. I’ll fix it very soon.


Okay, now the tiling tool seem to have nearly zero bugs or maybe zero (unlikely, but I haven’t spot any).