mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +00:00
Implements invert colours operator.
liboperators/OperatorInvert.py: initial implementation. libroar/RoarCanvasCommandsOperators.py: adds OperatorInvert. assets/text/TODO: updated.
This commit is contained in:
parent
498a20cd28
commit
738b1db74e
@ -11,7 +11,7 @@
|
||||
High-priority list:
|
||||
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
|
||||
3) operators: erase, invert, rotate, scale, shift, slice, tile
|
||||
3) operators: erase, rotate, scale, shift, slice, tile
|
||||
4) GUI:
|
||||
a) switch to GTK
|
||||
b) replace logo w/ canvas panel in About dialogue
|
||||
|
24
liboperators/OperatorInvert.py
Normal file
24
liboperators/OperatorInvert.py
Normal 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
|
@ -6,6 +6,7 @@
|
||||
|
||||
from OperatorFlipHorizontal import OperatorFlipHorizontal
|
||||
from OperatorFlipVertical import OperatorFlipVertical
|
||||
from OperatorInvert import OperatorInvert
|
||||
from GuiFrame import GuiCommandListDecorator
|
||||
from ToolObject import ToolObject
|
||||
import copy, wx
|
||||
@ -14,9 +15,10 @@ class RoarCanvasCommandsOperators():
|
||||
# {{{ canvasOperator(self, f, idx)
|
||||
@GuiCommandListDecorator(0, "Flip", "&Flip", 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_(event):
|
||||
applyOperator = [OperatorFlipVertical, OperatorFlipHorizontal][idx]()
|
||||
applyOperator = [OperatorFlipVertical, OperatorFlipHorizontal, OperatorInvert][idx]()
|
||||
if (self.currentTool.__class__ == ToolObject) \
|
||||
and (self.currentTool.toolState >= self.currentTool.TS_SELECT):
|
||||
region = self.currentTool.getRegion(self.parentCanvas.canvas)
|
||||
@ -56,7 +58,7 @@ class RoarCanvasCommandsOperators():
|
||||
def __init__(self):
|
||||
self.menus = (
|
||||
("&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 = ()
|
||||
|
Loading…
Reference in New Issue
Block a user