|
|
|
@ -148,7 +148,7 @@ class CanvasLayer(): |
|
|
|
data = self._data |
|
|
|
data = self._data |
|
|
|
colors = self._colors |
|
|
|
colors = self._colors |
|
|
|
if 0<=x<w and 0<=y<h: |
|
|
|
if 0<=x<w and 0<=y<h: |
|
|
|
return data[oy+y][ox+x] != ' ' or colors[oy+y][ox+x].background() |
|
|
|
return data[oy+y][ox+x] != ' ' or colors[oy+y][ox+x].hasBackground() |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def move(self,x,y): |
|
|
|
def move(self,x,y): |
|
|
|
@ -251,7 +251,7 @@ class CanvasLayer(): |
|
|
|
xa,xb,ya,yb = 0x10000,0,0x10000,0 |
|
|
|
xa,xb,ya,yb = 0x10000,0,0x10000,0 |
|
|
|
for y,(drow,crow) in enumerate(zip(data,colors)): |
|
|
|
for y,(drow,crow) in enumerate(zip(data,colors)): |
|
|
|
for x,(d,c) in enumerate(zip(drow,crow)): |
|
|
|
for x,(d,c) in enumerate(zip(drow,crow)): |
|
|
|
if d != ' ' or c.background(): |
|
|
|
if d != ' ' or c.hasBackground(): |
|
|
|
xa,xb = min(x,xa),max(x,xb) |
|
|
|
xa,xb = min(x,xa),max(x,xb) |
|
|
|
ya,yb = min(y,ya),max(y,yb) |
|
|
|
ya,yb = min(y,ya),max(y,yb) |
|
|
|
if (xa,xb,ya,yb) == (0x10000,0,0x10000,0): |
|
|
|
if (xa,xb,ya,yb) == (0x10000,0,0x10000,0): |
|
|
|
@ -278,9 +278,8 @@ class CanvasLayer(): |
|
|
|
palette = outData['palette'] = [] |
|
|
|
palette = outData['palette'] = [] |
|
|
|
for row in colors: |
|
|
|
for row in colors: |
|
|
|
for c in row: |
|
|
|
for c in row: |
|
|
|
colorType = c.colorType() |
|
|
|
fg = f"{c.getHex(ttk.TTkK.ColorType.Foreground)}" if c.hasForeground() else None |
|
|
|
fg = f"{c.getHex(ttk.TTkK.ColorType.Foreground)}" if (colorType&ttk.TTkK.ColorType.Foreground) else None |
|
|
|
bg = f"{c.getHex(ttk.TTkK.ColorType.Background)}" if c.hasBackground() else None |
|
|
|
bg = f"{c.getHex(ttk.TTkK.ColorType.Background)}" if (colorType&ttk.TTkK.ColorType.Background) else None |
|
|
|
|
|
|
|
if (pc:=(fg,bg)) not in palette: |
|
|
|
if (pc:=(fg,bg)) not in palette: |
|
|
|
palette.append(pc) |
|
|
|
palette.append(pc) |
|
|
|
|
|
|
|
|
|
|
|
@ -297,9 +296,8 @@ class CanvasLayer(): |
|
|
|
for row in colors[hslice]: |
|
|
|
for row in colors[hslice]: |
|
|
|
outData['colors'].append([]) |
|
|
|
outData['colors'].append([]) |
|
|
|
for c in row[wslice]: |
|
|
|
for c in row[wslice]: |
|
|
|
colorType = c.colorType() |
|
|
|
fg = f"{c.getHex(ttk.TTkK.ColorType.Foreground)}" if c.hasForeground() else None |
|
|
|
fg = f"{c.getHex(ttk.TTkK.ColorType.Foreground)}" if (colorType&ttk.TTkK.ColorType.Foreground) else None |
|
|
|
bg = f"{c.getHex(ttk.TTkK.ColorType.Background)}" if c.hasBackground() else None |
|
|
|
bg = f"{c.getHex(ttk.TTkK.ColorType.Background)}" if (colorType&ttk.TTkK.ColorType.Background) else None |
|
|
|
|
|
|
|
if palette: |
|
|
|
if palette: |
|
|
|
outData['colors'][-1].append(palette.index((fg,bg))) |
|
|
|
outData['colors'][-1].append(palette.index((fg,bg))) |
|
|
|
else: |
|
|
|
else: |
|
|
|
@ -387,7 +385,7 @@ class CanvasLayer(): |
|
|
|
xa,xb,ya,yb = 0x10000,0,0x10000,0 |
|
|
|
xa,xb,ya,yb = 0x10000,0,0x10000,0 |
|
|
|
for y,(drow,crow) in enumerate(zip(tmpd,tmpc)): |
|
|
|
for y,(drow,crow) in enumerate(zip(tmpd,tmpc)): |
|
|
|
for x,(d,c) in enumerate(zip(drow,crow)): |
|
|
|
for x,(d,c) in enumerate(zip(drow,crow)): |
|
|
|
if d != ' ' or c.background(): |
|
|
|
if d != ' ' or c.hasBackground(): |
|
|
|
xa,xb = min(x,xa),max(x,xb) |
|
|
|
xa,xb = min(x,xa),max(x,xb) |
|
|
|
ya,yb = min(y,ya),max(y,yb) |
|
|
|
ya,yb = min(y,ya),max(y,yb) |
|
|
|
if (xa,xb,ya,yb) == (0x10000,0,0x10000,0): |
|
|
|
if (xa,xb,ya,yb) == (0x10000,0,0x10000,0): |
|
|
|
@ -414,7 +412,7 @@ class CanvasLayer(): |
|
|
|
xa,xb,ya,yb = 0x10000,0,0x10000,0 |
|
|
|
xa,xb,ya,yb = 0x10000,0,0x10000,0 |
|
|
|
for y,(drow,crow) in enumerate(zip(tmpd,tmpc)): |
|
|
|
for y,(drow,crow) in enumerate(zip(tmpd,tmpc)): |
|
|
|
for x,(d,c) in enumerate(zip(drow,crow)): |
|
|
|
for x,(d,c) in enumerate(zip(drow,crow)): |
|
|
|
if d != ' ' or c.background(): |
|
|
|
if d != ' ' or c.hasBackground(): |
|
|
|
xa,xb = min(x,xa),max(x,xb) |
|
|
|
xa,xb = min(x,xa),max(x,xb) |
|
|
|
ya,yb = min(y,ya),max(y,yb) |
|
|
|
ya,yb = min(y,ya),max(y,yb) |
|
|
|
if (xa,xb,ya,yb) == (0x10000,0,0x10000,0): |
|
|
|
if (xa,xb,ya,yb) == (0x10000,0,0x10000,0): |
|
|
|
@ -495,14 +493,14 @@ class CanvasLayer(): |
|
|
|
colors[oy+y][ox+x] = color |
|
|
|
colors[oy+y][ox+x] = color |
|
|
|
else: |
|
|
|
else: |
|
|
|
glyph = data[ oy+y][ox+x] |
|
|
|
glyph = data[ oy+y][ox+x] |
|
|
|
oColorType = (oc:=colors[oy+y][ox+x]).colorType() |
|
|
|
oc = colors[oy+y][ox+x] |
|
|
|
nColorType = (nc:=color).colorType() |
|
|
|
nc = color |
|
|
|
if glyph==' ': |
|
|
|
if glyph==' ': |
|
|
|
if oColorType & ttk.TTkK.ColorType.Background: |
|
|
|
if oc.hasBackground(): |
|
|
|
colors[oy+y][ox+x] = nc.background() |
|
|
|
colors[oy+y][ox+x] = oc.background() |
|
|
|
else: |
|
|
|
else: |
|
|
|
fg = nc.foreground() if ttk.TTkK.ColorType.Foreground & nColorType else oc.foreground() |
|
|
|
fg = nc.foreground() if nc.hasForeground() else oc.foreground() |
|
|
|
bg = nc.background() if ttk.TTkK.ColorType.Background & nColorType & oColorType else oc.background() if ttk.TTkK.ColorType.Background & oColorType else fg |
|
|
|
bg = nc.background() if nc.hasBackground() and oc.hasBackground() else oc.background() if oc.hasBackground() else fg |
|
|
|
color = fg+bg |
|
|
|
color = fg+bg |
|
|
|
colors[oy+y][ox+x] = color |
|
|
|
colors[oy+y][ox+x] = color |
|
|
|
return True |
|
|
|
return True |
|
|
|
@ -530,7 +528,7 @@ class CanvasLayer(): |
|
|
|
|
|
|
|
|
|
|
|
for _y,(darow,carow) in enumerate(zip(darea,carea),oy+y): |
|
|
|
for _y,(darow,carow) in enumerate(zip(darea,carea),oy+y): |
|
|
|
for _x,(da,ca) in enumerate(zip(darow,carow),ox+x): |
|
|
|
for _x,(da,ca) in enumerate(zip(darow,carow),ox+x): |
|
|
|
if 0<=_x<w and 0<=_y<h and ( da!=' ' or ca.background()): |
|
|
|
if 0<=_x<w and 0<=_y<h and ( da!=' ' or ca.hasBackground()): |
|
|
|
if not transparent or (da==' ' and ca._bg): |
|
|
|
if not transparent or (da==' ' and ca._bg): |
|
|
|
data[_y][_x] = da |
|
|
|
data[_y][_x] = da |
|
|
|
colors[_y][_x] = ca |
|
|
|
colors[_y][_x] = ca |
|
|
|
|