core

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package advancegg provides a simple API for rendering 2D graphics in pure Go.

Index

Constants

View Source
const (
	EmojiCategorySmileys    = "Smileys & Emotion"
	EmojiCategoryPeople     = "People & Body"
	EmojiCategoryAnimals    = "Animals & Nature"
	EmojiCategoryFood       = "Food & Drink"
	EmojiCategoryActivities = "Activities"
	EmojiCategoryTravel     = "Travel & Places"
	EmojiCategoryObjects    = "Objects"
	EmojiCategorySymbols    = "Symbols"
	EmojiCategoryFlags      = "Flags"
)

Common emoji categories

View Source
const (
	TagRedColorant   = 0x7258595A // 'rXYZ'
	TagGreenColorant = 0x6758595A // 'gXYZ'
	TagBlueColorant  = 0x6258595A // 'bXYZ'
	TagWhitePoint    = 0x77747074 // 'wtpt'
	TagBlackPoint    = 0x626B7074 // 'bkpt'
	TagRedTRC        = 0x72545243 // 'rTRC'
	TagGreenTRC      = 0x67545243 // 'gTRC'
	TagBlueTRC       = 0x62545243 // 'bTRC'
	TagGrayTRC       = 0x6B545243 // 'kTRC'
	TagDescription   = 0x64657363 // 'desc'
	TagCopyright     = 0x63707274 // 'cprt'
)

Common ICC tag signatures

Variables

View Source
var (
	IlluminantD50 = XYZColor{X: 0.9642, Y: 1.0000, Z: 0.8249}
	IlluminantD65 = XYZColor{X: 0.9505, Y: 1.0000, Z: 1.0890}
)

Standard illuminants

View Source
var GlobalByteSlicePool = NewByteSlicePool()

GlobalByteSlicePool is the global byte slice pool

View Source
var GlobalContextPool = NewContextPool()

GlobalContextPool is the global context pool

View Source
var GlobalDebugConfig = DefaultDebugConfig()

GlobalDebugConfig is the global debug configuration

View Source
var GlobalFontCache = NewFontCache(50*1024*1024, 500) // 50MB, 500 items

GlobalFontCache is the global font cache

View Source
var GlobalImageCache = NewImageCache(100*1024*1024, 1000) // 100MB, 1000 items

GlobalImageCache is the global image cache

View Source
var GlobalImagePool = NewImagePool()

GlobalImagePool is the global image pool instance

View Source
var GlobalPathCache = NewPathCache(25*1024*1024, 250) // 25MB, 250 items

GlobalPathCache is the global path cache

View Source
var GlobalPathPool = NewPathPool()

GlobalPathPool is the global path pool

Functions

func AnimateColor

func AnimateColor(start, end color.RGBA, t float64, easing EasingFunc) color.RGBA

AnimateColor animates between two colors

func AnimateProperty

func AnimateProperty(start, end, t float64, easing EasingFunc) float64

AnimateProperty animates a single property over time

func ClearAllCaches

func ClearAllCaches()

ClearAllCaches clears all global caches

func ClearPools

func ClearPools()

ClearPools clears all memory pools (useful for testing)

func DebugAssert

func DebugAssert(condition bool, message string)

DebugAssert checks a condition and logs an error if it fails

func DebugLog

func DebugLog(format string, args ...interface{})

DebugLog logs a debug message if debug mode is enabled

func Degrees

func Degrees(radians float64) float64

func EaseBounce

func EaseBounce(t float64) float64

Bounce easing

func EaseElastic

func EaseElastic(t float64) float64

Elastic easing

func EaseIn

func EaseIn(t float64) float64

Ease in (slow start)

func EaseInCubic

func EaseInCubic(t float64) float64

Ease in cubic

func EaseInOut

func EaseInOut(t float64) float64

Ease in-out (slow start and end)

func EaseInOutCubic

func EaseInOutCubic(t float64) float64

Ease in-out cubic

func EaseLinear

func EaseLinear(t float64) float64

Linear easing (no easing)

func EaseOut

func EaseOut(t float64) float64

Ease out (slow end)

func EaseOutCubic

func EaseOutCubic(t float64) float64

Ease out cubic

func EdgeDetection

func EdgeDetection(img image.Image) image.Image

EdgeDetection applies edge detection using Sobel operator

func Emboss

func Emboss(img image.Image) image.Image

Emboss applies an emboss effect

func FastGrayscale

func FastGrayscale(img image.Image) image.Image

FastGrayscale is an optimized version of Grayscale using SIMD

func GenerateFontKey

func GenerateFontKey(fontPath string, size float64, params ...interface{}) string

GenerateFontKey generates a cache key for a font operation

func GenerateImageKey

func GenerateImageKey(operation string, params ...interface{}) string

GenerateImageKey generates a cache key for an image operation

func GeneratePathKey

func GeneratePathKey(pathData string, transform Matrix) string

GeneratePathKey generates a cache key for a path operation

func GetCacheStats

func GetCacheStats() map[string]CacheStats

GetCacheStats returns statistics for all caches

func GetFontFormat

func GetFontFormat(path string) (string, error)

GetFontFormat attempts to detect the font format from the file header.

func Grayscale

func Grayscale(img image.Image) image.Image

Grayscale converts the image to grayscale

func HandleError

func HandleError(err error)

HandleError handles an error using the global error handler

func Invert

func Invert(img image.Image) image.Image

Invert inverts the colors of the image

func IsDebugMode

func IsDebugMode() bool

IsDebugMode returns true if debug mode is enabled

func IsEmoji

func IsEmoji(r rune) bool

IsEmoji checks if a rune is an emoji

func LoadBMP

func LoadBMP(path string) (image.Image, error)

LoadBMP loads a BMP image from the specified file path.

func LoadFontFace

func LoadFontFace(path string, points float64) (font.Face, error)

LoadFontFace is a helper function to load the specified font file with the specified point size. Supports both TTF and OTF font formats. Note that the returned `font.Face` objects are not thread safe and cannot be used in parallel across goroutines. You can usually just use the Context.LoadFontFace function instead of this package-level function.

func LoadGIF

func LoadGIF(path string) (image.Image, error)

LoadGIF loads a GIF image from the specified file path.

func LoadImage

func LoadImage(path string) (image.Image, error)

func LoadJPG

func LoadJPG(path string) (image.Image, error)

func LoadOTFFace

func LoadOTFFace(path string, points float64) (font.Face, error)

LoadOTFFace loads an OTF font file with the specified point size.

func LoadPNG

func LoadPNG(path string) (image.Image, error)

func LoadTIFF

func LoadTIFF(path string) (image.Image, error)

LoadTIFF loads a TIFF image from the specified file path.

func LoadTTFFace

func LoadTTFFace(path string, points float64) (font.Face, error)

LoadTTFFace loads a TTF font file with the specified point size.

func LoadWebP

func LoadWebP(path string) (image.Image, error)

LoadWebP loads a WebP image from the specified file path.

func ParseFontFace

func ParseFontFace(fontBytes []byte, points float64) (font.Face, error)

ParseFontFace parses font data from bytes and creates a font face. Supports both TTF and OTF formats.

func ParseFontFaceWithOptions

func ParseFontFaceWithOptions(fontBytes []byte, options *truetype.Options) (font.Face, error)

ParseFontFaceWithOptions parses font data with custom options.

func Radians

func Radians(degrees float64) float64

func RecoverFromPanic

func RecoverFromPanic() error

RecoverFromPanic recovers from panics and converts them to AdvanceErrors

func ReleaseContext

func ReleaseContext(ctx *Context)

ReleaseContext returns a context and its resources to pools

func ReleasePath2D

func ReleasePath2D(path *Path2D)

ReleasePath2D returns a Path2D to the pool

func ResizeImage

func ResizeImage(img image.Image, newWidth, newHeight int) image.Image

ResizeImage resizes an image to the specified width and height using a default algorithm (bilinear) that balances quality and performance.

func ResizeImageFill

func ResizeImageFill(img image.Image, width, height int) image.Image

ResizeImageFill scales the image to completely fill the target width/height while maintaining aspect ratio, then center-crops to the exact size. This may crop edges.

func ResizeImageFit

func ResizeImageFit(img image.Image, maxWidth, maxHeight int) image.Image

ResizeImageFit resizes an image to fit entirely within the given bounding box while maintaining aspect ratio. The returned image will be <= maxWidth x maxHeight.

func ResizeImageWithAlgorithm

func ResizeImageWithAlgorithm(img image.Image, newWidth, newHeight int, algo ResizeAlgorithm) image.Image

ResizeImageWithAlgorithm resizes an image using the specified algorithm.

func SIMDAlphaBlend

func SIMDAlphaBlend(dst, src *image.RGBA)

SIMDAlphaBlend performs optimized alpha blending

func SIMDBlur

func SIMDBlur(img *image.RGBA, radius int) *image.RGBA

SIMDBlur applies blur using SIMD optimizations

func SIMDColorTransform

func SIMDColorTransform(img *image.RGBA, transform func(r, g, b, a uint8) (uint8, uint8, uint8, uint8)) *image.RGBA

SIMDColorTransform applies color transformations using SIMD

func SIMDConvolution

func SIMDConvolution(img *image.RGBA, kernel [][]float64) *image.RGBA

SIMDConvolution applies convolution kernel with SIMD optimizations

func SIMDMemCopy

func SIMDMemCopy(dst, src []byte)

SIMDMemCopy performs optimized memory copying

func SIMDResize

func SIMDResize(img *image.RGBA, newWidth, newHeight int) *image.RGBA

SIMDResize performs optimized image resizing

func SafeExecute

func SafeExecute(operation string, fn func() error) error

SafeExecute executes a function with panic recovery

func SaveBMP

func SaveBMP(path string, im image.Image) error

SaveBMP encodes the image as a BMP and writes it to disk.

func SaveGIF

func SaveGIF(path string, im image.Image) error

SaveGIF encodes the image as a GIF and writes it to disk.

func SaveJPEG

func SaveJPEG(path string, im image.Image, quality int) error

SaveJPEG encodes the image as a JPEG and writes it to disk.

func SaveJPG

func SaveJPG(path string, im image.Image, quality int) error

func SavePNG

func SavePNG(path string, im image.Image) error

func SaveTIFF

func SaveTIFF(path string, im image.Image) error

SaveTIFF encodes the image as a TIFF and writes it to disk.

func ScaleImage

func ScaleImage(img image.Image, factor float64) image.Image

ScaleImage scales an image by a floating-point factor. For example, factor=2.0 doubles the dimensions; factor=0.5 halves them.

func Sepia

func Sepia(img image.Image) image.Image

Sepia applies a sepia tone effect

func SetCacheConfig

func SetCacheConfig(config CacheConfig)

SetCacheConfig configures the global caches

func SetDebugConfig

func SetDebugConfig(config DebugConfig)

SetDebugConfig sets the global debug configuration

func SetDebugMode

func SetDebugMode(mode DebugMode)

SetDebugMode sets the global debug mode

func SetErrorHandler

func SetErrorHandler(handler ErrorHandler)

SetErrorHandler sets the global error handler

func SetPoolConfig

func SetPoolConfig(config PoolConfig)

SetPoolConfig sets the global pool configuration

func Sharpen

func Sharpen(img image.Image) image.Image

Sharpen applies a sharpening filter

func ValidateImageBounds

func ValidateImageBounds(x, y, width, height int) error

ValidateImageBounds validates coordinates are within image bounds

func ValidateNotNil

func ValidateNotNil(name string, value interface{}) error

ValidateNotNil validates that a pointer is not nil

func ValidatePositive

func ValidatePositive(name string, value float64) error

ValidatePositive validates that a number is positive

func ValidateRange

func ValidateRange(name string, value, min, max float64) error

ValidateRange validates that a value is within a range

Types

type AdvanceError

type AdvanceError struct {
	Type        ErrorType
	Message     string
	Context     map[string]interface{}
	StackTrace  []string
	Suggestions []string
	Code        string
}

AdvanceError represents an enhanced error with context

func NewError

func NewError(errorType ErrorType, message string) *AdvanceError

NewError creates a new AdvanceError with stack trace

func NewFileNotFoundError

func NewFileNotFoundError(filepath string) *AdvanceError

NewFileNotFoundError creates an error for missing files

func NewInvalidFormatError

func NewInvalidFormatError(filepath string, expectedFormats []string) *AdvanceError

NewInvalidFormatError creates an error for invalid file formats

func NewInvalidParameterError

func NewInvalidParameterError(paramName string, value interface{}, expected string) *AdvanceError

NewInvalidParameterError creates an error for invalid parameters

func NewInvalidStateError

func NewInvalidStateError(operation string, currentState string, requiredState string) *AdvanceError

NewInvalidStateError creates an error for invalid context state

func NewMemoryError

func NewMemoryError(operation string, requestedSize int64) *AdvanceError

NewMemoryError creates an error for memory-related issues

func NewOutOfBoundsError

func NewOutOfBoundsError(operation string, value, min, max interface{}) *AdvanceError

NewOutOfBoundsError creates an error for out-of-bounds operations

func NewRenderError

func NewRenderError(operation string, details string) *AdvanceError

NewRenderError creates an error for rendering issues

func NewUnsupportedOperationError

func NewUnsupportedOperationError(operation string, reason string) *AdvanceError

NewUnsupportedOperationError creates an error for unsupported operations

func (*AdvanceError) Error

func (e *AdvanceError) Error() string

Error implements the error interface

func (*AdvanceError) WithCode

func (e *AdvanceError) WithCode(code string) *AdvanceError

WithCode adds an error code

func (*AdvanceError) WithContext

func (e *AdvanceError) WithContext(key string, value interface{}) *AdvanceError

WithContext adds context to the error

func (*AdvanceError) WithSuggestion

func (e *AdvanceError) WithSuggestion(suggestion string) *AdvanceError

WithSuggestion adds a suggestion to the error

type Align

