diff --git a/pixie.nimble b/pixie.nimble index 1002a9a..57c4d10 100644 --- a/pixie.nimble +++ b/pixie.nimble @@ -8,7 +8,7 @@ srcDir = "src" requires "nim >= 1.2.6" requires "vmath >= 1.0.8" requires "chroma >= 0.2.5" -requires "zippy >= 0.3.5" +requires "zippy >= 0.5.12" requires "flatty >= 0.1.3" requires "nimsimd >= 1.0.0" requires "bumpy >= 1.0.3" diff --git a/src/pixie.nim b/src/pixie.nim index 822f11a..b0d21e0 100644 --- a/src/pixie.nim +++ b/src/pixie.nim @@ -1,9 +1,9 @@ import bumpy, chroma, flatty/binny, os, pixie/blends, pixie/common, - pixie/context, pixie/fileformats/bmp, pixie/fileformats/gif, + pixie/contexts, pixie/fileformats/bmp, pixie/fileformats/gif, pixie/fileformats/jpg, pixie/fileformats/png, pixie/fileformats/svg, pixie/fonts, pixie/images, pixie/masks, pixie/paints, pixie/paths, strutils, vmath -export blends, bumpy, chroma, common, context, fonts, images, masks, paints, +export blends, bumpy, chroma, common, contexts, fonts, images, masks, paints, paths, vmath type diff --git a/src/pixie/context.nim b/src/pixie/contexts.nim similarity index 100% rename from src/pixie/context.nim rename to src/pixie/contexts.nim diff --git a/src/pixie/fileformats/gif.nim b/src/pixie/fileformats/gif.nim index 69ab40a..18cd1ad 100644 --- a/src/pixie/fileformats/gif.nim +++ b/src/pixie/fileformats/gif.nim @@ -113,7 +113,7 @@ proc decodeGif*(data: string): Image = if bs.pos + bitSize.int > bs.data.len * 8: failInvalid() var # Read variable bits out of the table. - codeId = bs.readBits(bitSize.int).int + codeId = bs.readBits(bitSize).int # Some time we need to carry over table information. carryOver: seq[int] diff --git a/src/pixie/fileformats/svg.nim b/src/pixie/fileformats/svg.nim index 0592938..3295158 100644 --- a/src/pixie/fileformats/svg.nim +++ b/src/pixie/fileformats/svg.nim @@ -8,6 +8,7 @@ const svgSignature* = " 0: + when defined(pixieDebugSvg): + echo "Invalid style pair: ", pair + + if display.len > 0: + result.display = display.strip() != "none" if fillRule == "": discard # Inherit @@ -232,19 +266,21 @@ proc decodeCtx(inherited: Ctx, node: XmlNode): Ctx = failInvalidTransform(transform) proc fill(img: Image, ctx: Ctx, path: Path) {.inline.} = - img.fillPath(path, ctx.fill, ctx.transform, ctx.fillRule) + if ctx.display: + img.fillPath(path, ctx.fill, ctx.transform, ctx.fillRule) proc stroke(img: Image, ctx: Ctx, path: Path) {.inline.} = - img.strokePath( - path, - ctx.stroke, - ctx.transform, - ctx.strokeWidth, - ctx.strokeLineCap, - ctx.strokeLineJoin, - miterLimit = ctx.strokeMiterLimit, - dashes = ctx.strokeDashArray - ) + if ctx.display: + img.strokePath( + path, + ctx.stroke, + ctx.transform, + ctx.strokeWidth, + ctx.strokeLineCap, + ctx.strokeLineJoin, + miterLimit = ctx.strokeMiterLimit, + dashes = ctx.strokeDashArray + ) proc draw(img: Image, node: XmlNode, ctxStack: var seq[Ctx]) = if node.kind != xnElement: @@ -252,9 +288,13 @@ proc draw(img: Image, node: XmlNode, ctxStack: var seq[Ctx]) = return case node.tag: - of "title", "desc", "defs": + of "title", "desc": discard + of "defs": + when defined(pixieDebugSvg): + echo node + of "g": let ctx = decodeCtx(ctxStack[^1], node) ctxStack.add(ctx) diff --git a/tests/all.nim b/tests/all.nim index 3b810b4..e0c13a0 100644 --- a/tests/all.nim +++ b/tests/all.nim @@ -1,6 +1,6 @@ import test_bmp, - test_context, + test_contexts, test_fonts, test_gif, test_images, diff --git a/tests/images/svg/emojitwo.png b/tests/images/svg/emojitwo.png index a5e0faa..e023fcd 100644 Binary files a/tests/images/svg/emojitwo.png and b/tests/images/svg/emojitwo.png differ diff --git a/tests/test_context.nim b/tests/test_contexts.nim similarity index 100% rename from tests/test_context.nim rename to tests/test_contexts.nim