linecap, linejoin
This commit is contained in:
parent
f1762ec613
commit
bca5119e8b
2 changed files with 44 additions and 0 deletions
|
@ -8,6 +8,8 @@ const svgSignature* = "<?xml"
|
||||||
type Ctx = object
|
type Ctx = object
|
||||||
fill, stroke: ColorRGBA
|
fill, stroke: ColorRGBA
|
||||||
strokeWidth: float32
|
strokeWidth: float32
|
||||||
|
strokeLineCap: LineCap
|
||||||
|
strokeLineJoin: LineJoin
|
||||||
transform: Mat3
|
transform: Mat3
|
||||||
|
|
||||||
template failInvalid() =
|
template failInvalid() =
|
||||||
|
@ -25,6 +27,8 @@ proc decodeCtx(inherited: Ctx, node: XmlNode): Ctx =
|
||||||
fill = node.attr("fill")
|
fill = node.attr("fill")
|
||||||
stroke = node.attr("stroke")
|
stroke = node.attr("stroke")
|
||||||
strokeWidth = node.attr("stroke-width")
|
strokeWidth = node.attr("stroke-width")
|
||||||
|
strokeLineCap = node.attr("stroke-linecap")
|
||||||
|
strokeLineJoin = node.attr("stroke-linejoin")
|
||||||
transform = node.attr("transform")
|
transform = node.attr("transform")
|
||||||
|
|
||||||
if fill == "":
|
if fill == "":
|
||||||
|
@ -46,6 +50,40 @@ proc decodeCtx(inherited: Ctx, node: XmlNode): Ctx =
|
||||||
else:
|
else:
|
||||||
result.strokeWidth = parseFloat(strokeWidth)
|
result.strokeWidth = parseFloat(strokeWidth)
|
||||||
|
|
||||||
|
if strokeLineCap == "":
|
||||||
|
discard # Inherit
|
||||||
|
else:
|
||||||
|
case strokeLineCap:
|
||||||
|
of "butt":
|
||||||
|
result.strokeLineCap = lcButt
|
||||||
|
of "round":
|
||||||
|
result.strokeLineCap = lcRound
|
||||||
|
of "square":
|
||||||
|
result.strokeLineCap = lcSquare
|
||||||
|
of "inherit":
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
raise newException(
|
||||||
|
PixieError, "Invalid stroke-linecap value " & strokeLineCap
|
||||||
|
)
|
||||||
|
|
||||||
|
if strokeLineJoin == "":
|
||||||
|
discard # Inherit
|
||||||
|
else:
|
||||||
|
case strokeLineJoin:
|
||||||
|
of "miter":
|
||||||
|
result.strokeLineJoin = ljMiter
|
||||||
|
of "round":
|
||||||
|
result.strokeLineJoin = ljRound
|
||||||
|
of "bevel":
|
||||||
|
result.strokeLineJoin = ljBevel
|
||||||
|
of "inherit":
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
raise newException(
|
||||||
|
PixieError, "Invalid stroke-linejoin value " & strokeLineJoin
|
||||||
|
)
|
||||||
|
|
||||||
if transform == "":
|
if transform == "":
|
||||||
discard # Inherit
|
discard # Inherit
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -8,6 +8,12 @@ type
|
||||||
wrNonZero
|
wrNonZero
|
||||||
wrEvenOdd
|
wrEvenOdd
|
||||||
|
|
||||||
|
LineCap* = enum
|
||||||
|
lcButt, lcRound, lcSquare
|
||||||
|
|
||||||
|
LineJoin* = enum
|
||||||
|
ljMiter, ljRound, ljBevel
|
||||||
|
|
||||||
PathCommandKind* = enum
|
PathCommandKind* = enum
|
||||||
## Type of path commands
|
## Type of path commands
|
||||||
Close,
|
Close,
|
||||||
|
|
Loading…
Reference in a new issue