type Align int
const (
	AlignLeft Align = iota
	AlignCenter
	AlignRight
)

type AlignmentTarget

type AlignmentTarget struct {
	X, Y, Width, Height float64
	ID                  string
}

AlignmentTarget represents something that can be aligned

func AlignTargetsBottom

func AlignTargetsBottom(targets []AlignmentTarget) []AlignmentTarget

AlignTargetsBottom aligns targets to the bottommost position

func AlignTargetsCenterHorizontal

func AlignTargetsCenterHorizontal(targets []AlignmentTarget) []AlignmentTarget

AlignTargetsCenterHorizontal aligns targets horizontally to center

func AlignTargetsCenterVertical

func AlignTargetsCenterVertical(targets []AlignmentTarget) []AlignmentTarget

AlignTargetsCenterVertical aligns targets vertically to center

func AlignTargetsLeft

func AlignTargetsLeft(targets []AlignmentTarget) []AlignmentTarget

AlignTargetsLeft aligns targets to the leftmost position

func AlignTargetsRight

func AlignTargetsRight(targets []AlignmentTarget) []AlignmentTarget

AlignTargetsRight aligns targets to the rightmost position

func AlignTargetsTop

func AlignTargetsTop(targets []AlignmentTarget) []AlignmentTarget

AlignTargetsTop aligns targets to the topmost position

func DistributeHorizontally

func DistributeHorizontally(targets []AlignmentTarget) []AlignmentTarget

DistributeHorizontally distributes targets evenly horizontally

func DistributeVertically

func DistributeVertically(targets []AlignmentTarget) []AlignmentTarget

DistributeVertically distributes targets evenly vertically

type AnimationFrame

type AnimationFrame struct {
	Image *image.RGBA
	Delay time.Duration
}

AnimationFrame represents a single frame in an animation

type AnimationSequence

type AnimationSequence struct {
	// contains filtered or unexported fields
}

AnimationSequence represents a sequence of animations

func AnimRotate

func AnimRotate(duration time.Duration, fromAngle, toAngle float64, render func(ctx *Context)) *AnimationSequence

AnimRotate creates a rotation animation

func AnimScale

func AnimScale(duration time.Duration, fromScale, toScale float64, render func(ctx *Context)) *AnimationSequence

AnimScale creates a scale animation

func FadeIn

func FadeIn(duration time.Duration, render func(ctx *Context)) *AnimationSequence

FadeIn creates a fade-in animation

func FadeOut

func FadeOut(duration time.Duration, render func(ctx *Context)) *AnimationSequence

FadeOut creates a fade-out animation

func NewAnimationSequence

func NewAnimationSequence() *AnimationSequence

NewAnimationSequence creates a new animation sequence

func Pulse

func Pulse(duration time.Duration, minScale, maxScale float64, render func(ctx *Context)) *AnimationSequence

Pulse creates a pulsing animation

func SlideIn

func SlideIn(duration time.Duration, direction string, render func(ctx *Context)) *AnimationSequence

SlideIn creates a slide-in animation

func (*AnimationSequence) AddStep

func (seq *AnimationSequence) AddStep(duration time.Duration, render func(t float64, ctx *Context), easing EasingFunc) *AnimationSequence

AddStep adds a step to the animation sequence

func (*AnimationSequence) Render

func (seq *AnimationSequence) Render(width, height int, fps float64) *Animator

Render renders the animation sequence to frames

type AnimationStep

type AnimationStep struct {
	// contains filtered or unexported fields
}

AnimationStep represents a single step in an animation sequence

type Animator

type Animator struct {
	// contains filtered or unexported fields
}

Animator manages frame-based animations

func NewAnimator

func NewAnimator(width, height int, fps float64, duration time.Duration) *Animator

NewAnimator creates a new animator

func (*Animator) AddFrame

func (a *Animator) AddFrame(frame *image.RGBA)

AddFrame adds a frame to the animation

func (*Animator) GetFrame

func (a *Animator) GetFrame(index int) *image.RGBA

GetFrame returns a specific frame

func (*Animator) GetFrameCount

func (a *Animator) GetFrameCount() int

GetFrameCount returns the number of frames

func (*Animator) SaveGIF

func (a *Animator) SaveGIF(filename string) error

SaveGIF saves the animation as a GIF

type ArabicForm

type ArabicForm int

ArabicForm represents Arabic contextual forms

const (
	ArabicIsolated ArabicForm = iota
	ArabicInitial
	ArabicMedial
	ArabicFinal
)

type Batch

type Batch struct {
	// contains filtered or unexported fields
}

Batch manages a collection of drawing operations

func NewBatch

func NewBatch() *Batch

NewBatch creates a new batch

func (*Batch) Add

func (b *Batch) Add(op BatchOperation)

Add adds an operation to the batch

func (*Batch) Clear

func (b *Batch) Clear()

Clear clears all operations from the batch

func (*Batch) Execute

func (b *Batch) Execute(ctx *Context)

Execute executes all operations in the batch

func (*Batch) GetBounds

func (b *Batch) GetBounds() Rectangle

GetBounds returns the bounding rectangle of all operations

type BatchCircle

type BatchCircle struct {
	X, Y, Radius float64
	Color        color.Color
	Fill         bool
}

BatchCircle represents a circle drawing operation

func (BatchCircle) Execute

func (op BatchCircle) Execute(ctx *Context)

func (BatchCircle) GetBounds

func (op BatchCircle) GetBounds() (x, y, width, height float64)

func (BatchCircle) GetType

func (op BatchCircle) GetType() BatchOpType

type BatchImage

type BatchImage struct {
	Image image.Image
	X, Y  int
}

BatchImage represents an image drawing operation

func (BatchImage) Execute

func (op BatchImage) Execute(ctx *Context)

func (BatchImage) GetBounds

func (op BatchImage) GetBounds() (x, y, width, height float64)

func (BatchImage) GetType

func (op BatchImage) GetType() BatchOpType

type BatchLine

type BatchLine struct {
	X1, Y1, X2, Y2 float64
	Color          color.Color
	Width          float64
}

BatchLine represents a line drawing operation

func (BatchLine) Execute

func (op BatchLine) Execute(ctx *Context)

func (BatchLine) GetBounds

func (op BatchLine) GetBounds() (x, y, width, height float64)

func (BatchLine) GetType

func (op BatchLine) GetType() BatchOpType

type BatchOpType

type BatchOpType int

BatchOpType represents the type of batch operation

const (
	BatchOpCircle BatchOpType = iota
	BatchOpRectangle
	BatchOpLine
	BatchOpText
	BatchOpImage
	BatchOpPath
)

type BatchOperation

type BatchOperation interface {
	Execute(ctx *Context)
	GetBounds() (x, y, width, height float64)
	GetType() BatchOpType
}

BatchOperation represents a single drawing operation

type BatchRectangle

type BatchRectangle struct {
	X, Y, Width, Height float64
	Color               color.Color
	Fill                bool
}

BatchRectangle represents a rectangle drawing operation

func (BatchRectangle) Execute

func (op BatchRectangle) Execute(ctx *Context)

func (BatchRectangle) GetBounds

func (op BatchRectangle) GetBounds() (x, y, width, height float64)

func (BatchRectangle) GetType

func (op BatchRectangle) GetType() BatchOpType

type BatchText

type BatchText struct {
	Text  string
	X, Y  float64
	Color color.Color
}

BatchText represents a text drawing operation

func (BatchText) Execute

func (op BatchText) Execute(ctx *Context)

func (BatchText) GetBounds

func (op BatchText) GetBounds() (x, y, width, height float64)

func (BatchText) GetType

func (op BatchText) GetType() BatchOpType

type BidiRun

type BidiRun struct {
	Text      string
	Direction TextDirection
	Script    ScriptType
	Language  string
	Level     int
}

BidiRun represents a run of text with consistent direction and script

type BlendMode

type BlendMode int

BlendMode represents different layer blending modes

const (
	BlendModeNormal BlendMode = iota
	// Photoshop-style Blend Modes
	BlendModeMultiply
	BlendModeScreen
	BlendModeOverlay
	BlendModeSoftLight
	BlendModeHardLight
	BlendModeColorDodge
	BlendModeColorBurn
	BlendModeDarken
	BlendModeLighten
	BlendModeDifference
	BlendModeExclusion
	BlendModeHue
	BlendModeSaturation
	BlendModeColor
	BlendModeLuminosity

	// Porter-Duff Compositing Operators
	BlendModeClear
	BlendModeSource
	BlendModeDest
	BlendModeSrcOver // Alias for Normal but explicit
	BlendModeDstOver
	BlendModeSrcIn
	BlendModeDstIn
	BlendModeSrcOut
	BlendModeDstOut
	BlendModeSrcAtop
	BlendModeDstAtop
	BlendModeXor
	BlendModeAdd
)

type BlurOperation

type BlurOperation struct {
	Radius float64
}

BlurOperation applies blur

func (*BlurOperation) Apply

func (op *BlurOperation) Apply(img *image.RGBA) *image.RGBA

func (*BlurOperation) Clone

func (op *BlurOperation) Clone() EditOperation

func (*BlurOperation) GetParameters

func (op *BlurOperation) GetParameters() map[string]interface{}

func (*BlurOperation) GetType

func (op *BlurOperation) GetType() string

func (*BlurOperation) SetParameters

func (op *BlurOperation) SetParameters(params map[string]interface{})

type Bounds

type Bounds struct {
	X, Y, Width, Height float64
}

Bounds represents a bounding rectangle

type BrightnessOperation

type BrightnessOperation struct {
	Amount float64
}

BrightnessOperation adjusts image brightness

func (*BrightnessOperation) Apply

func (op *BrightnessOperation) Apply(img *image.RGBA) *image.RGBA

func (*BrightnessOperation) Clone

func (op *BrightnessOperation) Clone() EditOperation

func (*BrightnessOperation) GetParameters

func (op *BrightnessOperation) GetParameters() map[string]interface{}

func (*BrightnessOperation) GetType

func (op *BrightnessOperation) GetType() string

func (*BrightnessOperation) SetParameters

func (op *BrightnessOperation) SetParameters(params map[string]interface{})

type ByteSlicePool

type ByteSlicePool struct {
	// contains filtered or unexported fields
}

ByteSlicePool manages pools of byte slices for various operations

func NewByteSlicePool

func NewByteSlicePool() *ByteSlicePool

NewByteSlicePool creates a new byte slice pool

func (*ByteSlicePool) Get

func (p *ByteSlicePool) Get(size int) []byte

Get retrieves a byte slice from the pool

func (*ByteSlicePool) Put

func (p *ByteSlicePool) Put(slice []byte)

Put returns a byte slice to the pool

type CMYK

type CMYK struct {
	C, M, Y, K float64 // Cyan, Magenta, Yellow, Key (Black)
}

CMYK represents a color in CMYK color space

func (CMYK) ToRGB

func (cmyk CMYK) ToRGB() Color

CMYK to RGB conversion

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache represents a generic cache with LRU eviction

func NewCache

func NewCache(maxSize int64, maxItems int) *Cache

NewCache creates a new cache with specified limits

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all items from the cache

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool)

Get retrieves an item from the cache

func (*Cache) GetStats

func (c *Cache) GetStats() CacheStats

GetStats returns cache statistics

func (*Cache) Set

func (c *Cache) Set(key string, data interface{}, size int64)

Set stores an item in the cache

type CacheConfig

type CacheConfig struct {
	ImageCacheSize int64
	FontCacheSize  int64
	PathCacheSize  int64
	EnableCaching  bool
}

CacheConfig holds cache configuration

func DefaultCacheConfig

func DefaultCacheConfig() CacheConfig

DefaultCacheConfig returns the default cache configuration

type CacheEntry

type CacheEntry struct {
	Data        interface{}
	CreatedAt   time.Time
	AccessAt    time.Time
	AccessCount int64
	Size        int64
}

CacheEntry represents a cached item

type CacheStats

type CacheStats struct {
	Hits      int64
	Misses    int64
	Evictions int64
	TotalSize int64
	ItemCount int
}

CacheStats holds cache performance statistics

type CircleShape

type CircleShape struct {
	X, Y, Radius float64
}

CircleShape represents a circle

func (*CircleShape) Clone

func (c *CircleShape) Clone() Shape

func (*CircleShape) Draw

func (c *CircleShape) Draw(ctx *Context)

CircleShape methods

func (*CircleShape) GetBounds

func (c *CircleShape) GetBounds() (float64, float64, float64, float64)

type Color

type Color struct {
	R, G, B, A float64
}

Color represents a color in various color spaces

func NewColor

func NewColor(r, g, b, a float64) Color

NewColor creates a new Color from RGBA values (0-1 range)

func NewColorFromRGBA255

func NewColorFromRGBA255(r, g, b, a uint8) Color

NewColorFromRGBA255 creates a new Color from RGBA values (0-255 range)

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

RGBA returns the color as standard RGBA values (0-65535 range)

func (Color) RGBA255

func (c Color) RGBA255() (r, g, b, a uint8)

RGBA255 returns the color as RGBA values (0-255 range)

func (Color) ToCMYK

func (c Color) ToCMYK() CMYK

RGB to CMYK conversion

func (Color) ToHSL

func (c Color) ToHSL() HSL

RGB to HSL conversion

func (Color) ToHSV

func (c Color) ToHSV() HSV

RGB to HSV conversion

func (Color) ToLAB

func (c Color) ToLAB() LAB

RGB to LAB conversion

func (Color) ToStandardColor

func (c Color) ToStandardColor() color.Color

ToStandardColor converts to Go's standard color.Color interface

func (Color) ToXYZ

func (c Color) ToXYZ() XYZ

RGB to XYZ conversion (intermediate step for LAB)

type ColorConverter

type ColorConverter struct {
	SourceProfile *ICCProfile
	DestProfile   *ICCProfile
	Intent        RenderingIntent
}

ColorConverter handles color space conversions using ICC profiles

func NewColorConverter

