From 7146419b06c87eb00a51b16d5bec3e22b7d0a949 Mon Sep 17 00:00:00 2001 From: bptato Date: Fri, 16 Dec 2022 19:01:56 +0100 Subject: Display text for img tag, background-image --- src/render/renderdocument.nim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/render') diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim index 914ada85..bdcf4df8 100644 --- a/src/render/renderdocument.nim +++ b/src/render/renderdocument.nim @@ -300,6 +300,18 @@ proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockBox, x, y: int, window if ctx.computed{"background-color"}.a != 0: #TODO color blending grid.paintBackground(ctx.computed{"background-color"}, x, y, x + ctx.width, y + ctx.height, window) + if ctx.computed{"background-image"}.t == CONTENT_IMAGE: + # ugly hack for background-image display... TODO actually implement images + let s = ctx.computed{"background-image"}.s # [img] + let w = s.len * window.ppc + var x = x + if ctx.width < w: + # text is larger than image; center it to minimize error + x -= w div 2 + x += ctx.width div 2 + x = x div window.ppc + y = y div window.ppl + grid.setText(s, ComputedFormat(node: ctx.node), x, y) if ctx of ListItemBox: let ctx = ListItemBox(ctx) -- cgit