Add Multi-Layered Avatar Generation with Per-Layer Color Customization#16
Open
Sheikh566 wants to merge 5 commits intoMuhammadSaim:masterfrom
Open
Add Multi-Layered Avatar Generation with Per-Layer Color Customization#16Sheikh566 wants to merge 5 commits intoMuhammadSaim:masterfrom
Sheikh566 wants to merge 5 commits intoMuhammadSaim:masterfrom
Conversation
Implements multi-layered foregrounds for avatars. - Updates `options` struct to support multiple foreground colors and layers. - Adds `WithLayers` and `WithLayerColor` options. - Updates `Make` function to render multiple layers with different hashes. - Updates example code to demonstrate new features. - Updates tests to verify multi-layered rendering logic.
…alpha colors - Updated the `options` struct to use `color.NRGBA` for background and foreground colors. - Adjusted related functions and tests to accommodate the new color type. - Ensured consistent color handling across avatar generation logic.
…avatars-053d Multi-layered foreground avatars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a powerful multi-layered avatar generation feature to goavatar, enabling the creation of more complex and visually distinctive avatars. Users can now compose avatars from multiple layers (1-3), each with its own pattern derived from a unique hash and customizable foreground color.
Key Features
1. Multi-Layer Support
WithLayers(n)option to specify the number of avatar layers (1-3)2. Per-Layer Color Customization
WithLayerColor(layerIndex, r, g, b, a)option to set custom colors for specific layers3. Performance Improvements
image/drawpackage'sDraw()function withdraw.Uniformanddraw.OverSet()callsdraw.Srccomposite operator4. Code Quality Improvements
color.RGBAto slice ofcolor.NRGBAfor proper alpha handlingoptFunctoOptFuncfor exported visibility)Technical Details
Color Space Update:
color.RGBAtocolor.NRGBAfor more accurate alpha channel handlingMulti-Layer Architecture:
generateHash()Drawing Optimization:
image.Rect()to define rectangular regionsdraw.Draw()withimage.Uniformsource for efficient fillsExamples
2-Layer Avatar:
3-Layer Avatar with Custom Colors:
Files Changed
goavatar.go- Core implementation of multi-layer logic and drawing optimizationsgoavatar_test.go- Enhanced test coverage for multi-layer scenariosexample/main.go- New examples demonstrating multi-layer functionalityarts/avatar_7.png,arts/avatar_8.png- Example outputsarts/.gitignore- Updated to track new example imagesBackward Compatibility
✅ Fully backward compatible. Existing code continues to work without modifications. The
WithLayers()andWithLayerColor()options are opt-in.Testing
All tests updated to support the new multi-layer architecture while maintaining existing test behavior for single-layer avatars.