Implements invert colours operator.

liboperators/OperatorInvert.py: initial implementation.
libroar/RoarCanvasCommandsOperators.py: adds OperatorInvert.
assets/text/TODO: updated.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-15 20:43:49 +02:00
parent af5363cf04
commit aed3f7157c
3 changed files with 29 additions and 3 deletions

View File

@ -11,7 +11,7 @@
High-priority list: High-priority list:
1) unit tools: arrow, {cloud,speech bubble}, curve, measure, pick, polygon, triangle, unicode 1) unit tools: arrow, {cloud,speech bubble}, curve, measure, pick, polygon, triangle, unicode
2) text tool: a) honour RTL text flow b) navigating w/ cursor keys c) pasting text 2) text tool: a) honour RTL text flow b) navigating w/ cursor keys c) pasting text
3) operators: erase, invert, rotate, scale, shift, slice, tile 3) operators: erase, rotate, scale, shift, slice, tile
4) GUI: 4) GUI:
a) switch to GTK a) switch to GTK
b) replace logo w/ canvas panel in About dialogue b) replace logo w/ canvas panel in About dialogue

View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
#
# OperatorInvert.py
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
#
from Operator import Operator
class OperatorInvert(Operator):
name = "Invert colours"
#
# apply(self, region)
def apply(self, region):
for numRow in range(len(region)):
for numCol in range(len(region[numRow])):
region[numRow][numCol][0:2] = [(~r & (16 - 1) if r > 0 else r) for r in region[numRow][numCol][0:2]]
return region
# __init__(self, *args): initialisation method
def __init__(self, *args):
pass
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -6,6 +6,7 @@
from OperatorFlipHorizontal import OperatorFlipHorizontal from OperatorFlipHorizontal import OperatorFlipHorizontal
from OperatorFlipVertical import OperatorFlipVertical from OperatorFlipVertical import OperatorFlipVertical
from OperatorInvert import OperatorInvert
from GuiFrame import GuiCommandListDecorator from GuiFrame import GuiCommandListDecorator
from ToolObject import ToolObject from ToolObject import ToolObject
import copy, wx import copy, wx
@ -14,9 +15,10 @@ class RoarCanvasCommandsOperators():
# {{{ canvasOperator(self, f, idx) # {{{ canvasOperator(self, f, idx)
@GuiCommandListDecorator(0, "Flip", "&Flip", None, None, None) @GuiCommandListDecorator(0, "Flip", "&Flip", None, None, None)
@GuiCommandListDecorator(1, "Flip horizontally", "Flip &horizontally", None, None, None) @GuiCommandListDecorator(1, "Flip horizontally", "Flip &horizontally", None, None, None)
@GuiCommandListDecorator(2, "Invert", "&Invert", None, None, None)
def canvasOperator(self, f, idx): def canvasOperator(self, f, idx):
def canvasOperator_(event): def canvasOperator_(event):
applyOperator = [OperatorFlipVertical, OperatorFlipHorizontal][idx]() applyOperator = [OperatorFlipVertical, OperatorFlipHorizontal, OperatorInvert][idx]()
if (self.currentTool.__class__ == ToolObject) \ if (self.currentTool.__class__ == ToolObject) \
and (self.currentTool.toolState >= self.currentTool.TS_SELECT): and (self.currentTool.toolState >= self.currentTool.TS_SELECT):
region = self.currentTool.getRegion(self.parentCanvas.canvas) region = self.currentTool.getRegion(self.parentCanvas.canvas)
@ -56,7 +58,7 @@ class RoarCanvasCommandsOperators():
def __init__(self): def __init__(self):
self.menus = ( self.menus = (
("&Operators", ("&Operators",
self.canvasOperator(self.canvasOperator, 0), self.canvasOperator(self.canvasOperator, 1), self.canvasOperator(self.canvasOperator, 0), self.canvasOperator(self.canvasOperator, 1), self.canvasOperator(self.canvasOperator, 2),
), ),
) )
self.toolBars = () self.toolBars = ()