Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Source/Model/Nodes/SVGNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ public class SVGNode: SerializableElement {
@Published public var clip: SVGNode?
@Published public var mask: SVGNode?
@Published public var id: String?
@Published public var trimFrom: Double
@Published public var trimTo: Double
@Published public var pathStroke: SVGStroke?

var gestures = [AnyGesture<()>]()

public init(transform: CGAffineTransform = .identity, opaque: Bool = true, opacity: Double = 1, clip: SVGNode? = nil, mask: SVGNode? = nil, id: String? = nil) {
public init(transform: CGAffineTransform = .identity, opaque: Bool = true, opacity: Double = 1, clip: SVGNode? = nil, mask: SVGNode? = nil, id: String? = nil, trimFrom: Double = 0, trimTo: Double = 1, pathStroke: SVGStroke? = nil) {
self.transform = transform
self.opaque = opaque
self.opacity = opacity
self.clip = clip
self.mask = mask
self.id = id
self.trimFrom = trimFrom
self.trimTo = trimTo
self.pathStroke = pathStroke
}

public func bounds() -> CGRect {
Expand Down Expand Up @@ -56,6 +62,9 @@ public class SVGNode: SerializableElement {
serializer.add("opacity", opacity, 1)
serializer.add("opaque", opaque, true)
serializer.add("clip", clip).add("mask", mask)
serializer.add("trimFrom", trimFrom)
serializer.add("trimTo", trimTo)
serializer.add("pathStroke", pathStroke)
}

var typeName: String {
Expand Down
3 changes: 2 additions & 1 deletion Source/Model/Shapes/SVGPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ extension MBezierPath {
let isGradient = model.fill is SVGGradient
let bounds = isGradient ? model.bounds() : CGRect.zero
return Path(self.cgPath)
.applySVGStroke(stroke: model.stroke, eoFill: eoFill)
.trim(from: model.trimFrom, to: model.trimTo)
.applySVGStroke(stroke: model.pathStroke ?? model.stroke, eoFill: eoFill)
.applyShapeAttributes(model: model)
.applyIf(isGradient) {
$0.frame(width: bounds.width, height: bounds.height)
Expand Down