func NewColorConverter(source, dest *ICCProfile) *ColorConverter

NewColorConverter creates a new color converter

func (*ColorConverter) ConvertColor

func (cc *ColorConverter) ConvertColor(c color.Color) color.Color

ConvertColor converts a color from source to destination profile

type ColorEmojiFont

type ColorEmojiFont struct {
	// contains filtered or unexported fields
}

ColorEmojiFont represents a color emoji font with COLR/CPAL support

type ColorSpace

type ColorSpace uint32

ColorSpace represents different color spaces

const (
	ColorSpaceXYZ  ColorSpace = 0x58595A20 // 'XYZ '
	ColorSpaceLab  ColorSpace = 0x4C616220 // 'Lab '
	ColorSpaceRGB  ColorSpace = 0x52474220 // 'RGB '
	ColorSpaceCMYK ColorSpace = 0x434D594B // 'CMYK'
	ColorSpaceGray ColorSpace = 0x47524159 // 'GRAY'
)

type ConditionalBatch

type ConditionalBatch struct {
	*Batch
	// contains filtered or unexported fields
}

ConditionalBatch executes operations only if they're within the viewport

func NewConditionalBatch

func NewConditionalBatch(viewport Rectangle) *ConditionalBatch

NewConditionalBatch creates a batch that only executes operations within the viewport

func (*ConditionalBatch) Execute

func (cb *ConditionalBatch) Execute(ctx *Context)

Execute executes only operations that intersect with the viewport

type Context

type Context struct {
	// contains filtered or unexported fields
}

func CreateNew

func CreateNew(width, height int, backgroundColor color.Color) *Context

CreateNew creates a new image with specified dimensions and background color Similar to Pillow's Image.new()

func CreateNewGrayscale

func CreateNewGrayscale(width, height int, gray uint8) *Context

CreateNewGrayscale creates a new grayscale image

func CreateNewRGB

func CreateNewRGB(width, height int, r, g, b uint8) *Context

CreateNewRGB creates a new image with RGB background (alpha = 255)

func CreateNewRGBA

func CreateNewRGBA(width, height int, r, g, b, a uint8) *Context

CreateNewRGBA creates a new image with RGBA background

func CreateNewTransparent

func CreateNewTransparent(width, height int) *Context

CreateNewTransparent creates a new transparent image

func NewContext

func NewContext(width, height int) *Context

NewContext creates a new image.RGBA with the specified width and height and prepares a context for rendering onto that image.

func NewContextForImage

func NewContextForImage(im image.Image) *Context

NewContextForImage copies the specified image into a new image.RGBA and prepares a context for rendering onto that image.

func NewContextForRGBA

func NewContextForRGBA(im *image.RGBA) *Context

NewContextForRGBA prepares a context for rendering onto the specified image. No copy is made.

func PooledContext

func PooledContext(width, height int) *Context

PooledContext creates a new context using pooled resources

func (*Context) AddEditOperation

func (dc *Context) AddEditOperation(op EditOperation)

AddEditOperation adds a non-destructive edit operation

func (*Context) AddGuide

func (dc *Context) AddGuide(position float64, orientation GuideOrientation) *Guide

AddGuide adds a guide

func (*Context) AddLayer

func (dc *Context) AddLayer(name string) *Layer

AddLayer adds a new layer

func (*Context) ApplyFilter

func (dc *Context) ApplyFilter(filter Filter)

ApplyFilter applies a filter to the context's current image

func (*Context) ApplyNonDestructiveEdits

func (dc *Context) ApplyNonDestructiveEdits()

ApplyNonDestructiveEdits applies all non-destructive edits to the image

func (*Context) AsMask

func (dc *Context) AsMask() *image.Alpha

AsMask returns an *image.Alpha representing the alpha channel of this context. This can be useful for advanced clipping operations where you first render the mask geometry and then use it as a mask.

func (*Context) BatchCircles

func (dc *Context) BatchCircles(circles []BatchCircle)

BatchCircles draws multiple circles efficiently

func (*Context) BatchImages

func (dc *Context) BatchImages(images []BatchImage)

BatchImages draws multiple images efficiently

func (*Context) BatchLines

func (dc *Context) BatchLines(lines []BatchLine)

BatchLines draws multiple lines efficiently

func (*Context) BatchRectangles

func (dc *Context) BatchRectangles(rectangles []BatchRectangle)

BatchRectangles draws multiple rectangles efficiently

func (*Context) BatchTexts

func (dc *Context) BatchTexts(texts []BatchText)

BatchTexts draws multiple text strings efficiently

func (*Context) BeginBatch

func (dc *Context) BeginBatch() *Batch

BeginBatch starts a new batch operation

func (*Context) Clear

func (dc *Context) Clear()

Clear fills the entire image with the current color.

func (*Context) ClearPath

func (dc *Context) ClearPath()

ClearPath clears the current path. There is no current point after this operation.

func (*Context) ClearShadow

func (dc *Context) ClearShadow()

ClearShadow removes the shadow effect

func (*Context) Clip

func (dc *Context) Clip()

Clip updates the clipping region by intersecting the current clipping region with the current path as it would be filled by dc.Fill(). The path is cleared after this operation.

func (*Context) ClipPath2D

func (dc *Context) ClipPath2D(path2d *Path2D)

ClipPath2D sets a Path2D object as the clipping region

func (*Context) ClipPreserve

func (dc *Context) ClipPreserve()

ClipPreserve updates the clipping region by intersecting the current clipping region with the current path as it would be filled by dc.Fill(). The path is preserved after this operation.

func (*Context) ClosePath

func (dc *Context) ClosePath()

ClosePath adds a line segment from the current point to the beginning of the current subpath. If there is no current point, this is a no-op.

func (*Context) CompositeImage

func (dc *Context) CompositeImage(src image.Image, dstX, dstY int, blendMode draw.Op)

CompositeImage composites two images using the specified blend mode

func (*Context) CompositeToImage

func (dc *Context) CompositeToImage()

CompositeToImage renders all layers to the main image

func (*Context) ConvertToColorSpace

func (dc *Context) ConvertToColorSpace(targetProfile *ICCProfile)

ConvertToColorSpace converts the current image to a different color space

func (*Context) CreateImageData

func (dc *Context) CreateImageData(width, height int) *ImageData

CreateImageData creates a new ImageData with the specified dimensions

func (*Context) CubicTo

func (dc *Context) CubicTo(x1, y1, x2, y2, x3, y3 float64)

CubicTo adds a cubic bezier curve to the current path starting at the current point. If there is no current point, it first performs MoveTo(x1, y1). Because freetype/raster does not support cubic beziers, this is emulated with many small line segments.

func (*Context) DisableLayers

func (dc *Context) DisableLayers()

DisableLayers disables the layer system

func (*Context) DrawAlignedText

func (dc *Context) DrawAlignedText(text string, x, y, width float64, hAlign, vAlign Align)

DrawAlignedText draws text with various alignment options

func (*Context) DrawArc

func (dc *Context) DrawArc(x, y, r, angle1, angle2 float64)

func (*Context) DrawCachedCircle

func (dc *Context) DrawCachedCircle(x, y, radius float64, fill bool)

DrawCachedCircle draws a circle using cache if available

func (*Context) DrawCachedText

func (dc *Context) DrawCachedText(text string, x, y float64)

DrawCachedText draws text using cache if available

func (*Context) DrawCircle

func (dc *Context) DrawCircle(x, y, r float64)

func (*Context) DrawCircleOnImage

func (dc *Context) DrawCircleOnImage(x, y, r float64)

DrawCircleOnImage draws a circle directly on an existing image at specified coordinates This is useful for adding circles to loaded images without creating new contexts

func (*Context) DrawCircleWithBorder

func (dc *Context) DrawCircleWithBorder(x, y, r float64, fillColor, borderColor color.Color, borderWidth float64)

DrawCircleWithBorder draws a circle with fill and border

func (*Context) DrawCircleWithShadow

func (dc *Context) DrawCircleWithShadow(x, y, r float64)

DrawCircleWithShadow draws a circle with shadow support

func (*Context) DrawDashedLine

func (dc *Context) DrawDashedLine(x1, y1, x2, y2 float64, pattern []float64)

DrawDashedLine draws a dashed line

func (*Context) DrawDonut

func (dc *Context) DrawDonut(x, y, outerRadius, innerRadius float64)

DrawDonut draws a donut (ring) shape

func (*Context) DrawEllipse

func (dc *Context) DrawEllipse(x, y, rx, ry float64)

func (*Context) DrawEllipseOnImage

func (dc *Context) DrawEllipseOnImage(x, y, rx, ry float64)

DrawEllipseOnImage draws an ellipse directly on the existing image

func (*Context) DrawEllipseWithShadow

func (dc *Context) DrawEllipseWithShadow(x, y, rx, ry float64)

DrawEllipseWithShadow draws an ellipse with shadow support

func (*Context) DrawEllipticalArc

func (dc *Context) DrawEllipticalArc(x, y, rx, ry, angle1, angle2 float64)

func (*Context) DrawFilledCircle

func (dc *Context) DrawFilledCircle(x, y, r float64)

DrawFilledCircle draws a filled circle

func (*Context) DrawGradientLine

func (dc *Context) DrawGradientLine(x1, y1, x2, y2 float64, stops []StrokeGradientStop)

DrawGradientLine draws a line with gradient stroke

func (*Context) DrawImage

func (dc *Context) DrawImage(im image.Image, x, y int)

DrawImage draws the specified image at the specified point.

func (*Context) DrawImageAnchored

func (dc *Context) DrawImageAnchored(im image.Image, x, y int, ax, ay float64)

DrawImageAnchored draws the specified image at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the image. Use ax=0.5, ay=0.5 to center the image at the specified point.

func (*Context) DrawImageAnchoredWithShadow

func (dc *Context) DrawImageAnchoredWithShadow(im image.Image, x, y int, ax, ay float64)

DrawImageAnchoredWithShadow draws an anchored image with shadow support

func (*Context) DrawImageWithShadow

func (dc *Context) DrawImageWithShadow(im image.Image, x, y int)

DrawImageWithShadow draws an image with shadow support

func (*Context) DrawLine

func (dc *Context) DrawLine(x1, y1, x2, y2 float64)

func (*Context) DrawPath2D

func (dc *Context) DrawPath2D(path2d *Path2D)

DrawPath2D draws a Path2D object to the context

func (*Context) DrawPieSlice

func (dc *Context) DrawPieSlice(x, y, radius, startAngle, endAngle float64)

DrawPieSlice draws a pie slice (sector)

func (*Context) DrawPoint

func (dc *Context) DrawPoint(x, y, r float64)

DrawPoint is like DrawCircle but ensures that a circle of the specified size is drawn regardless of the current transformation matrix. The position is still transformed, but not the shape of the point.

func (*Context) DrawPolygon

func (dc *Context) DrawPolygon(x, y, radius float64, sides int)

DrawPolygon draws a regular polygon with n sides

func (*Context) DrawRectangle

func (dc *Context) DrawRectangle(x, y, w, h float64)

func (*Context) DrawRectangleOnImage

func (dc *Context) DrawRectangleOnImage(x, y, w, h float64)

DrawRectangleOnImage draws a rectangle directly on the existing image

func (*Context) DrawRectangleWithShadow

func (dc *Context) DrawRectangleWithShadow(x, y, w, h float64)

DrawRectangleWithShadow draws a rectangle with shadow support

func (*Context) DrawRegularPolygon

func (dc *Context) DrawRegularPolygon(n int, x, y, r, rotation float64)

func (*Context) DrawRoundedRectangle

func (dc *Context) DrawRoundedRectangle(x, y, w, h, r float64)

func (*Context) DrawRoundedRectangleOnImage

func (dc *Context) DrawRoundedRectangleOnImage(x, y, w, h, r float64)

DrawRoundedRectangleOnImage draws a rounded rectangle on the existing image

func (*Context) DrawRoundedRectangleWithShadow

func (dc *Context) DrawRoundedRectangleWithShadow(x, y, w, h, r float64)

DrawRoundedRectangleWithShadow draws a rounded rectangle with shadow support

func (*Context) DrawShapedString

func (dc *Context) DrawShapedString(text string, x, y float64)

DrawShapedString draws shaped text

func (*Context) DrawStar

func (dc *Context) DrawStar(x, y, outerRadius, innerRadius float64, points int)

DrawStar draws a star shape

func (*Context) DrawString

func (dc *Context) DrawString(s string, x, y float64)

DrawString draws the specified text at the specified point.

func (*Context) DrawStringAnchored

func (dc *Context) DrawStringAnchored(s string, x, y, ax, ay float64)

DrawStringAnchored draws the specified text at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the text. Use ax=0.5, ay=0.5 to center the text at the specified point.

func (*Context) DrawStringAnchoredWithShadow

func (dc *Context) DrawStringAnchoredWithShadow(s string, x, y, ax, ay float64)

DrawStringAnchoredWithShadow draws anchored text with shadow support

func (*Context) DrawStringWithEmoji

func (dc *Context) DrawStringWithEmoji(text string, x, y float64)

DrawStringWithEmoji draws text with emoji support

func (*Context) DrawStringWithShadow

func (dc *Context) DrawStringWithShadow(s string, x, y float64)

DrawStringWithShadow draws text with shadow support

func (*Context) DrawStringWrapped

func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align)

DrawStringWrapped word-wraps the specified string to the given max width and then draws it at the specified anchor point using the given line spacing and text alignment.

func (*Context) DrawStrokedCircle

func (dc *Context) DrawStrokedCircle(x, y, r float64)

DrawStrokedCircle draws a circle outline

func (*Context) DrawTaperedLine

func (dc *Context) DrawTaperedLine(x1, y1, x2, y2 float64, startWidth, endWidth float64)

DrawTaperedLine draws a line with tapered ends

func (*Context) DrawTextBox

func (dc *Context) DrawTextBox(text string, x, y, width, height float64, align Align)

