This GitHub repository contains a comprehensive cheat sheet for blend modes, a crucial aspect of computer graphics. The cheat sheet provides a quick reference guide for each blend mode, detailing their function and characteristics and practical examples of their use.
The documentation on blend modes is incomplete and fragmented across different sources. For instance, Apple’s documentation on Bitmap Images and Image Masks includes a section on using blend modes with images, but this information pertains to Quartz 2D rather than SwiftUI. Therefore, a comprehensive and up-to-date resource on blend modes specifically for SwiftUI is currently unavailable. And I want to fix it in this paper.
var body: some View {
sfImage("mountain.2.fill", .accentColor)
.overlay(overlay.blendMode(blendMode))
.compositingGroup()
}
var overlay: some View {
VStack {
sfImage("sun.max.fill", .orange)
HStack {
sfImage("tree.fill", .black)
Spacer()
sfImage("tree.fill", .white)
}
}
}
func sfImage(_ systemName: String, _ color: Color) -> some View {
Image(systemName: systemName)
.resizable()
.scaledToFit()
.foregroundColor(color)
}
Blend mode | Description | Result |
---|---|---|
.normal |
Paints the source image samples over the background image samples. | ![]() |
Blend mode | Description | Result |
---|---|---|
.destinationOver |
Draws the destination image on top of the source image. | ![]() |