โจ.destinationOut
Last updated
Last updated
import SwiftUI
public struct TestBlendModesView: View {
public init(){}
public var body: some View {
HStack {
// โญ blend mode ๆ้ๅฐๆๅบๅฑคโ
ZStack {
text
myFrame
}
// โญ ๅฅ็จ shadow ๅพ blend mode ๆๆๆถๅคฑโ
myFrame
.shadow(radius: 8) // โญ
// โญ ๅฅ็จ compositingGroup ๅฏไปฅ้ฒๆญข blend mode ้ๅฐๅบๅฑค
ZStack {
text
myFrame
.compositingGroup() // โญ
.shadow(radius: 8)
}
// โญ Rectangle + stroke ไนๅฏไปฅๅพๅฐใ้ๆกใ็ๆๆ
Rectangle()
.strokeBorder(lineWidth: 16) // โญ
.foregroundColor(.orange)
.frame(width: 150, height: 150)
.shadow(radius: 8)
}
.padding()
.background(Color.gray)
}
var text: some View {
Text("็")
.font(.system(size: 60))
.bold()
.foregroundColor(.pink)
}
var myFrame: some View {
VStack {
Color.green.overlay {
Color.orange.opacity(0.85)
.padding()
.blendMode(.destinationOut) // โญ ๆๆด
}
}
.frame(width: 150, height: 150)
}
}
source - pixels being applied with blend modes. (on top of destination)
destination - everything underneath source.
// R : result of blend operation
// D : destination pixel values
// Sa: source alpha
// destination out
R = D ร (1 โ Sa)
View โฉ
even-odd fill mode ไนๅฏไปฅ็จไพ็นช่ฃฝๆๆด็ๅๅฝขใ