DrawTextBox draws text within a bounding box with automatic word wrapping Similar to Pillow's textbbox functionality

func (*Context) DrawTextBoxAnchored

func (dc *Context) DrawTextBoxAnchored(text string, x, y, ax, ay, width, height float64, align Align)

DrawTextBoxAnchored draws text in a box with anchor positioning

func (*Context) EnableGuides

func (dc *Context) EnableGuides()

EnableGuides enables the guide system

func (*Context) EnableLayers

func (dc *Context) EnableLayers()

EnableLayers enables the layer system

func (*Context) EnableNonDestructiveEditing

func (dc *Context) EnableNonDestructiveEditing()

EnableNonDestructiveEditing enables non-destructive editing

func (*Context) EncodeJPG

func (dc *Context) EncodeJPG(w io.Writer, o *jpeg.Options) error

EncodeJPG encodes the image as a JPG and writes it to the provided io.Writer in JPEG 4:2:0 baseline format with the given options. Default parameters are used if a nil *jpeg.Options is passed.

func (*Context) EncodePNG

func (dc *Context) EncodePNG(w io.Writer) error

EncodePNG encodes the image as a PNG and writes it to the provided io.Writer.

func (*Context) ExecuteBatch

func (dc *Context) ExecuteBatch(batch *Batch)

ExecuteBatch executes a batch of operations

func (*Context) Fill

func (dc *Context) Fill()

Fill fills the current path with the current color. Open subpaths are implicity closed. The path is cleared after this operation.

func (*Context) FillPath2D

func (dc *Context) FillPath2D(path2d *Path2D)

FillPath2D fills a Path2D object

func (*Context) FillPreserve

func (dc *Context) FillPreserve()

FillPreserve fills the current path with the current color. Open subpaths are implicity closed. The path is preserved after this operation.

func (*Context) FillWithShadow

func (dc *Context) FillWithShadow()

FillWithShadow fills the current path with shadow support

func (*Context) FontHeight

func (dc *Context) FontHeight() float64

func (*Context) GetActiveLayer

func (dc *Context) GetActiveLayer() *Layer

GetActiveLayer returns the active layer

func (*Context) GetAdvancedStroke

func (dc *Context) GetAdvancedStroke() *StrokeStyle

GetAdvancedStroke returns the current advanced stroke style

func (*Context) GetBaseline

func (dc *Context) GetBaseline() float64

GetBaseline returns the baseline position for the current font

func (*Context) GetColorProfile

func (dc *Context) GetColorProfile() *ICCProfile

GetColorProfile returns the current color profile

func (*Context) GetCurrentPoint

func (dc *Context) GetCurrentPoint() (Point, bool)

GetCurrentPoint will return the current point and if there is a current point. The point will have been transformed by the context's transformation matrix.

func (*Context) GetEditStack

func (dc *Context) GetEditStack() *EditStack

GetEditStack returns the edit stack

func (*Context) GetEmojiRenderer

func (dc *Context) GetEmojiRenderer() *EmojiRenderer

GetEmojiRenderer returns the current emoji renderer

func (*Context) GetFontMetrics

func (dc *Context) GetFontMetrics() (ascent, descent, lineGap float64)

GetFontMetrics returns metrics for the current font

func (*Context) GetGuideManager

func (dc *Context) GetGuideManager() *GuideManager

GetGuideManager returns the guide manager

func (*Context) GetImageData

func (dc *Context) GetImageData() *ImageData

GetImageData returns the current image as ImageData for pixel manipulation

func (*Context) GetImageDataRegion

func (dc *Context) GetImageDataRegion(x, y, width, height int) *ImageData

GetImageDataRegion returns a region of the current image as ImageData

func (*Context) GetLayerManager

func (dc *Context) GetLayerManager() *LayerManager

GetLayerManager returns the layer manager

func (*Context) GetLineHeight

func (dc *Context) GetLineHeight() float64

GetLineHeight returns the recommended line height for the current font

func (*Context) GetTextBoxSize

func (dc *Context) GetTextBoxSize(text string, maxWidth float64) (width, height float64)

GetTextBoxSize calculates the size needed for a text box

func (*Context) GetTextHeight

func (dc *Context) GetTextHeight() float64

GetTextHeight returns the height of the current font

func (*Context) GetTextShaper

func (dc *Context) GetTextShaper() *TextShaper

GetTextShaper returns the current text shaper

func (*Context) GetTextWidth

func (dc *Context) GetTextWidth(s string) float64

GetTextWidth returns the width of the specified text

func (*Context) HasShadow

func (dc *Context) HasShadow() bool

HasShadow returns true if shadow is enabled

func (*Context) Height

func (dc *Context) Height() int

Height returns the height of the image in pixels.

func (*Context) Identity

func (dc *Context) Identity()

Identity resets the current transformation matrix to the identity matrix. This results in no translating, scaling, rotating, or shearing.

func (*Context) Image

func (dc *Context) Image() image.Image

Image returns the image that has been drawn by this context.

func (*Context) InvertMask

func (dc *Context) InvertMask()

InvertMask inverts the alpha values in the current clipping mask such that a fully transparent region becomes fully opaque and vice versa.

func (*Context) InvertY

func (dc *Context) InvertY()

InvertY flips the Y axis so that Y grows from bottom to top and Y=0 is at the bottom of the image.

func (*Context) IsPointInPath2D

func (dc *Context) IsPointInPath2D(path2d *Path2D, x, y float64) bool

IsPointInPath2D tests if a point is inside a Path2D object

func (*Context) LineTo

func (dc *Context) LineTo(x, y float64)

LineTo adds a line segment to the current path starting at the current point. If there is no current point, it is equivalent to MoveTo(x, y)

func (*Context) LoadFontFace

func (dc *Context) LoadFontFace(path string, points float64) error

func (*Context) LoadFontFaceFromBytes

func (dc *Context) LoadFontFaceFromBytes(fontBytes []byte, points float64) error

LoadFontFaceFromBytes loads a font from byte data and sets it as the current font face. Supports both TTF and OTF formats.

func (*Context) LoadFontFaceWithOptions

func (dc *Context) LoadFontFaceWithOptions(path string, options *truetype.Options) error

LoadFontFaceWithOptions loads a font with custom truetype options.

func (*Context) LoadOTFFace

func (dc *Context) LoadOTFFace(path string, points float64) error

LoadOTFFace loads an OTF font file and sets it as the current font face.

func (*Context) LoadTTFFace

func (dc *Context) LoadTTFFace(path string, points float64) error

LoadTTFFace loads a TTF font file and sets it as the current font face.

func (*Context) MeasureMultilineString

func (dc *Context) MeasureMultilineString(s string, lineSpacing float64) (width, height float64)

func (*Context) MeasureString

func (dc *Context) MeasureString(s string) (w, h float64)

MeasureString returns the rendered width and height of the specified text given the current font face.

func (*Context) MeasureTextMetrics

func (dc *Context) MeasureTextMetrics(s string) TextMetrics

MeasureTextMetrics returns detailed metrics for the specified text

func (*Context) MoveTo

func (dc *Context) MoveTo(x, y float64)

MoveTo starts a new subpath within the current path starting at the specified point.

func (*Context) NewSubPath

func (dc *Context) NewSubPath()

NewSubPath starts a new subpath within the current path. There is no current point after this operation.

func (*Context) PasteImage

func (dc *Context) PasteImage(im image.Image, x, y int)

PasteImage pastes an image onto the context at the specified position Similar to Pillow's paste() function

func (*Context) PasteImageWithMask

func (dc *Context) PasteImageWithMask(im image.Image, mask image.Image, x, y int)

PasteImageWithMask pastes an image with a mask (transparency)

func (*Context) Pop

func (dc *Context) Pop()

Pop restores the last saved context state from the stack.

func (*Context) Push

func (dc *Context) Push()

Push saves the current state of the context for later retrieval. These can be nested.

func (*Context) PutImageData

func (dc *Context) PutImageData(imageData *ImageData)

PutImageData replaces the current image with ImageData

func (*Context) PutImageDataAt

func (dc *Context) PutImageDataAt(imageData *ImageData, x, y int)

PutImageDataAt places ImageData at the specified coordinates

func (*Context) QuadraticTo

func (dc *Context) QuadraticTo(x1, y1, x2, y2 float64)

QuadraticTo adds a quadratic bezier curve to the current path starting at the current point. If there is no current point, it first performs MoveTo(x1, y1)

func (*Context) ResetClip

func (dc *Context) ResetClip()

ResetClip clears the clipping region.

func (*Context) Rotate

func (dc *Context) Rotate(angle float64)

Rotate updates the current matrix with a anticlockwise rotation. Rotation occurs about the origin. Angle is specified in radians.

func (*Context) RotateAbout

func (dc *Context) RotateAbout(angle, x, y float64)

RotateAbout updates the current matrix with a anticlockwise rotation. Rotation occurs about the specified point. Angle is specified in radians.

func (*Context) SaveBMP

func (dc *Context) SaveBMP(path string) error

SaveBMP saves the current image as a BMP file.

func (*Context) SaveGIF

func (dc *Context) SaveGIF(path string) error

SaveGIF saves the current image as a GIF file.

func (*Context) SaveJPEG

func (dc *Context) SaveJPEG(path string, quality int) error

SaveJPEG saves the current image as a JPEG file.

func (*Context) SaveJPG

func (dc *Context) SaveJPG(path string, quality int) error

SaveJPG encodes the image as a JPG and writes it to disk.

func (*Context) SavePNG

func (dc *Context) SavePNG(path string) error

SavePNG encodes the image as a PNG and writes it to disk.

func (*Context) SaveTIFF

func (dc *Context) SaveTIFF(path string) error

SaveTIFF saves the current image as a TIFF file.

func (*Context) Scale

func (dc *Context) Scale(x, y float64)

Scale updates the current matrix with a scaling factor. Scaling occurs about the origin.

func (*Context) ScaleAbout

func (dc *Context) ScaleAbout(sx, sy, x, y float64)

ScaleAbout updates the current matrix with a scaling factor. Scaling occurs about the specified point.

func (*Context) SetActiveLayer

func (dc *Context) SetActiveLayer(index int) bool

SetActiveLayer sets the active layer

func (*Context) SetActiveLayerByName

func (dc *Context) SetActiveLayerByName(name string) bool

SetActiveLayerByName sets the active layer by name

func (*Context) SetAdvancedStroke

func (dc *Context) SetAdvancedStroke(style *StrokeStyle)

SetAdvancedStroke sets an advanced stroke style for the context

func (*Context) SetCMYK

func (dc *Context) SetCMYK(c, m, y, k float64)

SetCMYK sets the current color using CMYK values (0-1 range)

func (*Context) SetColor

func (dc *Context) SetColor(c color.Color)

SetColor sets the current color(for both fill and stroke).

func (*Context) SetColorConverter

func (dc *Context) SetColorConverter(converter *ColorConverter)

SetColorConverter sets the color converter for the context

func (*Context) SetColorProfile

func (dc *Context) SetColorProfile(profile *ICCProfile)

SetColorProfile sets the color profile for the context

func (*Context) SetDash

func (dc *Context) SetDash(dashes ...float64)

SetDash sets the current dash pattern to use. Call with zero arguments to disable dashes. The values specify the lengths of each dash, with alternating on and off lengths.

func (*Context) SetDashOffset

func (dc *Context) SetDashOffset(offset float64)

SetDashOffset sets the initial offset into the dash pattern to use when stroking dashed paths.

func (*Context) SetEmojiRenderer

func (dc *Context) SetEmojiRenderer(renderer *EmojiRenderer)

SetEmojiRenderer sets the emoji renderer for the context

func (*Context) SetFillRule

func (dc *Context) SetFillRule(fillRule FillRule)

func (*Context) SetFillRuleEvenOdd

func (dc *Context) SetFillRuleEvenOdd()

func (*Context) SetFillRuleWinding

func (dc *Context) SetFillRuleWinding()

func (*Context) SetFillStyle

func (dc *Context) SetFillStyle(pattern Pattern)

SetFillStyle sets current fill style

func (*Context) SetFontFace

func (dc *Context) SetFontFace(fontFace font.Face)

func (*Context) SetHSL

func (dc *Context) SetHSL(h, s, l float64)

SetHSL sets the current color using HSL values

func (*Context) SetHSV

func (dc *Context) SetHSV(h, s, v float64)

SetHSV sets the current color using HSV values

func (*Context) SetHexColor

func (dc *Context) SetHexColor(x string)

