Complete API reference for AdvanceGG's latest enhanced features including layer compositing, DOM-style object model, hit testing, and animation support.
Professional multi-layer compositing with 13 blend modes for advanced graphics composition.
Enables the layer system for the current context.
Returns the layer manager for the current context.
Creates and adds a new layer with the specified name.
Available blend modes for layer compositing:
BlendModeNormalBlendModeMultiplyBlendModeScreenBlendModeOverlayBlendModeSoftLightBlendModeHardLightBlendModeColorDodgeBlendModeColorBurnBlendModeDarkenBlendModeLightenBlendModeDifferenceBlendModeExclusion// Enable layers and create layer manager
dc.EnableLayers()
lm := dc.GetLayerManager()
// Create layers with different blend modes
bgLayer := lm.GetActiveLayer()
bgLayer.Name = "Background"
overlayLayer := lm.AddLayer("Overlay")
overlayLayer.SetBlendMode(advancegg.BlendModeMultiply)
overlayLayer.SetOpacity(0.8)
// Draw on specific layers
lm.SetActiveLayer(1)
dc.SetRGB(1, 0, 0)
dc.DrawCircle(100, 100, 50)
dc.Fill()
// Composite all layers
result := lm.Composite()
Modern web-like API with tree structure for shapes, IDs, CSS-like classes, and style inheritance.
Creates a new document for managing graphics elements.
Adds an element to the document.
Retrieves an element by its ID.
Adds a CSS-like class to the element.
Sets a style property on the element.
// Create document and elements
doc := advancegg.NewDocument()
// Create shapes with IDs and classes
circle := advancegg.CreateCircle("circle1", 100, 100, 40)
circle.AddClass("shape")
circle.AddClass("primary")
circle.SetStyle("fill", color.RGBA{255, 100, 100, 255})
// Add CSS-like styles
doc.AddStyle(".primary", advancegg.Style{
Fill: color.RGBA{255, 100, 100, 255},
Stroke: color.RGBA{200, 50, 50, 255},
})
doc.AddElement(circle)
doc.Render(ctx)
Point-in-path detection for interactive graphics with spatial indexing for optimal performance.
Creates a new hit test manager.
Adds an object for hit testing.
Returns all objects that contain the specified point.
// Create hit test manager
htm := advancegg.NewHitTestManager()
// Add hit testable shapes
rect := advancegg.CreateHitTestRect("rect1", 50, 50, 100, 80)
circle := advancegg.CreateHitTestCircle("circle1", 200, 100, 40)
htm.AddObject(rect)
htm.AddObject(circle)
// Test for hits at mouse position
hits := htm.HitTest(mouseX, mouseY)
if len(hits) > 0 {
fmt.Printf("Hit: %s\n", hits[0].GetID())
}
Frame-based animation system with easing functions and GIF export capabilities.
Creates a new animator with specified dimensions, frame rate, and duration.
Adds a frame to the animation.
Exports the animation as a GIF file.
EaseLinearEaseInEaseOutEaseInOutEaseInCubicEaseOutCubicEaseInOutCubicEaseBounceEaseElastic// Create animator
animator := advancegg.NewAnimator(400, 300, 30.0, 3*time.Second)
// Generate frames with easing
frameCount := int(30.0 * 3.0) // 30 fps * 3 seconds
for i := 0; i < frameCount; i++ {
t := float64(i) / float64(frameCount-1)
// Animate with bounce easing
x := advancegg.AnimateProperty(50, 350, t, advancegg.EaseLinear)
y := 150 + 80*advancegg.EaseBounce(t)
// Create frame
ctx := advancegg.NewContext(400, 300)
ctx.SetRGB(1, 0.3, 0.3)
ctx.DrawCircle(x, y, 15)
ctx.Fill()
animator.AddFrame(ctx.Image().(*image.RGBA))
}
// Export as GIF
err := animator.SaveGIF("bouncing-ball.gif")