default svg load

This commit is contained in:
Ryan Oldenburg 2021-02-22 22:35:08 -06:00
parent 40afb8e4c4
commit 5fa35c7852
2 changed files with 8 additions and 1 deletions

View file

@ -3,7 +3,7 @@ import bumpy, chroma, flatty/binny, os, pixie/blends, pixie/common,
pixie/fileformats/svg, pixie/gradients, pixie/images, pixie/masks, pixie/fileformats/svg, pixie/gradients, pixie/images, pixie/masks,
pixie/paths, vmath pixie/paths, vmath
export blends, bumpy, chroma, common, gradients, images, masks, paths, svg, vmath export blends, bumpy, chroma, common, gradients, images, masks, paths, vmath
type type
FileFormat* = enum FileFormat* = enum
@ -17,6 +17,9 @@ proc decodeImage*(data: string | seq[uint8]): Image =
decodeJpg(data) decodeJpg(data)
elif data.len > 2 and data.readStr(0, 2) == bmpSignature: elif data.len > 2 and data.readStr(0, 2) == bmpSignature:
decodeBmp(data) decodeBmp(data)
elif data.len > 5 and
(data.readStr(0, 5) == xmlSignature or data.readStr(0, 4) == svgSignature):
decodeSvg(data)
else: else:
raise newException(PixieError, "Unsupported image file format") raise newException(PixieError, "Unsupported image file format")

View file

@ -3,6 +3,10 @@
import chroma, pixie/common, pixie/images, pixie/paths, strutils, vmath, import chroma, pixie/common, pixie/images, pixie/paths, strutils, vmath,
xmlparser, xmltree xmlparser, xmltree
const
xmlSignature* = "<?xml"
svgSignature* = "<svg"
type Ctx = object type Ctx = object
fillRule: WindingRule fillRule: WindingRule
fill, stroke: ColorRGBA fill, stroke: ColorRGBA