SetHexColor sets the current color using a hex string. The leading pound sign (#) is optional. Both 3- and 6-digit variations are supported. 8 digits may be provided to set the alpha value as well.

func (*Context) SetLAB

func (dc *Context) SetLAB(l, a, b float64)

SetLAB sets the current color using LAB values

func (*Context) SetLineCap

func (dc *Context) SetLineCap(lineCap LineCap)

func (*Context) SetLineCapButt

func (dc *Context) SetLineCapButt()

func (*Context) SetLineCapRound

func (dc *Context) SetLineCapRound()

func (*Context) SetLineCapSquare

func (dc *Context) SetLineCapSquare()

func (*Context) SetLineJoin

func (dc *Context) SetLineJoin(lineJoin LineJoin)

func (*Context) SetLineJoinBevel

func (dc *Context) SetLineJoinBevel()

func (*Context) SetLineJoinRound

func (dc *Context) SetLineJoinRound()

func (*Context) SetLineWidth

func (dc *Context) SetLineWidth(lineWidth float64)

func (*Context) SetMask

func (dc *Context) SetMask(mask *image.Alpha) error

SetMask allows you to directly set the *image.Alpha to be used as a clipping mask. It must be the same size as the context, else an error is returned and the mask is unchanged.

func (*Context) SetPixel

func (dc *Context) SetPixel(x, y int)

SetPixel sets the color of the specified pixel using the current color.

func (*Context) SetRGB

func (dc *Context) SetRGB(r, g, b float64)

SetRGB sets the current color. r, g, b values should be between 0 and 1, inclusive. Alpha will be set to 1 (fully opaque).

func (*Context) SetRGB255

func (dc *Context) SetRGB255(r, g, b int)

SetRGB255 sets the current color. r, g, b values should be between 0 and 255, inclusive. Alpha will be set to 255 (fully opaque).

func (*Context) SetRGBA

func (dc *Context) SetRGBA(r, g, b, a float64)

SetRGBA sets the current color. r, g, b, a values should be between 0 and 1, inclusive.

func (*Context) SetRGBA255

func (dc *Context) SetRGBA255(r, g, b, a int)

SetRGBA255 sets the current color. r, g, b, a values should be between 0 and 255, inclusive.

func (*Context) SetShadow

func (dc *Context) SetShadow(offsetX, offsetY, blur float64, shadowColor color.Color)

SetShadow sets the shadow properties

func (*Context) SetShadowRGBA

func (dc *Context) SetShadowRGBA(offsetX, offsetY, blur, r, g, b, a float64)

SetShadowRGBA sets the shadow with RGBA color

func (*Context) SetStrokeStyle

func (dc *Context) SetStrokeStyle(pattern Pattern)

SetStrokeStyle sets current stroke style

func (*Context) SetTextShaper

func (dc *Context) SetTextShaper(shaper *TextShaper)

SetTextShaper sets the text shaper for the context

func (*Context) Shear

func (dc *Context) Shear(x, y float64)

Shear updates the current matrix with a shearing angle. Shearing occurs about the origin.

func (*Context) ShearAbout

func (dc *Context) ShearAbout(sx, sy, x, y float64)

ShearAbout updates the current matrix with a shearing angle. Shearing occurs about the specified point.

func (*Context) SnapPoint

func (dc *Context) SnapPoint(x, y float64) (float64, float64)

SnapPoint snaps a point to guides or grid

func (*Context) Stroke

func (dc *Context) Stroke()

Stroke strokes the current path with the current color, line width, line cap, line join and dash settings. The path is cleared after this operation.

func (*Context) StrokePath2D

func (dc *Context) StrokePath2D(path2d *Path2D)

StrokePath2D strokes a Path2D object

func (*Context) StrokePreserve

func (dc *Context) StrokePreserve()

StrokePreserve strokes the current path with the current color, line width, line cap, line join and dash settings. The path is preserved after this operation.

func (*Context) StrokeWithShadow

func (dc *Context) StrokeWithShadow()

StrokeWithShadow strokes the current path with shadow support

func (*Context) TransformPoint

func (dc *Context) TransformPoint(x, y float64) (tx, ty float64)

TransformPoint multiplies the specified point by the current matrix, returning a transformed position.

func (*Context) Translate

func (dc *Context) Translate(x, y float64)

Translate updates the current matrix with a translation.

func (*Context) ValidateContext

func (dc *Context) ValidateContext() error

ValidateContext validates that a context is in a valid state

func (*Context) ValidateFontLoaded

func (dc *Context) ValidateFontLoaded() error

ValidateFontLoaded validates that a font is loaded

func (*Context) Width

func (dc *Context) Width() int

Width returns the width of the image in pixels.

func (*Context) WordWrap

func (dc *Context) WordWrap(s string, w float64) []string

WordWrap wraps the specified string to the given max width and current font face.

func (*Context) WrapText

func (dc *Context) WrapText(text string, maxWidth float64) []string

WrapText wraps text to fit within the specified width and returns the lines

type ContextPool

type ContextPool struct {
	// contains filtered or unexported fields
}

ContextPool manages a pool of Context objects

func NewContextPool

func NewContextPool() *ContextPool

NewContextPool creates a new context pool

func (*ContextPool) Get

func (p *ContextPool) Get() *Context

Get retrieves a context from the pool

func (*ContextPool) Put

func (p *ContextPool) Put(ctx *Context)

Put returns a context to the pool

type ContrastOperation

type ContrastOperation struct {
	Amount float64
}

ContrastOperation adjusts image contrast

func (*ContrastOperation) Apply

func (op *ContrastOperation) Apply(img *image.RGBA) *image.RGBA

func (*ContrastOperation) Clone

func (op *ContrastOperation) Clone() EditOperation

func (*ContrastOperation) GetParameters

func (op *ContrastOperation) GetParameters() map[string]interface{}

func (*ContrastOperation) GetType

func (op *ContrastOperation) GetType() string

func (*ContrastOperation) SetParameters

func (op *ContrastOperation) SetParameters(params map[string]interface{})

type CropOperation

type CropOperation struct {
	X, Y, Width, Height int
}

CropOperation crops the image

func (*CropOperation) Apply

func (op *CropOperation) Apply(img *image.RGBA) *image.RGBA

func (*CropOperation) Clone

func (op *CropOperation) Clone() EditOperation

func (*CropOperation) GetParameters

func (op *CropOperation) GetParameters() map[string]interface{}

func (*CropOperation) GetType

func (op *CropOperation) GetType() string

func (*CropOperation) SetParameters

func (op *CropOperation) SetParameters(params map[string]interface{})

type DebugConfig

type DebugConfig struct {
	Mode               DebugMode
	ShowBounds         bool
	ShowGrid           bool
	ShowCoordinates    bool
	ShowPerformance    bool
	ShowMemoryUsage    bool
	LogOperations      bool
	HighlightSlowOps   bool
	GridSize           int
	BoundsColor        color.Color
	GridColor          color.Color
	CoordinateColor    color.Color
	PerformanceOverlay bool
}

DebugConfig holds debug configuration

func DefaultDebugConfig

func DefaultDebugConfig() DebugConfig

DefaultDebugConfig returns the default debug configuration

type DebugContext

type DebugContext struct {
	*Context
	// contains filtered or unexported fields
}

DebugContext wraps a Context with debug functionality

func NewDebugContext

func NewDebugContext(width, height int) *DebugContext

NewDebugContext creates a new debug context

func (*DebugContext) ClearDebugInfo

func (dc *DebugContext) ClearDebugInfo()

ClearDebugInfo clears all debug information

func (*DebugContext) DebugDrawCircle

func (dc *DebugContext) DebugDrawCircle(x, y, radius float64)

DebugDrawCircle draws a circle with debug information

func (*DebugContext) DebugDrawRectangle

func (dc *DebugContext) DebugDrawRectangle(x, y, width, height float64)

DebugDrawRectangle draws a rectangle with debug information

func (*DebugContext) DebugDrawString

func (dc *DebugContext) DebugDrawString(text string, x, y float64)

DebugDrawString draws text with debug information

func (*DebugContext) DrawDebugGrid

func (dc *DebugContext) DrawDebugGrid()

DrawDebugGrid draws a debug grid overlay

func (*DebugContext) DrawPerformanceOverlay

func (dc *DebugContext) DrawPerformanceOverlay()

DrawPerformanceOverlay draws performance information

func (*DebugContext) GetDebugInfo

func (dc *DebugContext) GetDebugInfo() []DebugInfo

GetDebugInfo returns debug information for all operations

func (*DebugContext) PrintDebugSummary

func (dc *DebugContext) PrintDebugSummary()

PrintDebugSummary prints a summary of debug information

type DebugInfo

type DebugInfo struct {
	Operation   string
	StartTime   time.Time
	EndTime     time.Time
	Duration    time.Duration
	MemoryUsed  int64
	Parameters  map[string]interface{}
	BoundingBox Rectangle
}

DebugInfo holds debug information for operations

type DebugMode

type DebugMode int

DebugMode represents the current debug mode

const (
	DebugModeOff DebugMode = iota
	DebugModeBasic
	DebugModeVerbose
	DebugModePerformance
)

type DeviceClass

type DeviceClass uint32

DeviceClass represents ICC device class

const (
	DeviceClassInput      DeviceClass = 0x73636E72 // 'scnr'
	DeviceClassDisplay    DeviceClass = 0x6D6E7472 // 'mntr'
	DeviceClassOutput     DeviceClass = 0x70727472 // 'prtr'
	DeviceClassLink       DeviceClass = 0x6C696E6B // 'link'
	DeviceClassAbstract   DeviceClass = 0x61627374 // 'abst'
	DeviceClassNamedColor DeviceClass = 0x6E6D636C // 'nmcl'
)

type Document

type Document struct {
	Root *Element
	// contains filtered or unexported fields
}

Document represents a collection of elements

func NewDocument

func NewDocument() *Document

NewDocument creates a new document

func (*Document) AddElement

func (d *Document) AddElement(element *Element)

AddElement adds an element to the document

func (*Document) AddStyle

func (d *Document) AddStyle(selector string, style Style)

AddStyle adds a CSS-like style rule

func (*Document) ApplyStyles

func (d *Document) ApplyStyles()

ApplyStyles applies CSS-like styles to elements

func (*Document) GetElementByID

func (d *Document) GetElementByID(id string) *Element

GetElementByID gets an element by ID

func (*Document) GetElementsByClass

func (d *Document) GetElementsByClass(className string) []*Element

GetElementsByClass gets elements by class name

func (*Document) Render

func (d *Document) Render(ctx *Context)

Render renders the entire document

type EasingFunc

type EasingFunc func(t float64) float64

Easing functions for smooth animations

type EditOperation

type EditOperation interface {
	Apply(img *image.RGBA) *image.RGBA
	GetType() string
	GetParameters() map[string]interface{}
	SetParameters(params map[string]interface{})
	Clone() EditOperation
}

EditOperation represents a single editing operation

type EditStack

type EditStack struct {
	Operations   []EditOperation
	BaseImage    *image.RGBA
	CachedResult *image.RGBA
	CacheDirty   bool
}

EditStack manages a stack of non-destructive operations

func NewEditStack

func NewEditStack(baseImage *image.RGBA) *EditStack

NewEditStack creates a new edit stack

func (*EditStack) AddOperation

func (es *EditStack) AddOperation(op EditOperation)

AddOperation adds an operation to the stack

func (*EditStack) Clear

func (es *EditStack) Clear()

Clear removes all operations

func (*EditStack) Clone

func (es *EditStack) Clone() *EditStack

Clone creates a copy of the edit stack

func (*EditStack) GetPreview

func (es *EditStack) GetPreview(upToIndex int) *image.RGBA

GetPreview returns a preview up to the specified operation index

func (*EditStack) GetResult

func (es *EditStack) GetResult() *image.RGBA

GetResult returns the final processed image

func (*EditStack) InsertOperation

func (es *EditStack) InsertOperation(index int, op EditOperation)

InsertOperation inserts an operation at the specified index

func (*EditStack) MoveOperation

func (es *EditStack) MoveOperation(from, to int) bool

MoveOperation moves an operation from one index to another

func (*EditStack) RemoveOperation

func (es *EditStack) RemoveOperation(index int) bool

RemoveOperation removes an operation by index

func (*EditStack) UpdateOperation

func (es *EditStack) UpdateOperation(index int, params map[string]interface{}) bool

UpdateOperation updates an operation's parameters

type Element

type Element struct {
	ID       string
	Classes  []string
	Styles   map[string]interface{}
	Children []*Element
	Parent   *Element
	Shape    Shape
}

Element represents a drawable element with ID and styles

func CreateCircle

func CreateCircle(id string, x, y, radius float64) *Element

CreateCircle creates a circle element

func CreateLine

func CreateLine(id string, x1, y1, x2, y2 float64) *Element

CreateLine creates a line element

func CreateRect

func CreateRect(id string, x, y, width, height float64) *Element

CreateRect creates a rectangle element

func CreateText

func CreateText(id string, x, y float64, text string) *Element

CreateText creates a text element

func NewElement

func NewElement(id string) *Element

NewElement creates a new element

func (*Element) AddChild

func (e *Element) AddChild(child *Element)

AddChild adds a child element

func (*Element) AddClass

func (e *Element) AddClass(class string)

AddClass adds a CSS class

func (*Element) Draw

func (e *Element) Draw(ctx *Context)

Draw renders the element and its children

func (*Element) GetStyle

func (e *Element) GetStyle(property string) interface{}

GetStyle gets a style property

func (*Element) HasClass

func (e *Element) HasClass(class string) bool

HasClass checks if element has a CSS class

func (*Element) RemoveChild

func (e *Element) RemoveChild(child *Element)

RemoveChild removes a child element

func (*Element) RemoveClass

func (e *Element) RemoveClass(class string)

RemoveClass removes a CSS class

func (*Element) SetStyle

func (e *Element) SetStyle(property string, value interface{})

SetStyle sets a style property

type EmojiInfo

type EmojiInfo struct {
	Codepoint   string
	Name        string
	Category    string
	Subcategory string
	Keywords    []string
	SkinTones   []string
	ZWJSequence bool
	Modifiable  bool
}

EmojiInfo represents information about an emoji

type EmojiRenderer

type EmojiRenderer struct {
	ColorFonts   []string
	FallbackFont string
	EmojiSize    float64
	EnableSVG    bool
	EnableBitmap bool
	Cache        map[string]*image.RGBA
	// contains filtered or unexported fields
}

EmojiRenderer handles emoji rendering with proper color font support

func NewEmojiRenderer

func NewEmojiRenderer() *EmojiRenderer

NewEmojiRenderer creates a new emoji renderer

func (*EmojiRenderer) GetEmojiCategory

func (er *EmojiRenderer) GetEmojiCategory(r rune) string

GetEmojiCategory gets the category of an emoji

func (*EmojiRenderer) GetEmojiInfo

func (er *EmojiRenderer) GetEmojiInfo(emojiText string) *EmojiInfo

GetEmojiInfo gets information about an emoji

func (*EmojiRenderer) LoadEmojiFont

func (er *EmojiRenderer) LoadEmojiFont(fontPath string) error

LoadEmojiFont loads an emoji font from the specified path

func (*EmojiRenderer) ParseEmojiSequence

func (er *EmojiRenderer) ParseEmojiSequence(text string) []EmojiSequence

ParseEmojiSequence parses an emoji sequence including ZWJ sequences

func (*EmojiRenderer) RenderEmoji

func (er *EmojiRenderer) RenderEmoji(sequence EmojiSequence, size float64) *image.RGBA

RenderEmoji renders an emoji sequence

type EmojiSequence

type EmojiSequence struct {
	Runes       []rune
	Text        string
	IsZWJ       bool
	HasModifier bool
	SkinTone    string
	Category    string
}

EmojiSequence represents a complete emoji sequence

type ErrorHandler

type ErrorHandler func(error)

ErrorHandler is a function type for handling errors

var DefaultErrorHandler ErrorHandler = func(err error) {
	if err != nil {
		fmt.Printf("AdvanceGG Error: %v\n", err)
	}
}

DefaultErrorHandler is the default error handler

type ErrorType

type ErrorType int

ErrorType represents different types of errors

const (
	ErrorTypeInvalidParameter ErrorType = iota
	ErrorTypeFileNotFound
	ErrorTypeInvalidFormat
	ErrorTypeOutOfBounds
	ErrorTypeInvalidState
	ErrorTypeMemoryError
	ErrorTypeRenderError
	ErrorTypeUnsupportedOperation
)

type FillRule

type FillRule int
const (
	FillRuleWinding FillRule = iota
	FillRuleEvenOdd
)

type Filter

type Filter func(img image.Image) image.Image

Filter represents an image filter function

func BatchFilter

func BatchFilter(filters ...Filter) Filter

BatchFilter applies multiple filters efficiently

func Blur

func Blur(radius int) Filter

Blur applies a simple box blur

func Brightness

func Brightness(factor float64) Filter

Brightness adjusts the brightness of the image

func Contrast

func Contrast(factor float64) Filter

Contrast adjusts the contrast of the image

func FastBlur

func FastBlur(radius int) Filter

FastBlur is an optimized blur filter using separable convolution

func FastBrightness

func FastBrightness(factor float64) Filter

FastBrightness is an optimized brightness filter

func FastContrast

func FastContrast(factor float64) Filter

FastContrast is an optimized contrast filter

func FastEdgeDetection

func FastEdgeDetection() Filter

FastEdgeDetection is an optimized edge detection filter

func FastSharpen

func FastSharpen(amount float64) Filter

FastSharpen is an optimized sharpen filter

func Noise

func Noise(intensity float64) Filter

Noise adds random noise to the image

func ParallelFilter

func ParallelFilter(filter Filter, numWorkers int) Filter

ParallelFilter applies a filter using parallel processing

func Pixelate

func Pixelate(blockSize int) Filter

Pixelate creates a pixelated effect

func Posterize

func Posterize(levels int) Filter

Posterize reduces the number of colors

func Threshold

func Threshold(threshold uint8) Filter

Threshold applies a threshold effect

func Vignette

func Vignette(strength float64) Filter

Vignette applies a vignette effect

type FontCache

type FontCache struct {
	*Cache
}

FontCache caches font faces and metrics

func NewFontCache

func NewFontCache(maxSize int64, maxItems int) *FontCache

NewFontCache creates a new font cache

type Gradient

type Gradient interface {
	Pattern
	AddColorStop(offset float64, color color.Color)
}

func NewConicGradient

func NewConicGradient(cx, cy, deg float64) Gradient

func NewLinearGradient

func NewLinearGradient(x0, y0, x1, y1 float64) Gradient

func NewRadialGradient

func NewRadialGradient(x0, y0, r0, x1, y1, r1 float64) Gradient

type Guide

type Guide struct {
	Type        GuideType
	Position    float64
	Orientation GuideOrientation
	Visible     bool
	Color       color.Color
}

Guide represents a guide line

type GuideManager

type GuideManager struct {
	Guides          []*Guide
	GridSize        float64
	GridVisible     bool
	GridColor       color.Color
	SnapToGrid      bool
	SnapToGuides    bool
	SnapDistance    float64
	ShowCenterLines bool
	ShowBaselines   bool
	Margins         Margins
}

GuideManager manages guides and alignment

func NewGuideManager

func NewGuideManager() *GuideManager

NewGuideManager creates a new guide manager

func (*GuideManager) AddGuide

func (gm *GuideManager) AddGuide(position float64, orientation GuideOrientation) *Guide

AddGuide adds a manual guide

func (*GuideManager) ClearGuides

func (gm *GuideManager) ClearGuides()

ClearGuides removes all manual guides

func (*GuideManager) GenerateCenterGuides

func (gm *GuideManager) GenerateCenterGuides(width, height float64)

GenerateCenterGuides generates center guides for the canvas

func (*GuideManager) GenerateMarginGuides

func (gm *GuideManager) GenerateMarginGuides(width, height float64)

GenerateMarginGuides generates margin guides

func (*GuideManager) GetNearestGuides

func (gm *GuideManager) GetNearestGuides(x, y float64, maxDistance float64) []*Guide

GetNearestGuides returns guides near a point

func (*GuideManager) RemoveGuide

func (gm *GuideManager) RemoveGuide(guide *Guide) bool

RemoveGuide removes a guide

func (*GuideManager) SnapPoint

func (gm *GuideManager) SnapPoint(x, y float64) (float64, float64)

SnapPoint snaps a point to guides or grid

func (*GuideManager) SnapRectangle

func (gm *GuideManager) SnapRectangle(x, y, width, height float64) (float64, float64, float64, float64)

SnapRectangle snaps a rectangle to guides or grid

type GuideOrientation

type GuideOrientation int

GuideOrientation represents guide orientation

const (
	GuideHorizontal GuideOrientation = iota
	GuideVertical
)

type GuideType

type GuideType int

GuideType represents the type of guide

const (
	GuideTypeManual GuideType = iota
	GuideTypeGrid
	GuideTypeCenter
	GuideTypeBaseline
	GuideTypeMargin
)

type HSL

type HSL struct {
	H, S, L float64 // Hue (0-360), Saturation (0-1), Lightness (0-1)
}

HSL represents a color in HSL color space

func (HSL) ToRGB

func (hsl HSL) ToRGB() Color

HSL to RGB conversion

type HSV

type HSV struct {
	H, S, V float64 // Hue (0-360), Saturation (0-1), Value (0-1)
}

HSV represents a color in HSV color space

func (HSV) ToRGB

func (hsv HSV) ToRGB() Color

HSV to RGB conversion

type HitTestCircle

type HitTestCircle struct {
	X, Y, Radius float64
	ID           string
}

HitTestCircle represents a hit testable circle

func CreateHitTestCircle

func CreateHitTestCircle(id string, x, y, radius float64) *HitTestCircle

CreateHitTestCircle creates a hit testable circle

func (*HitTestCircle) GetBounds

func (c *HitTestCircle) GetBounds() (float64, float64, float64, float64)

GetBounds returns the bounding box

func (*HitTestCircle) HitTest

func (c *HitTestCircle) HitTest(x, y float64) bool

HitTest tests if point is inside circle

type HitTestEllipse

type HitTestEllipse struct {
	X, Y, RadiusX, RadiusY float64
	ID                     string
}

HitTestEllipse represents a hit testable ellipse

func CreateHitTestEllipse

func CreateHitTestEllipse(id string, x, y, radiusX, radiusY float64) *HitTestEllipse

CreateHitTestEllipse creates a hit testable ellipse

func (*HitTestEllipse) GetBounds

func (e *HitTestEllipse) GetBounds() (float64, float64, float64, float64)

GetBounds returns the bounding box

func (*HitTestEllipse) HitTest

func (e *HitTestEllipse) HitTest(x, y float64) bool

HitTest tests if point is inside ellipse

type HitTestLine

type HitTestLine struct {
	X1, Y1, X2, Y2 float64
	Thickness      float64
	ID             string
}

HitTestLine represents a hit testable line with thickness

func CreateHitTestLine

func CreateHitTestLine(id string, x1, y1, x2, y2, thickness float64) *HitTestLine

CreateHitTestLine creates a hit testable line

func (*HitTestLine) GetBounds

func (l *HitTestLine) GetBounds() (float64, float64, float64, float64)

GetBounds returns the bounding box

func (*HitTestLine) HitTest

func (l *HitTestLine) HitTest(x, y float64) bool

HitTest tests if point is near the line within thickness

type HitTestManager

type HitTestManager struct {
	// contains filtered or unexported fields
}

HitTestManager manages hit testing for multiple objects

func NewHitTestManager

func NewHitTestManager() *HitTestManager

NewHitTestManager creates a new hit test manager

func (*HitTestManager) AddObject

func (htm *HitTestManager) AddObject(obj HitTestable)

AddObject adds an object for hit testing

func (*HitTestManager) HitTest

func (htm *HitTestManager) HitTest(x, y float64) []HitTestable

HitTest performs hit testing at the given point

func (*HitTestManager) HitTestFirst

func (htm *HitTestManager) HitTestFirst(x, y float64) HitTestable

HitTestFirst returns the first object hit at the given point

func (*HitTestManager) HitTestLast

func (htm *HitTestManager) HitTestLast(x, y float64) HitTestable

HitTestLast returns the last (topmost) object hit at the given point

func (*HitTestManager) RemoveObject

func (htm *HitTestManager) RemoveObject(obj HitTestable)

RemoveObject removes an object from hit testing

type HitTestPath

type HitTestPath struct {
	Points []Point
	Closed bool
	ID     string
}

HitTestPath represents a hit testable path

func CreateHitTestPath

func CreateHitTestPath(id string, points []Point, closed bool) *HitTestPath

CreateHitTestPath creates a hit testable path

func (*HitTestPath) GetBounds

func (p *HitTestPath) GetBounds() (float64, float64, float64, float64)

GetBounds returns the bounding box

func (*HitTestPath) HitTest

func (p *HitTestPath) HitTest(x, y float64) bool

HitTest tests if point is inside path (if closed) or near path (if open)

type HitTestPolygon

type HitTestPolygon struct {
	Points []Point
	ID     string
}

HitTestPolygon represents a hit testable polygon

func CreateHitTestPolygon

func CreateHitTestPolygon(id string, points []Point) *HitTestPolygon

CreateHitTestPolygon creates a hit testable polygon

func (*HitTestPolygon) GetBounds

func (p *HitTestPolygon) GetBounds() (float64, float64, float64, float64)

GetBounds returns the bounding box

func (*HitTestPolygon) HitTest

func (p *HitTestPolygon) HitTest(x, y float64) bool

HitTest tests if point is inside polygon using ray casting algorithm

type HitTestRect

type HitTestRect struct {
	X, Y, Width, Height float64
	ID                  string
}

HitTestRect represents a hit testable rectangle

func CreateHitTestRect

func CreateHitTestRect(id string, x, y, width, height float64) *HitTestRect

CreateHitTestRect creates a hit testable rectangle

func (*HitTestRect) GetBounds

func (r *HitTestRect) GetBounds() (float64, float64, float64, float64)

GetBounds returns the bounding box

func (*HitTestRect) HitTest

func (r *HitTestRect) HitTest(x, y float64) bool

HitTest tests if point is inside rectangle

type HitTestable

type HitTestable interface {
	HitTest(x, y float64) bool
	GetBounds() (float64, float64, float64, float64)
}

HitTestable interface for objects that can be hit tested

type ICCHeader

type ICCHeader struct {
	ProfileSize        uint32
	PreferredCMM       [4]byte
	ProfileVersion     uint32
	DeviceClass        DeviceClass
	DataColorSpace     ColorSpace
	PCS                ColorSpace
	CreationDateTime   [12]byte
	PlatformSignature  [4]byte
	ProfileFlags       uint32
	DeviceManufacturer [4]byte
	DeviceModel        [4]byte
	DeviceAttributes   uint64
	RenderingIntent    RenderingIntent
	PCSIlluminant      XYZColor
	ProfileCreator     [4]byte
	Reserved           [44]byte
}

ICCHeader represents the ICC profile header

type ICCProfile

type ICCProfile struct {
	Header        ICCHeader
	TagTable      []ICCTag
	Data          []byte
	ColorSpace    ColorSpace
	PCS           ColorSpace // Profile Connection Space
	Intent        RenderingIntent
	WhitePoint    XYZColor
	BlackPoint    XYZColor
	RedColorant   XYZColor
	GreenColorant XYZColor
	BlueColorant  XYZColor
	Curves        []ToneCurve
}

ICCProfile represents an ICC color profile

func CreateAdobeRGBProfile

func CreateAdobeRGBProfile() *ICCProfile

CreateAdobeRGBProfile creates an Adobe RGB ICC profile

func CreateSRGBProfile

func CreateSRGBProfile() *ICCProfile

CreateSRGBProfile creates a standard sRGB ICC profile

func LoadICCProfile

func LoadICCProfile(data []byte) (*ICCProfile, error)

LoadICCProfile loads an ICC profile from data

func NewICCProfile

func NewICCProfile() *ICCProfile

NewICCProfile creates a new ICC profile

type ICCTag

type ICCTag struct {
	Signature [4]byte
	Offset    uint32
	Size      uint32
}

ICCTag represents an ICC tag

type ImageCache

type ImageCache struct {
	*Cache
}

ImageCache caches rendered images

func NewImageCache

func NewImageCache(maxSize int64, maxItems int) *ImageCache

NewImageCache creates a new image cache

func (*ImageCache) GetImage

func (ic *ImageCache) GetImage(key string) (*image.RGBA, bool)

GetImage retrieves a cached image

func (*ImageCache) SetImage

func (ic *ImageCache) SetImage(key string, img *image.RGBA)

SetImage stores an image in the cache

type ImageData

type ImageData struct {
	Data   []uint8 // RGBA data: [R, G, B, A, R, G, B, A, ...]
	Width  int
	Height int
}

ImageData represents pixel data that can be manipulated directly

func NewImageData

func NewImageData(width, height int) *ImageData

NewImageData creates a new ImageData with the specified dimensions

func NewImageDataFromImage

func NewImageDataFromImage(img image.Image) *ImageData

NewImageDataFromImage creates ImageData from an existing image

func (*ImageData) ApplyKernel

func (id *ImageData) ApplyKernel(kernel [][]float64) *ImageData

ApplyKernel applies a convolution kernel to the ImageData

func (*ImageData) Clone

func (id *ImageData) Clone() *ImageData

Clone creates a copy of the ImageData

func (*ImageData) CopyFrom

func (id *ImageData) CopyFrom(src *ImageData, srcX, srcY, srcWidth, srcHeight, dstX, dstY int)

CopyFrom copies pixel data from another ImageData

func (*ImageData) Fill

func (id *ImageData) Fill(r, g, b, a uint8)

Fill fills the entire ImageData with the specified color

func (*ImageData) FillRect

func (id *ImageData) FillRect(x, y, width, height int, r, g, b, a uint8)

FillRect fills a rectangular region with the specified color

func (*ImageData) FlipHorizontal

func (id *ImageData) FlipHorizontal() *ImageData

FlipHorizontal flips the ImageData horizontally

func (*ImageData) FlipVertical

func (id *ImageData) FlipVertical() *ImageData

FlipVertical flips the ImageData vertically

func (*ImageData) GetPixel

func (id *ImageData) GetPixel(x, y int) (r, g, b, a uint8)

GetPixel returns the RGBA values at the specified coordinates

func (*ImageData) GetPixelColor

func (id *ImageData) GetPixelColor(x, y int) color.RGBA

GetPixelColor returns the color at the specified coordinates

func (*ImageData) GetSubImageData

func (id *ImageData) GetSubImageData(x, y, width, height int) *ImageData

GetSubImageData extracts a rectangular region as new ImageData

func (*ImageData) Resize

func (id *ImageData) Resize(newWidth, newHeight int) *ImageData

Resize creates a new ImageData with different dimensions using nearest neighbor

func (*ImageData) Rotate90

func (id *ImageData) Rotate90() *ImageData

Rotate90 rotates the ImageData 90 degrees clockwise

func (*ImageData) SetPixel

func (id *ImageData) SetPixel(x, y int, r, g, b, a uint8)

SetPixel sets the RGBA values at the specified coordinates

func (*ImageData) SetPixelColor

func (id *ImageData) SetPixelColor(x, y int, c color.Color)

SetPixelColor sets the color at the specified coordinates

func (*ImageData) ToImage

func (id *ImageData) ToImage() *image.RGBA

ToImage converts ImageData to a standard Go image

type ImagePool

type ImagePool struct {
	// contains filtered or unexported fields
}

ImagePool manages a pool of RGBA images to reduce allocations

func NewImagePool

func NewImagePool() *ImagePool

NewImagePool creates a new image pool

func (*ImagePool) Get

func (p *ImagePool) Get(width, height int) *image.RGBA

Get retrieves an image from the pool or creates a new one

func (*ImagePool) Put

func (p *ImagePool) Put(img *image.RGBA)

Put returns an image to the pool

type LAB

type LAB struct {
	L, A, B float64 // Lightness, A (green-red), B (blue-yellow)
}

LAB represents a color in LAB color space

func (LAB) ToRGB

func (lab LAB) ToRGB() Color

LAB to RGB conversion

func (LAB) ToXYZ

func (lab LAB) ToXYZ() XYZ

LAB to XYZ conversion

type Layer

type Layer struct {
	Name      string
	Image     *image.RGBA
	Opacity   float64
	BlendMode BlendMode
	Visible   bool
	Locked    bool
	Mask      *image.Alpha
	Transform Matrix
	ID        string
}

Layer represents a single drawing layer

func NewLayer

func NewLayer(name string, width, height int) *Layer

NewLayer creates a new layer

func (*Layer) AddMask

func (l *Layer) AddMask()

AddMask adds a layer mask

func (*Layer) Clear

func (l *Layer) Clear()

Clear clears the layer

func (*Layer) Fill

func (l *Layer) Fill(c color.Color)

Fill fills the layer with a color

func (*Layer) RemoveMask

func (l *Layer) RemoveMask()

RemoveMask removes the layer mask

func (*Layer) SetBlendMode

func (l *Layer) SetBlendMode(mode BlendMode)

SetBlendMode sets the layer blend mode

func (*Layer) SetLocked

func (l *Layer) SetLocked(locked bool)

SetLocked sets layer lock state

func (*Layer) SetOpacity

func (l *Layer) SetOpacity(opacity float64)

SetOpacity sets the layer opacity

func (*Layer) SetVisible

func (l *Layer) SetVisible(visible bool)

SetVisible sets layer visibility

type LayerManager

type LayerManager struct {
	Layers      []*Layer
	ActiveLayer int
	Width       int
	Height      int
	Background  color.Color
}

LayerManager manages multiple layers

func NewLayerManager

func NewLayerManager(width, height int) *LayerManager

NewLayerManager creates a new layer manager

func (*LayerManager) AddLayer

func (lm *LayerManager) AddLayer(name string) *Layer

AddLayer adds a new layer

func (*LayerManager) Composite

func (lm *LayerManager) Composite() *image.RGBA

Composite renders all layers into a single image

func (*LayerManager) DuplicateLayer

func (lm *LayerManager) DuplicateLayer(index int) *Layer

DuplicateLayer duplicates a layer

func (*LayerManager) GetActiveLayer

func (lm *LayerManager) GetActiveLayer() *Layer

GetActiveLayer returns the currently active layer

func (*LayerManager) InsertLayer

func (lm *LayerManager) InsertLayer(index int, name string) *Layer

InsertLayer inserts a layer at the specified index

func (*LayerManager) MoveLayer

func (lm *LayerManager) MoveLayer(from, to int) bool

MoveLayer moves a layer from one index to another

func (*LayerManager) RemoveLayer

func (lm *LayerManager) RemoveLayer(index int) bool

RemoveLayer removes a layer by index

func (*LayerManager) SetActiveLayer

func (lm *LayerManager) SetActiveLayer(index int) bool

SetActiveLayer sets the active layer by index

func (*LayerManager) SetActiveLayerByName

func (lm *LayerManager) SetActiveLayerByName(name string) bool

SetActiveLayerByName sets the active layer by name

type LineCap

type LineCap int
const (
	LineCapRound LineCap = iota
	LineCapButt
	LineCapSquare
)

type LineJoin

type LineJoin int
const (
	LineJoinRound LineJoin = iota
	LineJoinBevel
)

type LineShape

type LineShape struct {
	X1, Y1, X2, Y2 float64
}

LineShape represents a line

func (*LineShape) Clone

func (l *LineShape) Clone() Shape

func (*LineShape) Draw

func (l *LineShape) Draw(ctx *Context)

LineShape methods

func (*LineShape) GetBounds

func (l *LineShape) GetBounds() (float64, float64, float64, float64)

type Margins

type Margins struct {
	Top, Right, Bottom, Left float64
}

Margins represents canvas margins

type Matrix

type Matrix struct {
	XX, YX, XY, YY, X0, Y0 float64
}

func Identity

func Identity() Matrix

func Rotate

func Rotate(angle float64) Matrix

func SIMDMatrixMultiply

func SIMDMatrixMultiply(a, b Matrix) Matrix

SIMDMatrixMultiply performs optimized matrix multiplication

func Scale

func Scale(x, y float64) Matrix

func Shear

func Shear(x, y float64) Matrix

func Translate

func Translate(x, y float64) Matrix

func (Matrix) Multiply

func (a Matrix) Multiply(b Matrix) Matrix

func (Matrix) Rotate

func (a Matrix) Rotate(angle float64) Matrix

func (Matrix) Scale

func (a Matrix) Scale(x, y float64) Matrix

func (Matrix) Shear

func (a Matrix) Shear(x, y float64) Matrix

func (Matrix) TransformPoint

func (a Matrix) TransformPoint(x, y float64) (tx, ty float64)

func (Matrix) TransformVector

func (a Matrix) TransformVector(x, y float64) (tx, ty float64)

func (Matrix) Translate

func (a Matrix) Translate(x, y float64) Matrix

type MemoryStats

type MemoryStats struct {
	ImagePoolSize     int
	ByteSlicePoolSize int
	ContextPoolSize   int
	PathPoolSize      int
}

MemoryStats provides memory usage statistics

func GetMemoryStats

func GetMemoryStats() MemoryStats

GetMemoryStats returns current memory pool statistics

type OptimizedContext

type OptimizedContext struct {
	*Context
	// contains filtered or unexported fields
}

OptimizedContext provides an optimized rendering context

func NewOptimizedContext

func NewOptimizedContext(width, height int) *OptimizedContext

NewOptimizedContext creates a new optimized context

func (*OptimizedContext) AddDirtyRegion

func (oc *OptimizedContext) AddDirtyRegion(bounds Bounds)

AddDirtyRegion marks a region as needing redraw

func (*OptimizedContext) ClearDirtyRegions

func (oc *OptimizedContext) ClearDirtyRegions()

ClearDirtyRegions clears all dirty regions

func (*OptimizedContext) DrawOptimizedRectangle

func (oc *OptimizedContext) DrawOptimizedRectangle(id string, x, y, width, height float64, fillColor color.Color)

DrawOptimizedRectangle draws a rectangle with caching

func (*OptimizedContext) GetDirtyRegions

func (oc *OptimizedContext) GetDirtyRegions() []Bounds

GetDirtyRegions returns the current dirty regions

func (*OptimizedContext) GetPerformanceMonitor

func (oc *OptimizedContext) GetPerformanceMonitor() *PerformanceMonitor

GetPerformanceMonitor returns the performance monitor

func (*OptimizedContext) GetRenderCache

func (oc *OptimizedContext) GetRenderCache() *RenderCache

GetRenderCache returns the render cache

func (*OptimizedContext) GetSpatialIndex

func (oc *OptimizedContext) GetSpatialIndex() *SpatialIndex

GetSpatialIndex returns the spatial index

func (*OptimizedContext) IsVisible

func (oc *OptimizedContext) IsVisible(bounds Bounds) bool

Frustum culling for efficient rendering

type ParallelRenderer

type ParallelRenderer struct {
	// contains filtered or unexported fields
}

ParallelRenderer provides parallel rendering capabilities

func NewParallelRenderer

func NewParallelRenderer(workers int) *ParallelRenderer

NewParallelRenderer creates a new parallel renderer

func (*ParallelRenderer) GetResult

func (pr *ParallelRenderer) GetResult() RenderResult

GetResult gets a rendering result

func (*ParallelRenderer) Start

func (pr *ParallelRenderer) Start()

Start starts the parallel renderer workers

func (*ParallelRenderer) Stop

func (pr *ParallelRenderer) Stop()

Stop stops the parallel renderer

func (*ParallelRenderer) Submit

func (pr *ParallelRenderer) Submit(job RenderJob)

Submit submits a rendering job

type Path2D

type Path2D struct {
	// contains filtered or unexported fields
}

Path2D represents a 2D path that can be reused and manipulated

func NewPath2D

func NewPath2D() *Path2D

NewPath2D creates a new empty Path2D

func NewPath2DFromPath

func NewPath2DFromPath(other *Path2D) *Path2D

NewPath2DFromPath creates a new Path2D from an existing Path2D

func PooledPath2D

func PooledPath2D() *Path2D

PooledPath2D creates a new Path2D using pooled resources

func (*Path2D) AddPath

func (p *Path2D) AddPath(other *Path2D)

AddPath adds another path to this path

func (*Path2D) Arc

func (p *Path2D) Arc(x, y, radius, startAngle, endAngle float64, counterclockwise bool)

Arc adds an arc to the path

func (*Path2D) ArcTo

func (p *Path2D) ArcTo(x1, y1, x2, y2, radius float64)

ArcTo adds an arc with the given control points and radius

func (*Path2D) BezierCurveTo

func (p *Path2D) BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y float64)

