Implement painting of cells

This commit is contained in:
Kovid Goyal
2016-10-15 14:26:53 +05:30
parent 59f92f9db8
commit 0336873afc
5 changed files with 186 additions and 9 deletions
+11
View File
@@ -2,7 +2,10 @@
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from typing import Tuple, Dict, Union
from numpy import zeros, dtype
from PyQt5.QtGui import QColor
color_type = dtype([('type', 'u1'), ('r', 'u1'), ('g', 'u1'), ('b', 'u1')])
@@ -22,3 +25,11 @@ class Line:
self.strikethrough = zeros(sz, bool)
self.decoration = zeros(sz, 'u1')
self.decoration_fg = zeros(sz, color_type)
def as_color(entry: Tuple[int, int, int, int], color_table: Dict[int, QColor]) -> Union[QColor, None]:
t, r, g, b = entry
if t == 1:
return color_table.get(r)
if t == 2:
return QColor(r, g, b)