Skip to content

Commit 3d312c4

Browse files
committed
adding opacity to LayerTree.Builder
1 parent eb73169 commit 3d312c4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

SwiftDraw/LayerTree/LayerTree.Builder.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ extension LayerTree {
9292
l.transform = Builder.createTransforms(from: element.transform ?? [])
9393
l.clip = createClipShapes(for: element)
9494
l.mask = createMaskLayer(for: element)
95+
l.opacity = state.opacity
9596

9697
if let contents = createContents(from: element, with: state) {
9798
l.appendContents(contents)
@@ -270,7 +271,7 @@ extension LayerTree.Builder {
270271
static func createState(for attributes: PresentationAttributes, inheriting existing: State) -> State {
271272
var state = State()
272273

273-
state.opacity = attributes.opacity ?? existing.opacity
274+
state.opacity = attributes.opacity ?? 1.0
274275
state.display = attributes.display ?? existing.display
275276

276277
state.stroke = attributes.stroke ?? existing.stroke

SwiftDraw/LayerTree/LayerTree.Layer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ extension LayerTree.Layer {
169169
desc += mask.customDescription(indent: indent, title: "Mask")
170170
}
171171

172+
if opacity != 1.0 {
173+
desc += "\(whitepace)Opacity: \(opacity)\n"
174+
}
175+
172176
self.contents.forEach{
173177
desc += $0.customDescription(indent: indent + 3) + "\n"
174178
}

0 commit comments

Comments
 (0)