Professional layer compositing system with 13 blend modes for advanced graphics composition, matching industry-standard tools like Photoshop.
// Enable layer system
dc.EnableLayers()
lm := dc.GetLayerManager()
// Create layers
backgroundLayer := lm.GetActiveLayer()
backgroundLayer.Name = "Background"
overlayLayer := lm.AddLayer("Overlay")
overlayLayer.SetBlendMode(advancegg.BlendModeMultiply)
overlayLayer.SetOpacity(0.8)
// Draw on specific layers
lm.SetActiveLayer(0) // Background
dc.SetRGB(0.2, 0.4, 0.8)
dc.DrawRectangle(0, 0, 400, 300)
dc.Fill()
lm.SetActiveLayer(1) // Overlay
dc.SetRGB(1, 0.3, 0.3)
dc.DrawCircle(200, 150, 100)
dc.Fill()
// Composite all layers
result := lm.Composite()
AdvanceGG supports 13 professional blend modes with accurate color mathematics:
Default blending mode. Top layer completely covers bottom layer.
BlendModeNormal
Multiplies colors, resulting in darker output. White has no effect.
BlendModeMultiply
Inverts, multiplies, and inverts again. Results in lighter output.
BlendModeScreen
Combines multiply and screen. Enhances contrast.
BlendModeOverlay
Subtle lighting effect. Darkens or lightens based on source.
BlendModeSoftLight
Strong lighting effect. Like overlay but with source and destination swapped.
BlendModeHardLight
Brightens destination based on source. Creates bright, saturated colors.
BlendModeColorDodge
Darkens destination based on source. Creates dark, saturated colors.
BlendModeColorBurn
Selects the darker of the two colors for each pixel.
BlendModeDarken
Selects the lighter of the two colors for each pixel.
BlendModeLighten
Subtracts colors, creating high contrast effects.
BlendModeDifference
Similar to difference but with lower contrast.
BlendModeExclusion
// Layer properties
layer := lm.AddLayer("Effect Layer")
// Set blend mode
layer.SetBlendMode(advancegg.BlendModeMultiply)
// Set opacity (50% transparent)
layer.SetOpacity(0.5)
// Hide/show layer
layer.SetVisible(false)
layer.SetVisible(true)
// Get current properties
mode := layer.GetBlendMode()
opacity := layer.GetOpacity()
visible := layer.IsVisible()
// Complex layer composition example
func createComplexComposition(dc *advancegg.Context) {
// Enable layers
dc.EnableLayers()
lm := dc.GetLayerManager()
// Background layer
bg := lm.GetActiveLayer()
bg.Name = "Background"
lm.SetActiveLayer(0)
// Create gradient background
gradient := advancegg.NewLinearGradient(0, 0, 400, 300)
gradient.AddColorStop(0, color.RGBA{100, 150, 200, 255})
gradient.AddColorStop(1, color.RGBA{200, 100, 150, 255})
dc.SetFillStyle(gradient)
dc.DrawRectangle(0, 0, 400, 300)
dc.Fill()
// Multiply layer for shadows
shadowLayer := lm.AddLayer("Shadows")
shadowLayer.SetBlendMode(advancegg.BlendModeMultiply)
shadowLayer.SetOpacity(0.6)
lm.SetActiveLayer(1)
dc.SetRGBA(0, 0, 0, 0.5)
dc.DrawCircle(220, 170, 80)
dc.Fill()
// Screen layer for highlights
highlightLayer := lm.AddLayer("Highlights")
highlightLayer.SetBlendMode(advancegg.BlendModeScreen)
highlightLayer.SetOpacity(0.8)
lm.SetActiveLayer(2)
dc.SetRGBA(1, 1, 1, 0.7)
dc.DrawCircle(180, 130, 60)
dc.Fill()
// Overlay layer for main content
contentLayer := lm.AddLayer("Content")
contentLayer.SetBlendMode(advancegg.BlendModeOverlay)
lm.SetActiveLayer(3)
dc.SetRGB(1, 0.5, 0.2)
dc.DrawCircle(200, 150, 70)
dc.Fill()
// Composite all layers
result := lm.Composite()
return result
}