tmp
This commit is contained in:
parent
cc93d33ab9
commit
ce4ac78b5d
3 changed files with 5 additions and 9 deletions
|
@ -22,7 +22,6 @@ type
|
||||||
strokeMiterLimit: float32
|
strokeMiterLimit: float32
|
||||||
strokeDashArray: seq[float32]
|
strokeDashArray: seq[float32]
|
||||||
transform: Mat3
|
transform: Mat3
|
||||||
shouldStroke: bool
|
|
||||||
opacity, fillOpacity, strokeOpacity: float32
|
opacity, fillOpacity, strokeOpacity: float32
|
||||||
linearGradients: TableRef[string, LinearGradient]
|
linearGradients: TableRef[string, LinearGradient]
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ proc attrOrDefault(node: XmlNode, name, default: string): string =
|
||||||
proc initSvgProperties(): SvgProperties =
|
proc initSvgProperties(): SvgProperties =
|
||||||
result.display = true
|
result.display = true
|
||||||
result.fill = "black"
|
result.fill = "black"
|
||||||
result.stroke = rgbx(0, 0, 0, 255)
|
|
||||||
result.strokeWidth = 1
|
result.strokeWidth = 1
|
||||||
result.transform = mat3()
|
result.transform = mat3()
|
||||||
result.strokeMiterLimit = defaultMiterLimit
|
result.strokeMiterLimit = defaultMiterLimit
|
||||||
|
@ -167,12 +165,12 @@ proc parseSvgProperties(node: XmlNode, inherited: SvgProperties): SvgProperties
|
||||||
if stroke == "":
|
if stroke == "":
|
||||||
discard # Inherit
|
discard # Inherit
|
||||||
elif stroke == "currentColor":
|
elif stroke == "currentColor":
|
||||||
result.shouldStroke = true
|
if result.stroke == rgbx(0, 0, 0, 0):
|
||||||
|
result.stroke = rgbx(0, 0, 0, 255)
|
||||||
elif stroke == "none":
|
elif stroke == "none":
|
||||||
result.stroke = ColorRGBX()
|
result.stroke = ColorRGBX()
|
||||||
else:
|
else:
|
||||||
result.stroke = parseHtmlColor(stroke).rgbx
|
result.stroke = parseHtmlColor(stroke).rgbx
|
||||||
result.shouldStroke = true
|
|
||||||
|
|
||||||
if fillOpacity.len > 0:
|
if fillOpacity.len > 0:
|
||||||
result.fillOpacity = parseFloat(fillOpacity).clamp(0, 1)
|
result.fillOpacity = parseFloat(fillOpacity).clamp(0, 1)
|
||||||
|
@ -186,10 +184,8 @@ proc parseSvgProperties(node: XmlNode, inherited: SvgProperties): SvgProperties
|
||||||
if strokeWidth.endsWith("px"):
|
if strokeWidth.endsWith("px"):
|
||||||
strokeWidth = strokeWidth[0 .. ^3]
|
strokeWidth = strokeWidth[0 .. ^3]
|
||||||
result.strokeWidth = parseFloat(strokeWidth)
|
result.strokeWidth = parseFloat(strokeWidth)
|
||||||
result.shouldStroke = true
|
if result.stroke == rgbx(0, 0, 0, 0):
|
||||||
|
result.stroke = rgbx(0, 0, 0, 255)
|
||||||
if result.stroke == ColorRGBX() or result.strokeWidth <= 0:
|
|
||||||
result.shouldStroke = false
|
|
||||||
|
|
||||||
if strokeLineCap == "":
|
if strokeLineCap == "":
|
||||||
discard # Inherit
|
discard # Inherit
|
||||||
|
@ -581,7 +577,7 @@ proc decodeSvg*(
|
||||||
renderInfos.add node.parseSvgElement(propertiesStack)
|
renderInfos.add node.parseSvgElement(propertiesStack)
|
||||||
for (path, props) in renderInfos:
|
for (path, props) in renderInfos:
|
||||||
result.fill(path, props)
|
result.fill(path, props)
|
||||||
if props.shouldStroke:
|
if props.stroke != rgbx(0, 0, 0, 0) and props.strokeWidth > 0:
|
||||||
result.stroke(path, props)
|
result.stroke(path, props)
|
||||||
except PixieError as e:
|
except PixieError as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 787 KiB After Width: | Height: | Size: 787 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 3.4 MiB |
Loading…
Reference in a new issue