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
8 changes: 8 additions & 0 deletions Source/Model/Primitives/SVGGradient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class SVGLinearGradient: SVGGradient {
.frame(width: width, height: height)
.offset(x: bounds.minX, y: bounds.minY)
.mask(view)
.opacity(opacity)
)
}

Expand Down Expand Up @@ -130,6 +131,7 @@ public class SVGRadialGradient: SVGGradient {
height: userSpace ? 1 : height/minimum))
.offset(x: bounds.minX, y: bounds.minY)
.mask(view)
.opacity(opacity)
)
}

Expand All @@ -151,12 +153,18 @@ public class SVGGradient: SVGPaint, Equatable {

public let userSpace: Bool
public let stops: [SVGStop]
public private(set) var opacity: Double = 1.0

public init(userSpace: Bool = false, stops: [SVGStop] = []) {
self.userSpace = userSpace
self.stops = stops
}

public override func opacity(_ opacity: Double) -> SVGGradient {
self.opacity = opacity
return self
}

}

public class SVGStop: Equatable {
Expand Down
2 changes: 1 addition & 1 deletion Source/Parser/SVG/SVGParserBasics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extension SVGHelper {
static func parseFillInternal(_ colorString: String, _ style: [String: String], _ index: SVGIndex) -> SVGPaint? {
if let colorId = SVGHelper.parseIdFromUrl(colorString) {
if let paint = index.paint(by: colorId) {
return paint
return paint.opacity(parseOpacity(style, "fill-opacity", alternativeKeys: ["opacity"]))
}
}
if let color = parseColor(colorString, style) {
Expand Down