BezierCurveTo draws a cubic Bézier curve

func (*Path2D) ClosePath

func (p *Path2D) ClosePath()

ClosePath closes the current path by drawing a line to the start point

func (*Path2D) Ellipse

func (p *Path2D) Ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle float64, counterclockwise bool)

Ellipse adds an ellipse to the path

func (*Path2D) GetCurrentPoint

func (p *Path2D) GetCurrentPoint() (x, y float64)

GetCurrentPoint returns the current point of the path

func (*Path2D) GetPath

func (p *Path2D) GetPath() raster.Path

GetPath returns the internal raster.Path for use with Context

func (*Path2D) IsEmpty

func (p *Path2D) IsEmpty() bool

IsEmpty returns true if the path has no operations

func (*Path2D) LineTo

func (p *Path2D) LineTo(x, y float64)

LineTo draws a line from the current point to the specified coordinates

func (*Path2D) MoveTo

func (p *Path2D) MoveTo(x, y float64)

MoveTo moves the current point to the specified coordinates

func (*Path2D) QuadraticCurveTo

func (p *Path2D) QuadraticCurveTo(cpx, cpy, x, y float64)

QuadraticCurveTo draws a quadratic Bézier curve

func (*Path2D) Rect

func (p *Path2D) Rect(x, y, width, height float64)

