diff options
Diffstat (limited to 'src/render/renderdocument.nim')
-rw-r--r-- | src/render/renderdocument.nim | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim index d18dbdd5..00719023 100644 --- a/src/render/renderdocument.nim +++ b/src/render/renderdocument.nim @@ -14,9 +14,9 @@ import types/color import utils/twtstr func formatFromWord(computed: ComputedFormat): Format = - result.fgcolor = computed.color.cellColor() + result.fgcolor = cellColor(computed.color) if computed.bgcolor.a != 0: - result.bgcolor = computed.bgcolor.cellColor() + result.bgcolor = cellColor(computed.bgcolor) if computed.fontstyle in { FONT_STYLE_ITALIC, FONT_STYLE_OBLIQUE }: result.italic = true if computed.fontweight > 500: @@ -127,28 +127,25 @@ proc setText(lines: var FlexibleGrid, linestr: string, cformat: ComputedFormat, lnode = lines[y].formats[fi].node if lines[y].formats[fi].pos == x: # Replace. - if cformat.bgcolor.a == 0: #TODO alpha blending - # We must check if the old string's last x position is greater than - # the new string's first x position. If not, we cannot inherit - # its bgcolor (which is supposed to end before the new string started.) - if nx > cx: - format.bgcolor = lines[y].formats[fi].format.bgcolor + # We must check if the old string's last x position is greater than + # the new string's first x position. If not, we cannot inherit + # its bgcolor (which is supposed to end before the new string started.) + if nx > cx: + format.bgcolor = lines[y].formats[fi].format.bgcolor.blend(format.bgcolor) lines[y].formats.delete(fi) lines[y].insertFormat(x, fi, format, cformat.node) else: # First format's pos < x => split it up. assert lines[y].formats[fi].pos < x - if cformat.bgcolor.a == 0: #TODO alpha blending - if nx > cx: # see above - format.bgcolor = lines[y].formats[fi].format.bgcolor + if nx > cx: # see above + format.bgcolor = format.bgcolor.blend(lines[y].formats[fi].format.bgcolor) inc fi # insert after first format lines[y].insertFormat(x, fi, format, cformat.node) inc fi # skip last format while fi < lines[y].formats.len and lines[y].formats[fi].pos < nx: # Other formats must be > x => replace them - if cformat.bgcolor.a == 0: #TODO alpha blending - format.bgcolor = lines[y].formats[fi].format.bgcolor + format.bgcolor = lines[y].formats[fi].format.bgcolor let px = lines[y].formats[fi].pos lformat = lines[y].formats[fi].format # save for later use lnode = lines[y].formats[fi].node @@ -200,7 +197,7 @@ proc setSpacing(lines: var FlexibleGrid, spacing: InlineSpacing, x, y: int, wind lines.setText(linestr, spacing.format, x, y) proc paintBackground(lines: var FlexibleGrid, color: RGBAColor, startx, starty, endx, endy: int, node: StyledNode, window: WindowAttributes) = - let color = color.cellColor() + let color = cellColor(color) var starty = starty div window.ppl var endy = endy div window.ppl @@ -333,8 +330,8 @@ proc renderBlockBox(grid: var FlexibleGrid, box: BlockBox, x, y: int, window: Wi posy = y if box.computed{"visibility"} == VISIBILITY_VISIBLE: - if box.computed{"background-color"}.a != 0: #TODO color blending - grid.paintBackground(box.computed{"background-color"}, x, y, x + box.width, y + box.height, box.node, window) + grid.paintBackground(box.computed{"background-color"}, x, y, + x + box.width, y + box.height, box.node, window) if box.computed{"background-image"}.t == CONTENT_IMAGE and box.computed{"background-image"}.s != "": # ugly hack for background-image display... TODO actually display images let s = "[img]" |