### Install AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Installs the AdvanceGG library using the go get command. ```bash go get github.com/GrandpaEJ/advancegg ``` -------------------------------- ### Install AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Installs the AdvanceGG library using Go modules. Requires Go 1.18 or later. The library has no external dependencies beyond the Go standard library and packages for font and image handling. ```go go get github.com/GrandpaEJ/advancegg ``` -------------------------------- ### Clone and Run AdvanceGG Examples Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md Instructions to clone the AdvanceGG repository and run the provided Go examples, demonstrating basic setup and execution. ```bash git clone https://github.com/GrandpaEJ/advancegg.git cd advancegg/examples go run basic-drawing.go go run text-rendering.go go run filter-performance-test.go ``` -------------------------------- ### Install AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.md Installs the AdvanceGG library using the go get command. ```bash go get github.com/GrandpaEJ/advancegg ``` -------------------------------- ### Quick Start: Create a Basic Graphic Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html A simple Go program demonstrating how to create a canvas, set a background color, draw a red circle, add text, and save the output as a PNG file using AdvanceGG. ```go package main import "github.com/GrandpaEJ/advancegg" func main() { // Create a new 800x600 canvas dc := advancegg.NewContext(800, 600) // Set background color to dark blue dc.SetRGB(0.1, 0.1, 0.3) dc.Clear() // Draw a red circle dc.SetRGB(1, 0, 0) dc.DrawCircle(400, 300, 100) dc.Fill() // Add white text dc.SetRGB(1, 1, 1) dc.DrawString("Hello AdvanceGG!", 300, 350) // Save as PNG dc.SavePNG("hello.png") } ``` -------------------------------- ### AdvanceGG Development Setup and Testing Source: https://github.com/grandpaej/advancegg/blob/main/README.md Provides instructions for setting up the AdvanceGG development environment, including cloning the repository, installing dependencies, running tests, executing benchmarks, and generating examples. ```bash # Clone the repository git clone https://github.com/GrandpaEJ/advancegg.git cd advancegg # Install dependencies go mod download # Run tests go test ./... # Run benchmarks go test -bench=. ./... # Generate examples go run examples/generate-all.go ``` -------------------------------- ### Basic Drawing with AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Demonstrates creating a drawing context, setting colors, drawing text and a circle, and saving the output as a PNG file. ```go package main import "github.com/GrandpaEJ/advancegg" func main() { // Create a new drawing context dc := advancegg.NewContext(800, 600) // Set background color to white dc.SetRGB(1, 1, 1) dc.Clear() // Set drawing color to black dc.SetRGB(0, 0, 0) // Draw some text dc.DrawString("Hello, AdvanceGG!", 50, 50) // Draw a circle dc.SetRGB(1, 0, 0) // Red dc.DrawCircle(400, 300, 50) dc.Fill() // Save the image dc.SavePNG("hello.png") } ``` -------------------------------- ### Setup and Run AdvanceGG Development Environment Source: https://github.com/grandpaej/advancegg/blob/main/docs/contributing.md Commands to clone the repository, install dependencies, run tests, and execute example programs for the AdvanceGG project. ```bash git clone https://github.com/GrandpaEJ/advancegg.git cd advancegg # Install dependencies go mod tidy # Run tests go test ./... # Run examples to verify everything works cd examples go run circle.go ``` -------------------------------- ### Example Template for Contribution Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md A Go code template for creating new examples to contribute to the AdvanceGG library, including basic setup, drawing, and saving the output. ```go package main import ( "fmt" "github.com/GrandpaEJ/advancegg" ) func main() { fmt.Println("Example: [Your Example Name]") // Create context dc := advancegg.NewContext(800, 600) // Your code here // Save result dc.SavePNG("your-example.png") fmt.Println("Generated: your-example.png") } ``` -------------------------------- ### AdvanceGG Image Saving Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Provides examples for saving images in various formats including PNG, JPEG, GIF, BMP, TIFF, and WebP. ```go dc.SavePNG("output.png") dc.SaveJPEG("output.jpg", 90) // 90% quality dc.SaveGIF("output.gif") dc.SaveBMP("output.bmp") dc.SaveTIFF("output.tiff") dc.SaveWebP("output.webp", 90) ``` -------------------------------- ### AdvanceGG Pixel Manipulation Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Demonstrates getting and putting image data for direct pixel manipulation. ```go // Pixel manipulation imageData := dc.GetImageData() // Modify pixels... dc.PutImageData(imageData) ``` -------------------------------- ### AdvanceGG Quick Help - Getting Started Issues Source: https://github.com/grandpaej/advancegg/blob/main/README.md Addresses common issues encountered during the initial setup and usage of AdvanceGG, such as installation problems and font loading errors, providing solutions and best practices. ```Go // Q: Installation fails with module errors A: Ensure you're using Go 1.18+ and run `go mod tidy` after installation. // Q: Fonts not loading properly A: Check font file paths and ensure TTF/OTF files are accessible. Use absolute paths for reliability. // Q: Images appear blurry A: Use high DPI settings with `dc.SetDPI(144)` for crisp output on high-resolution displays. ``` -------------------------------- ### Layer System for Composition with Blend Modes and Opacity Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Explains how to use the layer manager to create, manage, and draw on multiple layers. Covers setting blend modes, opacity, clearing layers, and compositing the final image. ```Go // Create layer manager layerManager := advancegg.NewLayerManager(800, 600) // Add layers bgLayer := layerManager.AddLayer("background") fgLayer := layerManager.AddLayer("foreground") // Draw on specific layers bgLayer.SetRGB(0.2, 0.2, 0.4) bgLayer.Clear() fgLayer.SetRGB(1, 1, 0) fgLayer.DrawCircle(400, 300, 100) fgLayer.Fill() // Set blend modes fgLayer.SetBlendMode(advancegg.BlendModeMultiply) fgLayer.SetOpacity(0.8) // Composite final image result := layerManager.Flatten() result.SavePNG("layered.png") ``` -------------------------------- ### Hello World Example Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md A basic 'Hello World' example demonstrating how to create a new graphics context, set colors, draw text, and save the output as a PNG file. ```go package main import "github.com/GrandpaEJ/advancegg" func main() { dc := advancegg.NewContext(800, 600) dc.SetRGB(1, 1, 1) dc.Clear() dc.SetRGB(0, 0, 0) dc.DrawString("Hello, AdvanceGG!", 400, 300) dc.SavePNG("hello.png") } ``` -------------------------------- ### AdvanceGG Context Creation Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Demonstrates two ways to create a drawing context: a new blank canvas of specified dimensions or from an existing RGBA image. ```go // Create a 1920x1080 canvas dc := advancegg.NewContext(1920, 1080) // Or create from an existing image img := image.NewRGBA(image.Rect(0, 0, 800, 600)) dc := advancegg.NewContextForRGBA(img) ``` -------------------------------- ### AdvanceGG Context Creation Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Initializes a new drawing context with specified width and height. ```go dc := advancegg.NewContext(width, height) ``` -------------------------------- ### First Program: Gradient Background and Transparent Circles Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html A more advanced Go program using AdvanceGG to create a graphic with a gradient background, multiple semi-transparent circles, and text with a shadow effect, saved as a PNG. ```go package main import ( "math" "github.com/GrandpaEJ/advancegg" ) func main() { // Create canvas dc := advancegg.NewContext(800, 600) // Gradient background for y := 0; y < 600; y++ { t := float64(y) / 600.0 dc.SetRGB(0.1+t*0.2, 0.1+t*0.3, 0.3+t*0.4) dc.DrawLine(0, float64(y), 800, float64(y)) dc.Stroke() } // Draw multiple circles with transparency for i := 0; i < 10; i++ { angle := float64(i) * 2 * math.Pi / 10 x := 400 + 150*math.Cos(angle) y := 300 + 150*math.Sin(angle) // Set color with transparency dc.SetRGBA(1, float64(i)/10, 0.5, 0.7) dc.DrawCircle(x, y, 30) dc.Fill() } // Add title with shadow effect dc.SetRGB(0, 0, 0) dc.DrawString("AdvanceGG Graphics", 252, 102) // Shadow dc.SetRGB(1, 1, 1) dc.DrawString("AdvanceGG Graphics", 250, 100) // Main text // Save the result dc.SavePNG("first-program.png") } ``` -------------------------------- ### AdvanceGG Gradients and Patterns Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Illustrates creating and applying linear gradients as fill patterns for shapes. ```go // Linear gradient gradient := advancegg.CreateLinearGradient(0, 0, 200, 0, color.RGBA{255, 0, 0, 255}, // Red color.RGBA{0, 0, 255, 255}, // Blue ) dc.SetFillPattern(gradient) dc.DrawRectangle(0, 0, 200, 100) dc.Fill() ``` -------------------------------- ### Image Loading, Filtering, and Saving Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Shows how to load images (PNG), apply image filters like blur and brightness, and save images in different formats (PNG, JPEG) with quality control. Relies on the advancegg package and the drawing context (dc). ```Go // Load and draw images img := advancegg.LoadPNG("input.png") dc.DrawImage(img, x, y) // Apply filters filtered := advancegg.ApplyBlur(img, 5.0) filtered = advancegg.ApplyBrightness(filtered, 1.2) dc.DrawImage(filtered, x, y) // Save in different formats dc.SavePNG("output.png") dc.SaveJPEG("output.jpg", 95) // 95% quality ``` -------------------------------- ### Color Management with RGB, Hex, CMYK, HSV, LAB, and Gradients Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Details various methods for setting colors, including RGB, RGBA, Hex codes, CMYK, HSV, and LAB color spaces. Also demonstrates creating and applying linear gradients. ```Go // RGB colors dc.SetRGB(1, 0, 0) // Red dc.SetRGBA(1, 0, 0, 0.5) // Semi-transparent red dc.SetHexColor("#FF5733") // Hex color // Other color spaces dc.SetCMYK(0, 1, 1, 0) // CMYK dc.SetHSV(240, 1, 1) // HSV (blue) dc.SetLAB(50, 20, -30) // LAB color space // Gradients gradient := advancegg.NewLinearGradient(0, 0, 100, 0) gradient.AddColorStop(0, color.RGBA{255, 0, 0, 255}) gradient.AddColorStop(1, color.RGBA{0, 0, 255, 255}) dc.SetFillStyle(gradient) ``` -------------------------------- ### Run AdvanceGG Examples Source: https://github.com/grandpaej/advancegg/blob/main/docs/examples.md Provides instructions on how to execute the provided AdvanceGG examples using the Go toolchain. It details navigating to the examples directory and running a specific example file. ```bash cd examples go run circle.go ``` -------------------------------- ### AdvanceGG Drawing with Transparency Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Shows how to draw shapes with transparency using RGBA color values. ```go dc.SetRGBA(1, 0, 0, 0.5) // 50% transparent red dc.DrawCircle(100, 100, 50) dc.Fill() ``` -------------------------------- ### AdvanceGG Drawing Operations: Path-Based Model Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Illustrates the path-based drawing model in AdvanceGG, which involves setting styles, creating a path with drawing operations, and then rendering the path by filling or stroking it. ```go // 1. Set style dc.SetRGB(0, 0.5, 1) dc.SetLineWidth(5) // 2. Create path dc.MoveTo(100, 100) dc.LineTo(200, 150) dc.LineTo(150, 200) dc.ClosePath() // 3. Render dc.Stroke() // or dc.Fill() or dc.FillPreserve() + dc.Stroke() ``` -------------------------------- ### Install AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/index-old.html Installs the AdvanceGG library using the go get command. ```Go go get github.com/GrandpaEJ/advancegg ``` -------------------------------- ### Text Rendering with Custom Fonts and Layouts Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Covers loading custom fonts, drawing basic strings, anchored text, word wrapping, and rendering text along a circular path. Utilizes the drawing context (dc) and the advancegg package. ```Go // Load custom font dc.LoadFontFace("fonts/arial.ttf", 24) // Basic text dc.DrawString("Hello World", x, y) dc.DrawStringAnchored("Centered", x, y, 0.5, 0.5) // Word wrapping dc.DrawStringWrapped("Long text...", x, y, ax, ay, width, lineSpacing, align) // Text on path advancegg.DrawTextOnCircle(dc, "Circular Text", centerX, centerY, radius) ``` -------------------------------- ### Advanced Path Drawing with Bézier Curves and Arcs Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Demonstrates how to draw complex paths using Bézier curves (quadratic and cubic) and arcs. Requires a drawing context (dc). ```Go // Bézier curves dc.MoveTo(100, 100) dc.QuadraticTo(200, 50, 300, 100) // Quadratic dc.CubicTo(400, 50, 500, 150, 600, 100) // Cubic // Arcs dc.DrawArc(x, y, radius, startAngle, endAngle) ``` -------------------------------- ### AdvanceGG Color Setting Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Demonstrates various methods for setting colors, including RGB, RGBA, RGB255, Hex, HSV, and CMYK color spaces. ```go // RGB values (0.0 to 1.0) dc.SetRGB(1, 0, 0) // Red // RGBA with alpha dc.SetRGBA(1, 0, 0, 0.5) // Semi-transparent red // RGB values (0 to 255) dc.SetRGBA255(255, 0, 0, 255) // Hex colors dc.SetHexColor("#FF0000") // Color spaces dc.SetHSV(0, 1, 1) // Red in HSV dc.SetCMYK(0, 1, 1, 0) // Red in CMYK ``` -------------------------------- ### Running Individual Examples Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md Shows how to execute specific Go examples from the command line, including options for custom output filenames and verbose logging. ```bash # Run a specific example go run basic-drawing.go # With custom output go run text-rendering.go -output custom-name.png # With verbose logging go run filter-performance-test.go -verbose ``` -------------------------------- ### AdvanceGG Drawing Context (dc) Utility Functions Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Provides a collection of useful utility functions for the AdvanceGG drawing context (dc), including state management, debugging, text measurement, and performance optimization tips. ```Go // Use dc.Push() and dc.Pop() to save and restore drawing state // Enable debug mode with dc.SetDebugMode(true) for development // Use dc.MeasureString() to calculate text dimensions before drawing // Batch similar operations together for better performance ``` -------------------------------- ### AdvanceGG Image Processing Filters Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Shows how to apply image processing filters like blur, brightness, and contrast to the drawing context. ```go // Apply filters dc.ApplyFilter(advancegg.Blur(5)) dc.ApplyFilter(advancegg.Brightness(1.2)) dc.ApplyFilter(advancegg.Contrast(1.1)) ``` -------------------------------- ### AdvanceGG Path Drawing Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Demonstrates creating and drawing complex shapes using paths, including closing paths and using the reusable Path2D object. ```go // Start a new path dc.MoveTo(100, 100) dc.LineTo(200, 100) dc.LineTo(150, 200) dc.ClosePath() dc.Fill() // Or use Path2D for reusable paths path := advancegg.NewPath2D() path.MoveTo(100, 100) path.LineTo(200, 100) path.LineTo(150, 200) path.ClosePath() dc.DrawPath(path) dc.Fill() ``` -------------------------------- ### AdvanceGG Text Drawing Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Shows different ways to draw text, including simple text, anchored text for alignment, and wrapped text for long content. ```go // Simple text dc.DrawString("Hello", x, y) // Anchored text (centered, etc.) dc.DrawStringAnchored("Centered", x, y, 0.5, 0.5) // Wrapped text dc.DrawStringWrapped("Long text...", x, y, ax, ay, width, lineSpacing, align) ``` -------------------------------- ### Install and Use AdvanceGG in Go Source: https://github.com/grandpaej/advancegg/blob/main/docs/index.html Demonstrates how to install the AdvanceGG library using go get and then import and create a new drawing context for creating graphics. ```go go get github.com/GrandpaEJ/advancegg import "github.com/GrandpaEJ/advancegg" dc := advancegg.NewContext(800, 600) ``` -------------------------------- ### AdvanceGG Basic Shapes Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Illustrates drawing basic shapes like rectangles, circles, lines, and rounded rectangles, with options to fill or stroke them. ```go // Rectangle dc.DrawRectangle(x, y, width, height) dc.Fill() // or dc.Stroke() // Circle dc.DrawCircle(centerX, centerY, radius) dc.Fill() // Line dc.DrawLine(x1, y1, x2, y2) dc.Stroke() // Rounded rectangle dc.DrawRoundedRectangle(x, y, width, height, radius) dc.Fill() ``` -------------------------------- ### Running Batch Generation Examples Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md Demonstrates how to run multiple examples simultaneously using a batch generation script, with options to specify categories or custom settings like image size and quality. ```bash # Generate all examples go run generate-all.go # Generate specific category go run generate-all.go -category visualization # Generate with custom settings go run generate-all.go -size 1920x1080 -quality high ``` -------------------------------- ### AdvanceGG Transformations Source: https://github.com/grandpaej/advancegg/blob/main/docs/GETTING_STARTED.md Demonstrates using transformations like translate and rotate to manipulate drawing elements, including saving and restoring drawing states. ```go dc.Push() // Save current state dc.Translate(100, 100) dc.Rotate(math.Pi / 4) // 45 degrees dc.DrawRectangle(-25, -25, 50, 50) dc.Fill() dc.Pop() // Restore state ``` -------------------------------- ### Analyzing Go Profiles with pprof Source: https://github.com/grandpaej/advancegg/blob/main/docs/PERFORMANCE.md Provides command-line examples for using the 'go tool pprof' command to analyze CPU and memory profiles served over HTTP. It includes options for analyzing the top functions and specifying profiling duration. ```bash # CPU profiling go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30 # Memory profiling go tool pprof http://localhost:6060/debug/pprof/heap # Analyze specific function go tool pprof -top http://localhost:6060/debug/pprof/profile ``` -------------------------------- ### AdvanceGG Basic Shapes: Rectangles, Circles, Lines Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.html Demonstrates the usage of basic shape drawing functions in AdvanceGG, including rectangles, rounded rectangles, circles, ellipses, lines, and regular polygons. ```go // Rectangles dc.DrawRectangle(x, y, width, height) dc.DrawRoundedRectangle(x, y, width, height, radius) // Circles and ellipses dc.DrawCircle(x, y, radius) dc.DrawEllipse(x, y, rx, ry) // Lines and polygons dc.DrawLine(x1, y1, x2, y2) dc.DrawRegularPolygon(6, x, y, radius, rotation) ``` -------------------------------- ### Enabling Go Profiling via HTTP Source: https://github.com/grandpaej/advancegg/blob/main/docs/PERFORMANCE.md Shows how to enable Go's built-in profiling endpoints by importing the 'net/http/pprof' package and starting an HTTP server. This allows access to CPU, memory, and goroutine profiles. ```go import _ "net/http/pprof" func main() { go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }() // Your AdvanceGG code here } ``` -------------------------------- ### Layer System Examples in AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/examples/index.html Demonstrates multi-layer compositing, blend modes, and advanced layer compositions with AdvanceGG. ```Go // Example for Creating and managing multiple layers // See: layer-basics.html ``` ```Go // Example for Multiply, screen, overlay, and more blend modes // See: blend-modes.html ``` ```Go // Example for Complex layer compositions and effects // See: advanced-composite.html ``` -------------------------------- ### Custom Benchmarking with Go's testing package Source: https://github.com/grandpaej/advancegg/blob/main/docs/PERFORMANCE.md Demonstrates how to write custom benchmarks for Go functions using the 'testing' package. It includes examples for benchmarking a single filter and a batch of filters, resetting the timer, and iterating within the benchmark loop. ```go func BenchmarkFilter(b *testing.B) { img := createTestImage() b.ResetTimer() for i := 0; i < b.N; i++ { _ = core.FastGrayscale(img) } } ``` ```go func BenchmarkBatchFilter(b *testing.B) { img := createTestImage() filter := core.BatchFilter( core.FastGrayscale, core.FastBrightness(1.2), ) b.ResetTimer() for i := 0; i < b.N; i++ { _ = filter(img) } } ``` -------------------------------- ### Running Performance Benchmark Examples Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md Provides commands to execute performance tests for various examples and generate a performance report, useful for analyzing the efficiency of graphics operations. ```bash # Run performance tests go run filter-performance-test.go go run parallel-processing.go go run memory-optimization.go # Generate performance report go run benchmark-all.go > performance-report.txt ``` -------------------------------- ### Data Visualization Examples in AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/examples/index.html Showcases the creation of charts, graphs, dashboards, and infographics using the AdvanceGG library. ```Go // Example for Bar charts, line graphs, and pie charts // See: charts-graphs.html ``` ```Go // Example for Interactive data dashboards and reports // See: dashboard-demo.html ``` ```Go // Example for Visual storytelling and data presentation // See: infographics.html ``` -------------------------------- ### Gradient Circle Example Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md Demonstrates how to create a radial gradient and use it to fill a circle, showcasing advanced fill styles in AdvanceGG. ```go package main import "github.com/GrandpaEJ/advancegg" func main() { dc := advancegg.NewContext(400, 400) // Gradient background gradient := dc.NewRadialGradient(200, 200, 0, 200, 200, 150) gradient.AddColorStop(0, color.RGBA{255, 100, 100, 255}) gradient.AddColorStop(1, color.RGBA{100, 100, 255, 255}) dc.SetFillStyle(gradient) dc.DrawCircle(200, 200, 150) dc.Fill() dc.SavePNG("gradient-circle.png") } ``` -------------------------------- ### Get Specific Version of AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/README.md Installs a specific version (v1.0.0) of the AdvanceGG library using the go get command. ```go go get github.com/GrandpaEJ/advancegg@v1.0.0 ``` -------------------------------- ### Apply Image Filters with AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/TUTORIALS.md Demonstrates how to apply image filters sequentially or using a filter chain in AdvanceGG. Includes examples for blur, brightness, and contrast. ```go dc := advancegg.NewContext(800, 600) // Create or load your image content here ``` ```go // Method 1: Individual filters dc.ApplyFilter(advancegg.Blur(3)) dc.ApplyFilter(advancegg.Brightness(1.2)) dc.ApplyFilter(advancegg.Contrast(1.1)) ``` ```go // Method 2: Filter chain (more efficient) chain := advancegg.NewFilterChain(). Add(advancegg.BlurFilter{Radius: 3}). Add(advancegg.BrightnessFilter{Amount: 1.2}). Add(advancegg.ContrastFilter{Amount: 1.1}) processedImage := chain.Apply(dc.Image()) ``` ```go dc.SavePNG("processed-image.png") ``` -------------------------------- ### Basic Drawing: Rendering Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.md Explains how to render paths by filling or stroking them, and how to clear the entire context. ```go // Fill the current path dc.Fill() // Stroke the current path dc.Stroke() // Clear the entire context dc.Clear() ``` -------------------------------- ### Creating Drawing Contexts Source: https://github.com/grandpaej/advancegg/blob/main/docs/getting-started.md Shows different methods for creating a drawing context, including from scratch, an existing image, or an RGBA image. ```go // Create a new context with specified dimensions dc := advancegg.NewContext(width, height) // Create a context from an existing image dc := advancegg.NewContextForImage(img) // Create a context from an RGBA image dc := advancegg.NewContextForRGBA(rgbaImg) ``` -------------------------------- ### Create Simple Bar Chart with AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/TUTORIALS.md Tutorial on creating a basic bar chart using AdvanceGG. It covers setting up the drawing context, preparing data, drawing axes, and rendering bars with specified colors. ```go dc := advancegg.NewContext(800, 600) dc.SetRGB(1, 1, 1) // White background dc.Clear() ``` ```go data := []struct { label string value float64 color [3]float64 }{ {"Jan", 120, [3]float64{0.8, 0.2, 0.2}}, {"Feb", 150, [3]float64{0.2, 0.8, 0.2}}, {"Mar", 180, [3]float64{0.2, 0.2, 0.8}}, } ``` ```go chartX, chartY := 100.0, 100.0 chartWidth, chartHeight := 600.0, 400.0 dc.SetRGB(0, 0, 0) dc.SetLineWidth(2) dc.DrawLine(chartX, chartY+chartHeight, chartX+chartWidth, chartY+chartHeight) // X-axis dc.DrawLine(chartX, chartY, chartX, chartY+chartHeight) // Y-axis dc.Stroke() ``` ```go maxValue := 200.0 // Find your actual max barWidth := chartWidth / float64(len(data)) * 0.8 for i, item := range data { barHeight := (item.value / maxValue) * chartHeight barX := chartX + float64(i)*(chartWidth/float64(len(data))) + 10 barY := chartY + chartHeight - barHeight dc.SetRGB(item.color[0], item.color[1], item.color[2]) dc.DrawRectangle(barX, barY, barWidth, barHeight) dc.Fill() } ``` -------------------------------- ### AdvanceGG Data Visualization Examples Source: https://github.com/grandpaej/advancegg/blob/main/examples/README.md Demonstrates the creation of professional charts and dashboards using AdvanceGG, including bar charts, line graphs, pie charts, and complete dashboard layouts. ```go // bar-charts.go: Professional bar charts // Gradients, shadows, labels ``` ```go // line-graphs.go: Interactive line graphs // Multiple series, legends, axes ``` ```go // pie-charts.go: Beautiful pie charts // 3D effects, animations, tooltips ``` ```go // dashboard.go: Complete dashboard // Multiple chart types, layouts ``` -------------------------------- ### Go Example File Status Source: https://github.com/grandpaej/advancegg/blob/main/EXAMPLE_TEST_RESULTS.md Reports the status of Go example files, indicating passed or failed tests. ```go ✅ `advanced-features.go` - Layer system, non-destructive editing, guides ✅ `advanced-patterns-filters.go` - Advanced pattern and filter effects ✅ `advanced-strokes.go` - Dashed, gradient, and tapered strokes ✅ `beziers.go` - Bézier curve demonstrations ✅ `circle.go` - Basic circle drawing ✅ `clip.go` - Clipping operations ✅ `color-profiles.go` - ICC color profile handling ✅ `color-spaces.go` - CMYK, HSV, LAB color spaces ✅ `create-missing-images.go` - Generated demo images ✅ `crisp.go` - Crisp pixel-perfect rendering ✅ `css-effects.go` - CSS-like filters and patterns ✅ `cubic.go` - Cubic curve drawing ✅ `data-visualization.go` - Charts, graphs, dashboards ✅ `dom-object-model.go` - DOM-style element management ✅ `ellipse.go` - Ellipse drawing ✅ `emoji-sequences-test.go` - Complex emoji sequence handling ✅ `emoji-test.go` - Basic emoji rendering ✅ `filter-performance-test.go` - Filter optimization benchmarks ✅ `font-comparison.go` - Font comparison displays ✅ `font-formats.go` - Multiple font format support ✅ `font-loading-test.go` - Comprehensive font loading tests ✅ `gofont.go` - Go font rendering ✅ `gradient-conic.go` - Conic gradient effects ✅ `gradient-linear.go` - Linear gradient effects ✅ `gradient-radial.go` - Radial gradient effects ✅ `gradient-text.go` - Text with gradient fills ✅ `hit-testing.go` - Interactive hit testing system ✅ `imagedata-manipulation.go` - Pixel-level image manipulation ✅ `image-filters.go` - Comprehensive image filter suite ✅ `image-formats.go` - Multiple image format support ✅ `invert-mask.go` - Mask inversion operations ✅ `layer-compositing.go` - Multi-layer blend modes ✅ `lines.go` - Line drawing ✅ `linewidth.go` - Variable line width ✅ `lorem.go` - Lorem ipsum text rendering ✅ `openfill.go` - Open path filling ✅ `otf-advanced.go` - Advanced OpenType features ✅ `path2d-advanced.go` - Advanced Path2D operations ✅ `path2d-basic.go` - Basic Path2D usage ✅ `path2d-reuse.go` - Path2D reusability ✅ `performance-optimizations.go` - Performance benchmarks ✅ `quadratic.go` - Quadratic curve drawing ✅ `resize.go` - Image resizing with multiple algorithms ✅ `rotated-text.go` - Text rotation ✅ `sine.go` - Sine wave graphics ✅ `spiral.go` - Spiral patterns ✅ `star.go` - Star shape drawing ✅ `stars.go` - Multiple star patterns ✅ `svg-demo.go` - SVG export functionality ✅ `text-metrics.go` - Text measurement and metrics ✅ `text-on-path.go` - Text following paths ✅ `text-on-path-test.go` - Text-on-path testing ✅ `unicode-emoji.go` - Unicode and emoji rendering ``` -------------------------------- ### Render Text with Styles Source: https://github.com/grandpaej/advancegg/blob/main/docs/examples.md Demonstrates text rendering capabilities, including drawing plain text and centered text. It shows how to set text color and use anchoring for text alignment. ```go package main import "github.com/GrandpaEJ/advancegg" func main() { dc := advancegg.NewContext(800, 600) // White background dc.SetRGB(1, 1, 1) dc.Clear() // Black text dc.SetRGB(0, 0, 0) dc.DrawString("Hello, AdvanceGG!", 50, 100) // Centered text dc.DrawStringAnchored("Centered Text", 400, 300, 0.5, 0.5) dc.SavePNG("text.png") } ``` -------------------------------- ### Memory Pooling with AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/TUTORIALS.md Demonstrates how to use memory pooling for contexts and 2D paths to improve performance and reduce memory overhead. It shows the acquisition and release of pooled resources. ```go // Use pooled contexts for temporary work ctx := advancegg.PooledContext(400, 300) defers advancegg.ReleaseContext(ctx) // Use pooled paths path := advancegg.PooledPath2D() defers advancegg.ReleasePath2D(path) ``` -------------------------------- ### High-Performance Rendering Setup and Profiling Source: https://github.com/grandpaej/advancegg/blob/main/docs/api/performance.html Illustrates setting up a high-performance rendering context and profiling its execution. It enables various optimizations like SIMD, memory pooling, caching, and GPU acceleration if available. The code includes detailed profiling of different rendering stages. ```go package main import ( "fmt" "runtime" "time" "github.com/GrandpaEJ/advancegg" ) func main() { // Initialize performance optimizations setupPerformanceOptimizations() // Create profiler profiler := advancegg.NewProfiler() profiler.Start() // Perform high-performance rendering profiler.BeginSection("setup") dc := setupHighPerformanceContext() profiler.EndSection("setup") profiler.BeginSection("rendering") renderComplexScene(dc) profiler.EndSection("rendering") profiler.BeginSection("save") dc.SavePNG("high_performance_render.png") profiler.EndSection("save") // Print performance results results := profiler.GetResults() fmt.Printf("Total time: %v\n", results.TotalTime) for _, section := range results.Sections { fmt.Printf("%s: %v (%.1f%%)\n", section.Name, section.Duration, section.Percentage) } } func setupPerformanceOptimizations() { // Enable all optimizations advancegg.EnableSIMD(true) advancegg.EnableMemoryPooling(true) advancegg.EnableAutomaticCaching(true) advancegg.SetWorkerThreads(runtime.NumCPU()) // Configure memory pools advancegg.SetMemoryPoolSize(advancegg.PoolTypeImage, 200*1024*1024) advancegg.SetMemoryPoolSize(advancegg.PoolTypeContext, 100*1024*1024) // Configure caches advancegg.SetCacheSize(advancegg.CacheTypeFont, 50*1024*1024) advancegg.SetCacheSize(advancegg.CacheTypeGradient, 25*1024*1024) // Enable GPU if available if advancegg.GPUSupported() { advancegg.EnableGPUAcceleration(true) } } func setupHighPerformanceContext() *advancegg.Context { dc := advancegg.NewContext(1920, 1080) // Enable context-specific optimizations dc.SetSIMDEnabled(true) dc.SetMemoryPoolingEnabled(true) dc.SetCachingEnabled(true) return dc } func renderComplexScene(dc *advancegg.Context) { // Background gradient bg := advancegg.NewLinearGradient(0, 0, 1920, 1080) bg.AddColorStop(0, advancegg.RGB(0.1, 0.1, 0.2)) bg.AddColorStop(1, advancegg.RGB(0.2, 0.1, 0.3)) dc.SetFillStyle(bg) dc.DrawRectangle(0, 0, 1920, 1080) dc.Fill() // Render thousands of objects efficiently renderParticleSystem(dc, 10000) renderGeometry(dc, 1000) renderText(dc) } func renderParticleSystem(dc *advancegg.Context, count int) { // Batch particles by color for efficiency colors := []advancegg.Color{ advancegg.RGB(1, 0.5, 0), advancegg.RGB(0.5, 1, 0), advancegg.RGB(0, 0.5, 1), } for _, color := range colors { dc.SetColor(color) for i := 0; i < count/len(colors); i++ { x := rand.Float64() * 1920 y := rand.Float64() * 1080 size := 1 + rand.Float64()*3 dc.DrawCircle(x, y, size) } dc.Fill() // Single fill for all particles of this color } } ``` -------------------------------- ### Go Compilation Fix Source: https://github.com/grandpaej/advancegg/blob/main/EXAMPLE_TEST_RESULTS.md Corrects compilation issues in Go examples, such as removing unused imports. ```go ✅ `game-graphics.go` - Removed unused "time" import ✅ `shadow-effects.go` - Actually worked (was false positive) ``` -------------------------------- ### Basic Drawing with AdvanceGG Source: https://github.com/grandpaej/advancegg/blob/main/docs/index.html Shows a simple example of setting a color, drawing a circle, filling it, and saving the result as a PNG file using the AdvanceGG library. ```go dc.SetRGB(1, 0, 0) dc.DrawCircle(400, 300, 100) dc.Fill() dc.SavePNG("circle.png") ``` -------------------------------- ### Generated Image Files Source: https://github.com/grandpaej/advancegg/blob/main/EXAMPLE_TEST_RESULTS.md Lists the types and quantity of image files generated for documentation and examples. ```go PNG files: Various graphics demonstrations GIF files: Animation examples (bouncing-ball.gif) SVG files: Vector graphics exports ``` -------------------------------- ### Go Timeout Fix Source: https://github.com/grandpaej/advancegg/blob/main/EXAMPLE_TEST_RESULTS.md Addresses timeout issues in Go examples by optimizing animation parameters. ```go ✅ `animation-demo.go` - Optimized: 30→10 FPS, 3→2 second duration ```