Rect adds a rectangle to the path

type PathCache

type PathCache struct {
	*Cache
}

PathCache caches rendered paths

func NewPathCache

func NewPathCache(maxSize int64, maxItems int) *PathCache

NewPathCache creates a new path cache

type PathPool

type PathPool struct {
	// contains filtered or unexported fields
}

PathPool manages a pool of Path2D objects

func NewPathPool

func NewPathPool() *PathPool

NewPathPool creates a new path pool

func (*PathPool) Get

func (p *PathPool) Get() *Path2D

Get retrieves a path from the pool

func (*PathPool) Put

func (p *PathPool) Put(path *Path2D)

Put returns a path to the pool

type PathShape

type PathShape struct {
	Points []Point
}

PathShape represents a complex path (simplified)

func (*PathShape) Clone

func (p *PathShape) Clone() Shape

func (*PathShape) Draw

func (p *PathShape) Draw(ctx *Context)

PathShape methods

func (*PathShape) GetBounds

func (p *PathShape) GetBounds() (float64, float64, float64, float64)

type Pattern

type Pattern interface {
	ColorAt(x, y int) color.Color
}

func NewSolidPattern

func NewSolidPattern(color color.Color) Pattern

func NewSurfacePattern

func NewSurfacePattern(im image.Image, op RepeatOp) Pattern

type PerformanceMonitor

type PerformanceMonitor struct {
	// contains filtered or unexported fields
}

PerformanceMonitor tracks rendering performance

func NewPerformanceMonitor

func NewPerformanceMonitor() *PerformanceMonitor

NewPerformanceMonitor creates a new performance monitor

func (*PerformanceMonitor) GetFPS

func (pm *PerformanceMonitor) GetFPS() float64

GetFPS returns the current FPS

func (*PerformanceMonitor) GetFrameCount

func (pm *PerformanceMonitor) GetFrameCount() int

GetFrameCount returns the total frame count

func (*PerformanceMonitor) Reset

func (pm *PerformanceMonitor) Reset()

Reset resets the performance monitor

func (*PerformanceMonitor) StartFrame

func (pm *PerformanceMonitor) StartFrame()

StartFrame marks the start of a frame

type Point

type Point struct {
	X, Y float64
}

func AnimatePoint

func AnimatePoint(start, end Point, t float64, easing EasingFunc) Point

AnimatePoint animates between two points

func CubicBezier

func CubicBezier(x0, y0, x1, y1, x2, y2, x3, y3 float64) []Point

func QuadraticBezier

func QuadraticBezier(x0, y0, x1, y1, x2, y2 float64) []Point

func (Point) Distance

func (a Point) Distance(b Point) float64

func (Point) Fixed

func (a Point) Fixed() fixed.Point26_6

func (Point) Interpolate

func (a Point) Interpolate(b Point, t float64) Point

type PoolConfig

type PoolConfig struct {
	MaxImagePoolSize     int
	MaxByteSlicePoolSize int
	EnablePooling        bool
}

PoolConfig holds configuration for memory pools

func DefaultPoolConfig

func DefaultPoolConfig() PoolConfig

DefaultPoolConfig returns the default pool configuration

type RectShape

type RectShape struct {
	X, Y, Width, Height float64
}

RectShape represents a rectangle

func (*RectShape) Clone

func (r *RectShape) Clone() Shape

func (*RectShape) Draw

func (r *RectShape) Draw(ctx *Context)

RectShape methods

func (*RectShape) GetBounds

func (r *RectShape) GetBounds() (float64, float64, float64, float64)

type Rectangle

type Rectangle struct {
	X, Y, Width, Height float64
}

Rectangle represents a bounding rectangle

type RenderCache

type RenderCache struct {
	// contains filtered or unexported fields
}

RenderCache provides caching for rendered elements

func NewRenderCache

func NewRenderCache(maxSize int) *RenderCache

NewRenderCache creates a new render cache

func (*RenderCache) Clear

func (rc *RenderCache) Clear()

Clear clears the cache

func (*RenderCache) Get

func (rc *RenderCache) Get(key string) (*image.RGBA, bool)

Get retrieves a cached image

func (*RenderCache) Set

func (rc *RenderCache) Set(key string, img *image.RGBA)

Set stores an image in the cache

type RenderJob

type RenderJob struct {
	ID     string
	Bounds Bounds
	Render func() *image.RGBA
}

RenderJob represents a rendering job

type RenderResult

type RenderResult struct {
	ID    string
	Image *image.RGBA
	Error error
}

RenderResult represents a rendering result

type RenderingIntent

type RenderingIntent uint32

RenderingIntent represents ICC rendering intent

const (
	IntentPerceptual           RenderingIntent = 0
	IntentRelativeColorimetric RenderingIntent = 1
	IntentSaturation           RenderingIntent = 2
	IntentAbsoluteColorimetric RenderingIntent = 3
)

type RepeatOp

type RepeatOp int
const (
	RepeatBoth RepeatOp = iota
	RepeatX
	RepeatY
	RepeatNone
)

type ResizeAlgorithm

type ResizeAlgorithm int

ResizeAlgorithm specifies the interpolation algorithm to use when resizing images.

const (
	// ResizeNearestNeighbor uses nearest-neighbor sampling (fastest, lower quality)
	ResizeNearestNeighbor ResizeAlgorithm = iota
	// ResizeBilinear uses bilinear interpolation (good balance of quality/speed)
	ResizeBilinear
	// ResizeBicubic uses bicubic interpolation (higher quality, slower)
	ResizeBicubic
	// ResizeLanczos uses Lanczos resampling (highest quality, slowest)
	ResizeLanczos
)

type SIMDConfig

type SIMDConfig struct {
	Enabled    bool
	UseAVX2    bool
	UseSSE4    bool
	NumWorkers int
}

SIMDConfig holds SIMD optimization settings

func DefaultSIMDConfig

func DefaultSIMDConfig() SIMDConfig

DefaultSIMDConfig returns the default SIMD configuration

type ScriptType

type ScriptType int

ScriptType represents different script types

const (
	ScriptLatin ScriptType = iota
	ScriptArabic
	ScriptHebrew
	ScriptDevanagari
	ScriptThai
	ScriptChinese
	ScriptJapanese
	ScriptKorean
	ScriptCyrillic
	ScriptGreek
)

type Shape

type Shape interface {
	Draw(ctx *Context)
	GetBounds() (float64, float64, float64, float64)
	Clone() Shape
}

Shape interface for different drawable shapes

type ShapedGlyph

type ShapedGlyph struct {
	GlyphID   uint32
	X, Y      float64
	AdvanceX  float64
	AdvanceY  float64
	Cluster   int
	Character rune
}

ShapedGlyph represents a positioned glyph

type ShapedText

type ShapedText struct {
	Glyphs    []ShapedGlyph
	Direction TextDirection
	Width     float64
	Height    float64
}

ShapedText represents shaped text with positioning

type SpatialIndex

type SpatialIndex struct {
	// contains filtered or unexported fields
}

SpatialIndex provides spatial indexing for fast object lookup

func NewSpatialIndex

func NewSpatialIndex(bounds Bounds, maxDepth, maxItems int) *SpatialIndex

NewSpatialIndex creates a new spatial index

func (*SpatialIndex) Insert

func (si *SpatialIndex) Insert(obj SpatialObject)

Insert adds an object to the spatial index

func (*SpatialIndex) Query

func (si *SpatialIndex) Query(bounds Bounds) []SpatialObject

Query returns objects that intersect with the given bounds

type SpatialObject

type SpatialObject interface {
	GetBounds() (float64, float64, float64, float64)
	GetID() string
}

SpatialObject represents an object that can be spatially indexed

type StrokeGradient

type StrokeGradient struct {
	Type    StrokeGradientType
	Colors  []StrokeGradientStop
	StartX  float64
	StartY  float64
	EndX    float64
	EndY    float64
	CenterX float64 // For radial gradients
	CenterY float64
	Radius  float64
}

StrokeGradient represents gradient stroke coloring

type StrokeGradientStop

type StrokeGradientStop struct {
	Position float64 // 0.0 to 1.0
	Color    color.Color
}

StrokeGradientStop represents a color stop in a gradient

type StrokeGradientType

type StrokeGradientType int

StrokeGradientType represents gradient types

const (
	StrokeGradientLinear StrokeGradientType = iota
	StrokeGradientRadial
	StrokeGradientConic
)

type StrokeLineCap

type StrokeLineCap int

StrokeLineCap represents line cap styles

const (
	StrokeLineCapButt   StrokeLineCap = iota // Square end
	StrokeLineCapRound                       // Rounded end
	StrokeLineCapSquare                      // Extended square end
)

type StrokeLineJoin

type StrokeLineJoin int

StrokeLineJoin represents line join styles

const (
	StrokeLineJoinMiter StrokeLineJoin = iota // Sharp corner
	StrokeLineJoinRound                       // Rounded corner
	StrokeLineJoinBevel                       // Beveled corner
)

type StrokeStyle

type StrokeStyle struct {
	Width       float64
	Color       color.Color
	DashPattern []float64
	DashOffset  float64
	LineCap     StrokeLineCap
	LineJoin    StrokeLineJoin
	MiterLimit  float64
	Gradient    *StrokeGradient
	Taper       *StrokeTaper
}

StrokeStyle represents advanced stroke styling options

func CreateDashedStroke

func CreateDashedStroke(width float64, color color.Color, pattern []float64) *StrokeStyle

CreateDashedStroke creates a dashed stroke style

func CreateGradientStroke

func CreateGradientStroke(width float64, startX, startY, endX, endY float64, stops []StrokeGradientStop) *StrokeStyle

CreateGradientStroke creates a gradient stroke style

func CreateTaperedStroke

func CreateTaperedStroke(width float64, color color.Color, startWidth, endWidth float64) *StrokeStyle

CreateTaperedStroke creates a tapered stroke style

func NewStrokeStyle

func NewStrokeStyle() *StrokeStyle

NewStrokeStyle creates a new stroke style with defaults

func (*StrokeStyle) SetDashPattern

func (ss *StrokeStyle) SetDashPattern(pattern []float64, offset float64)

SetDashPattern sets a dash pattern for the stroke

func (*StrokeStyle) SetLinearGradient

func (ss *StrokeStyle) SetLinearGradient(startX, startY, endX, endY float64, stops []StrokeGradientStop)

SetLinearGradient sets a linear gradient for the stroke

func (*StrokeStyle) SetRadialGradient

func (ss *StrokeStyle) SetRadialGradient(centerX, centerY, radius float64, stops []StrokeGradientStop)

SetRadialGradient sets a radial gradient for the stroke

func (*StrokeStyle) SetTaper

func (ss *StrokeStyle) SetTaper(startWidth, endWidth float64, taperType StrokeTaperType)

SetTaper sets stroke tapering

type StrokeTaper

type StrokeTaper struct {
	StartWidth float64 // Width at start (0.0 to 1.0 multiplier)
	EndWidth   float64 // Width at end (0.0 to 1.0 multiplier)
	Type       StrokeTaperType
}

StrokeTaper represents tapered stroke ends

type StrokeTaperType

type StrokeTaperType int

StrokeTaperType represents taper styles

const (
	StrokeTaperLinear      StrokeTaperType = iota // Linear taper
	StrokeTaperExponential                        // Exponential taper
	StrokeTaperSinusoidal                         // Smooth sinusoidal taper
)

type Style

type Style struct {
	Fill        color.Color
	Stroke      color.Color
	StrokeWidth float64
	Opacity     float64
	Transform   Matrix
	Visible     bool
}

Style represents CSS-like styling

type TextDirection

type TextDirection int

TextDirection represents text direction

const (
	TextDirectionLTR TextDirection = iota // Left-to-Right
	TextDirectionRTL                      // Right-to-Left
	TextDirectionTTB                      // Top-to-Bottom
	TextDirectionBTT                      // Bottom-to-Top
)

type TextMetrics

type TextMetrics struct {
	Width                    float64 // Total width of the text
	Height                   float64 // Total height of the text
	ActualBoundingBoxLeft    float64 // Distance from text baseline to left edge of bounding box
	ActualBoundingBoxRight   float64 // Distance from text baseline to right edge of bounding box
	ActualBoundingBoxAscent  float64 // Distance from text baseline to top of bounding box
	ActualBoundingBoxDescent float64 // Distance from text baseline to bottom of bounding box
	FontBoundingBoxAscent    float64 // Distance from baseline to top of font bounding box
	FontBoundingBoxDescent   float64 // Distance from baseline to bottom of font bounding box
	EmHeightAscent           float64 // Distance from baseline to top of em square
	EmHeightDescent          float64 // Distance from baseline to bottom of em square
	HangingBaseline          float64 // Distance from alphabetic baseline to hanging baseline
	AlphabeticBaseline       float64 // Distance from alphabetic baseline to alphabetic baseline (0)
	IdeographicBaseline      float64 // Distance from alphabetic baseline to ideographic baseline
}

TextMetrics represents detailed text measurement information

type TextShape

type TextShape struct {
	X, Y float64
	Text string
}

TextShape represents text

func (*TextShape) Clone

func (t *TextShape) Clone() Shape

func (*TextShape) Draw

func (t *TextShape) Draw(ctx *Context)

TextShape methods

func (*TextShape) GetBounds

func (t *TextShape) GetBounds() (float64, float64, float64, float64)

type TextShaper

type TextShaper struct {
	Direction       TextDirection
	Script          ScriptType
	Language        string
	EnableLigatures bool
	EnableKerning   bool
	// contains filtered or unexported fields
}

TextShaper handles complex text shaping using HarfBuzz

func NewTextShaper

func NewTextShaper() *TextShaper

NewTextShaper creates a new text shaper

func (*TextShaper) SetFont

func (ts *TextShaper) SetFont(fontFace fonts.Face) error

SetFont sets the font for shaping

func (*TextShaper) ShapeText

func (ts *TextShaper) ShapeText(text string) *ShapedText

ShapeText shapes text according to Unicode rules using proper BiDi and HarfBuzz

type ToneCurve

type ToneCurve struct {
	Type   uint32
	Points []float64
}

ToneCurve represents a tone reproduction curve

type XYZ

type XYZ struct {
	X, Y, Z float64
}

XYZ represents a color in XYZ color space (intermediate for LAB conversion)

func (XYZ) ToLAB

func (xyz XYZ) ToLAB() LAB

XYZ to LAB conversion

func (XYZ) ToRGB

func (xyz XYZ) ToRGB() Color

XYZ to RGB conversion

type XYZColor

type XYZColor struct {
	X, Y, Z float64
}

XYZColor represents a color in CIE XYZ color space

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL