Documentation
¶
Overview ¶
Package render provides Ebiten-based rendering capabilities for conky-go. This file implements the Cairo compatibility layer that translates Cairo drawing commands to Ebiten vector graphics.
Package render provides Ebiten-based rendering capabilities for conky-go. This file implements color management and transparency handling utilities for parsing, converting, and manipulating colors in various formats.
Package render provides Ebiten-based rendering capabilities for conky-go.
Package render provides Ebiten-based rendering capabilities for conky-go. It implements the core rendering engine using Ebiten v2 for cross-platform 2D graphics with support for text rendering and widget display.
Package render provides Ebiten-based rendering capabilities for conky-go. This file implements graph widget types including line graphs, bar graphs, and histograms for visualizing time-series and categorical data.
Package render provides Ebiten-based rendering capabilities for conky-go. This file implements image loading and bitmap drawing capabilities for displaying PNG, JPEG, and GIF images in the rendering engine.
Package render provides Ebiten-based rendering capabilities for conky-go. This file implements performance optimization utilities including frame rate monitoring, object pooling, and dirty region tracking for 60fps rendering.
Package render provides Ebiten-based rendering capabilities for conky-go.
Package render provides Ebiten-based rendering capabilities for conky-go. This file implements progress bar and gauge widgets for visualizing percentage-based data like CPU usage, memory, battery level, etc.
Index ¶
- Variables
- func AdjustHue(c color.RGBA, degrees float64) color.RGBA
- func AlphaBlend(bg, fg color.RGBA) color.RGBA
- func Blend(c1, c2 color.RGBA, ratio float64) color.RGBA
- func ContrastRatio(c1, c2 color.RGBA) float64
- func Darken(c color.RGBA, amount float64) color.RGBA
- func DefaultErrorHandler(err error)
- func Desaturate(c color.RGBA, amount float64) color.RGBA
- func Grayscale(c color.RGBA) color.RGBA
- func HSLToRGBA(hsl HSL, alpha uint8) color.RGBA
- func Invert(c color.RGBA) color.RGBA
- func IsDark(c color.RGBA) bool
- func IsLight(c color.RGBA) bool
- func Lighten(c color.RGBA, amount float64) color.RGBA
- func Luminance(c color.RGBA) float64
- func MustParseColor(s string) color.RGBA
- func ParseColor(s string) (color.RGBA, error)
- func Saturate(c color.RGBA, amount float64) color.RGBA
- func ToHex(c color.RGBA) string
- func ToRGBA(c color.RGBA) string
- func WithAlpha(c color.RGBA, alpha uint8) color.RGBA
- func WithOpacity(c color.RGBA, opacity float64) color.RGBA
- type BarGraph
- func (bg *BarGraph) ClearData()
- func (bg *BarGraph) Draw(screen *ebiten.Image)
- func (bg *BarGraph) SetAutoScale(enabled bool)
- func (bg *BarGraph) SetBarSpacing(spacing float64)
- func (bg *BarGraph) SetData(data []float64)
- func (bg *BarGraph) SetHorizontal(horizontal bool)
- func (bg *BarGraph) SetLabels(labels []string)
- func (bg *BarGraph) SetPosition(x, y float64)
- func (bg *BarGraph) SetRange(minVal, maxVal float64)
- func (bg *BarGraph) SetSize(width, height float64)
- func (bg *BarGraph) SetStyle(style GraphStyle)
- type CairoRenderer
- func (cr *CairoRenderer) Arc(xc, yc, radius, angle1, angle2 float64)
- func (cr *CairoRenderer) ArcNegative(xc, yc, radius, angle1, angle2 float64)
- func (cr *CairoRenderer) ClosePath()
- func (cr *CairoRenderer) CurveTo(x1, y1, x2, y2, x3, y3 float64)
- func (cr *CairoRenderer) DrawCircle(xc, yc, radius float64)
- func (cr *CairoRenderer) DrawLine(x1, y1, x2, y2 float64)
- func (cr *CairoRenderer) DrawRectangle(x, y, width, height float64)
- func (cr *CairoRenderer) Fill()
- func (cr *CairoRenderer) FillCircle(xc, yc, radius float64)
- func (cr *CairoRenderer) FillPreserve()
- func (cr *CairoRenderer) FillRectangle(x, y, width, height float64)
- func (cr *CairoRenderer) GetAntialias() bool
- func (cr *CairoRenderer) GetCurrentColor() color.RGBA
- func (cr *CairoRenderer) GetCurrentPoint() (x, y float64, hasPoint bool)
- func (cr *CairoRenderer) GetLineCap() LineCap
- func (cr *CairoRenderer) GetLineJoin() LineJoin
- func (cr *CairoRenderer) GetLineWidth() float64
- func (cr *CairoRenderer) LineTo(x, y float64)
- func (cr *CairoRenderer) MoveTo(x, y float64)
- func (cr *CairoRenderer) NewPath()
- func (cr *CairoRenderer) Paint()
- func (cr *CairoRenderer) PaintWithAlpha(alpha float64)
- func (cr *CairoRenderer) Rectangle(x, y, width, height float64)
- func (cr *CairoRenderer) Screen() *ebiten.Image
- func (cr *CairoRenderer) SetAntialias(enabled bool)
- func (cr *CairoRenderer) SetLineCap(capStyle LineCap)
- func (cr *CairoRenderer) SetLineJoin(join LineJoin)
- func (cr *CairoRenderer) SetLineWidth(width float64)
- func (cr *CairoRenderer) SetScreen(screen *ebiten.Image)
- func (cr *CairoRenderer) SetSourceRGB(r, g, b float64)
- func (cr *CairoRenderer) SetSourceRGBA(r, g, b, a float64)
- func (cr *CairoRenderer) Stroke()
- func (cr *CairoRenderer) StrokePreserve()
- type Config
- type DataProvider
- type DirtyRegion
- type DirtyTracker
- func (dt *DirtyTracker) Clear()
- func (dt *DirtyTracker) DirtyRegions() []DirtyRegion
- func (dt *DirtyTracker) IsEmpty() bool
- func (dt *DirtyTracker) MarkDirty(region DirtyRegion)
- func (dt *DirtyTracker) MarkFullRedraw()
- func (dt *DirtyTracker) NeedsFullRedraw() bool
- func (dt *DirtyTracker) RegionCount() int
- func (dt *DirtyTracker) SetScreenSize(width, height int)
- type DrawOptionsPool
- type ErrorHandler
- type FontFamily
- func (ff *FontFamily) AddFont(style FontStyle, source *etext.GoTextFaceSource)
- func (ff *FontFamily) AvailableStyles() []FontStyle
- func (ff *FontFamily) GetFont(style FontStyle) *etext.GoTextFaceSource
- func (ff *FontFamily) GetFontWithFallback(style FontStyle) *etext.GoTextFaceSource
- func (ff *FontFamily) HasStyle(style FontStyle) bool
- func (ff *FontFamily) Name() string
- type FontManager
- func (fm *FontManager) DefaultFamily() string
- func (fm *FontManager) FallbackChain() []string
- func (fm *FontManager) GetFamily(name string) *FontFamily
- func (fm *FontManager) GetFont(familyName string, style FontStyle) *etext.GoTextFaceSource
- func (fm *FontManager) GetFontWithFallback(familyName string, style FontStyle) *etext.GoTextFaceSource
- func (fm *FontManager) ListFamilies() []string
- func (fm *FontManager) LoadFontFromData(familyName string, style FontStyle, data []byte) error
- func (fm *FontManager) LoadFontFromFile(familyName string, style FontStyle, filePath string) error
- func (fm *FontManager) RegisterAlias(alias, familyName string) error
- func (fm *FontManager) SetDefaultFamily(familyName string)
- func (fm *FontManager) SetFallbackChain(families []string)
- type FontStyle
- type FrameMetrics
- func (fm *FrameMetrics) AverageFrameTime() time.Duration
- func (fm *FrameMetrics) FPS() float64
- func (fm *FrameMetrics) LastFrameTime() time.Duration
- func (fm *FrameMetrics) MaxFrameTime() time.Duration
- func (fm *FrameMetrics) MinFrameTime() time.Duration
- func (fm *FrameMetrics) RecordFrame(frameTime time.Duration)
- func (fm *FrameMetrics) Reset()
- func (fm *FrameMetrics) TotalFrames() int64
- type Game
- func (g *Game) AddLine(line TextLine)
- func (g *Game) ClearLines()
- func (g *Game) Config() Config
- func (g *Game) Draw(screen *ebiten.Image)
- func (g *Game) IsRunning() bool
- func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int)
- func (g *Game) Run() error
- func (g *Game) SetDataProvider(dp DataProvider)
- func (g *Game) SetErrorHandler(handler ErrorHandler)
- func (g *Game) SetLines(lines []TextLine)
- func (g *Game) Update() error
- type Gauge
- func (g *Gauge) Draw(screen *ebiten.Image)
- func (g *Gauge) Percentage() float64
- func (g *Gauge) SetAngles(startAngle, endAngle float64)
- func (g *Gauge) SetClockwise(clockwise bool)
- func (g *Gauge) SetPosition(x, y float64)
- func (g *Gauge) SetRadius(radius float64)
- func (g *Gauge) SetRange(minVal, maxVal float64)
- func (g *Gauge) SetStyle(style WidgetStyle)
- func (g *Gauge) SetThickness(thickness float64)
- func (g *Gauge) SetValue(value float64)
- func (g *Gauge) Value() float64
- type Gradient
- type GradientStop
- type GraphStyle
- type GraphWidget
- type HSL
- type Histogram
- func (h *Histogram) AddValue(value float64)
- func (h *Histogram) ClearData()
- func (h *Histogram) Draw(screen *ebiten.Image)
- func (h *Histogram) SetAutoRange(enabled bool)
- func (h *Histogram) SetBinCount(n int)
- func (h *Histogram) SetData(data []float64)
- func (h *Histogram) SetPosition(x, y float64)
- func (h *Histogram) SetRange(minVal, maxVal float64)
- func (h *Histogram) SetSize(width, height float64)
- func (h *Histogram) SetStyle(style GraphStyle)
- type ImageCache
- type ImageLoader
- type ImageWidget
- func (iw *ImageWidget) CenterOrigin() bool
- func (iw *ImageWidget) Clear()
- func (iw *ImageWidget) Draw(screen *ebiten.Image)
- func (iw *ImageWidget) IsLoaded() bool
- func (iw *ImageWidget) LoadFromFile(path string) error
- func (iw *ImageWidget) LoadFromImage(img *ebiten.Image)
- func (iw *ImageWidget) LoadFromReader(r io.Reader) error
- func (iw *ImageWidget) Opacity() float64
- func (iw *ImageWidget) OriginalSize() (width, height int)
- func (iw *ImageWidget) Position() (x, y float64)
- func (iw *ImageWidget) Rotation() float64
- func (iw *ImageWidget) Scale() (scaleX, scaleY float64)
- func (iw *ImageWidget) SetCenterOrigin(centered bool)
- func (iw *ImageWidget) SetOpacity(opacity float64)
- func (iw *ImageWidget) SetPosition(x, y float64)
- func (iw *ImageWidget) SetRotation(radians float64)
- func (iw *ImageWidget) SetScale(scaleX, scaleY float64)
- func (iw *ImageWidget) SetSize(width, height float64)
- func (iw *ImageWidget) SetUniformScale(scale float64)
- func (iw *ImageWidget) Size() (width, height float64)
- type IndexPool
- type LineCap
- type LineGraph
- func (lg *LineGraph) AddPoint(value float64)
- func (lg *LineGraph) ClearData()
- func (lg *LineGraph) Draw(screen *ebiten.Image)
- func (lg *LineGraph) SetAutoScale(enabled bool)
- func (lg *LineGraph) SetData(data []float64)
- func (lg *LineGraph) SetMaxPoints(n int)
- func (lg *LineGraph) SetPosition(x, y float64)
- func (lg *LineGraph) SetRange(minVal, maxVal float64)
- func (lg *LineGraph) SetSize(width, height float64)
- func (lg *LineGraph) SetStyle(style GraphStyle)
- type LineJoin
- type PerformanceConfig
- type PerformanceManager
- func (pm *PerformanceManager) Config() PerformanceConfig
- func (pm *PerformanceManager) DirtyTracker() *DirtyTracker
- func (pm *PerformanceManager) GetDrawOptions() *ebiten.DrawImageOptions
- func (pm *PerformanceManager) GetIndices() []uint16
- func (pm *PerformanceManager) GetVertices() []ebiten.Vertex
- func (pm *PerformanceManager) Metrics() *FrameMetrics
- func (pm *PerformanceManager) PutDrawOptions(op *ebiten.DrawImageOptions)
- func (pm *PerformanceManager) PutIndices(indices []uint16)
- func (pm *PerformanceManager) PutVertices(vertices []ebiten.Vertex)
- func (pm *PerformanceManager) RecordFrame(frameTime time.Duration)
- func (pm *PerformanceManager) ResetStats()
- func (pm *PerformanceManager) SetScreenSize(width, height int)
- func (pm *PerformanceManager) Stats() *RenderStats
- type ProgressBar
- func (pb *ProgressBar) Draw(screen *ebiten.Image)
- func (pb *ProgressBar) Percentage() float64
- func (pb *ProgressBar) SetPosition(x, y float64)
- func (pb *ProgressBar) SetRange(minVal, maxVal float64)
- func (pb *ProgressBar) SetReversed(reversed bool)
- func (pb *ProgressBar) SetSize(width, height float64)
- func (pb *ProgressBar) SetStyle(style WidgetStyle)
- func (pb *ProgressBar) SetValue(value float64)
- func (pb *ProgressBar) SetVertical(vertical bool)
- func (pb *ProgressBar) Value() float64
- type RenderStats
- type TextLine
- type TextRenderer
- func (tr *TextRenderer) DrawText(screen *ebiten.Image, textStr string, x, y float64, clr color.RGBA)
- func (tr *TextRenderer) DrawTextWithStyle(screen *ebiten.Image, textStr string, x, y float64, clr color.RGBA, ...)
- func (tr *TextRenderer) FontFamily() string
- func (tr *TextRenderer) FontManager() *FontManager
- func (tr *TextRenderer) FontSize() float64
- func (tr *TextRenderer) FontStyle() FontStyle
- func (tr *TextRenderer) LineHeight() float64
- func (tr *TextRenderer) LoadFontFromFile(familyName string, style FontStyle, filePath string) error
- func (tr *TextRenderer) MeasureText(textStr string) (width, height float64)
- func (tr *TextRenderer) SetFont(family string, style FontStyle)
- func (tr *TextRenderer) SetFontFamily(family string)
- func (tr *TextRenderer) SetFontSize(size float64)
- func (tr *TextRenderer) SetFontStyle(style FontStyle)
- type TextRendererInterface
- type VertexPool
- type Widget
- type WidgetStyle
Constants ¶
This section is empty.
Variables ¶
var NamedColors = map[string]color.RGBA{
"black": {R: 0, G: 0, B: 0, A: 255},
"white": {R: 255, G: 255, B: 255, A: 255},
"red": {R: 255, G: 0, B: 0, A: 255},
"green": {R: 0, G: 128, B: 0, A: 255},
"blue": {R: 0, G: 0, B: 255, A: 255},
"yellow": {R: 255, G: 255, B: 0, A: 255},
"cyan": {R: 0, G: 255, B: 255, A: 255},
"magenta": {R: 255, G: 0, B: 255, A: 255},
"gray": {R: 128, G: 128, B: 128, A: 255},
"grey": {R: 128, G: 128, B: 128, A: 255},
"silver": {R: 192, G: 192, B: 192, A: 255},
"maroon": {R: 128, G: 0, B: 0, A: 255},
"olive": {R: 128, G: 128, B: 0, A: 255},
"lime": {R: 0, G: 255, B: 0, A: 255},
"aqua": {R: 0, G: 255, B: 255, A: 255},
"teal": {R: 0, G: 128, B: 128, A: 255},
"navy": {R: 0, G: 0, B: 128, A: 255},
"fuchsia": {R: 255, G: 0, B: 255, A: 255},
"purple": {R: 128, G: 0, B: 128, A: 255},
"orange": {R: 255, G: 165, B: 0, A: 255},
"pink": {R: 255, G: 192, B: 203, A: 255},
"brown": {R: 165, G: 42, B: 42, A: 255},
"coral": {R: 255, G: 127, B: 80, A: 255},
"gold": {R: 255, G: 215, B: 0, A: 255},
"indigo": {R: 75, G: 0, B: 130, A: 255},
"violet": {R: 238, G: 130, B: 238, A: 255},
"turquoise": {R: 64, G: 224, B: 208, A: 255},
"salmon": {R: 250, G: 128, B: 114, A: 255},
"khaki": {R: 240, G: 230, B: 140, A: 255},
"lavender": {R: 230, G: 230, B: 250, A: 255},
"beige": {R: 245, G: 245, B: 220, A: 255},
"ivory": {R: 255, G: 255, B: 240, A: 255},
"chocolate": {R: 210, G: 105, B: 30, A: 255},
"crimson": {R: 220, G: 20, B: 60, A: 255},
"darkblue": {R: 0, G: 0, B: 139, A: 255},
"darkgreen": {R: 0, G: 100, B: 0, A: 255},
"darkred": {R: 139, G: 0, B: 0, A: 255},
"darkorange": {R: 255, G: 140, B: 0, A: 255},
"lightblue": {R: 173, G: 216, B: 230, A: 255},
"lightgreen": {R: 144, G: 238, B: 144, A: 255},
"lightgray": {R: 211, G: 211, B: 211, A: 255},
"lightgrey": {R: 211, G: 211, B: 211, A: 255},
"darkgray": {R: 169, G: 169, B: 169, A: 255},
"darkgrey": {R: 169, G: 169, B: 169, A: 255},
"transparent": {R: 0, G: 0, B: 0, A: 0},
}
NamedColors maps CSS color names to their RGBA values. This provides compatibility with Conky configurations that use named colors.
Functions ¶
func AlphaBlend ¶
AlphaBlend composites a foreground color over a background color using standard alpha blending (Porter-Duff "over" operator).
func Blend ¶
Blend blends two colors together with the specified ratio (0.0-1.0). A ratio of 0.0 returns c1, 1.0 returns c2, 0.5 returns an even mix.
func ContrastRatio ¶
ContrastRatio calculates the contrast ratio between two colors. Returns a value between 1.0 (no contrast) and 21.0 (maximum contrast). WCAG recommends at least 4.5:1 for normal text and 3:1 for large text.
func Darken ¶
Darken returns a darker version of the color. Amount is a value from 0.0-1.0, where 0.0 returns the original color and 1.0 returns black.
func DefaultErrorHandler ¶
func DefaultErrorHandler(err error)
DefaultErrorHandler writes errors to stderr.
func Desaturate ¶
Desaturate decreases the saturation of a color. Amount is a value from 0.0-1.0 representing how much to decrease.
func Lighten ¶
Lighten returns a lighter version of the color. Amount is a value from 0.0-1.0, where 0.0 returns the original color and 1.0 returns white.
func Luminance ¶
Luminance returns the relative luminance of a color (0.0-1.0). This is useful for determining if a color is "light" or "dark".
func MustParseColor ¶
MustParseColor parses a color string and panics if parsing fails. Use this only for known-good color values in initialization code.
func ParseColor ¶
ParseColor parses a color string and returns an RGBA color. Supported formats:
- Named colors: "red", "blue", "green", etc.
- Hex formats: "#RGB", "#RGBA", "#RRGGBB", "#RRGGBBAA"
- Hex without #: "RGB", "RGBA", "RRGGBB", "RRGGBBAA"
- RGB function: "rgb(255, 0, 0)"
- RGBA function: "rgba(255, 0, 0, 0.5)" or "rgba(255, 0, 0, 128)"
Returns an error if the color string cannot be parsed.
func Saturate ¶
Saturate increases the saturation of a color. Amount is a value from 0.0-1.0 representing how much to increase.
func ToHex ¶
ToHex converts a color to a hex string with # prefix. Format: #RRGGBB or #RRGGBBAA if alpha is not 255.
Types ¶
type BarGraph ¶
type BarGraph struct {
// contains filtered or unexported fields
}
BarGraph displays data as vertical or horizontal bars. It is suitable for showing categorical data or comparisons.
func NewBarGraph ¶
NewBarGraph creates a new bar graph with the specified dimensions.
func (*BarGraph) ClearData ¶
func (bg *BarGraph) ClearData()
ClearData removes all data from the graph.
func (*BarGraph) SetAutoScale ¶
SetAutoScale enables or disables automatic value axis scaling.
func (*BarGraph) SetBarSpacing ¶
SetBarSpacing sets the spacing between bars in pixels.
func (*BarGraph) SetHorizontal ¶
SetHorizontal sets whether bars should be drawn horizontally.
func (*BarGraph) SetPosition ¶
SetPosition sets the top-left position of the graph.
func (*BarGraph) SetRange ¶
SetRange sets the minimum and maximum values for the value axis. This disables auto-scaling. If maxVal <= minVal, the values are swapped to ensure a valid range.
func (*BarGraph) SetStyle ¶
func (bg *BarGraph) SetStyle(style GraphStyle)
SetStyle sets the visual style of the graph.
type CairoRenderer ¶
type CairoRenderer struct {
// contains filtered or unexported fields
}
CairoRenderer implements a Cairo-compatible drawing API using Ebiten. It maintains drawing state similar to Cairo's context and translates Cairo drawing commands to Ebiten vector operations.
func NewCairoRenderer ¶
func NewCairoRenderer() *CairoRenderer
NewCairoRenderer creates a new CairoRenderer instance. The renderer is initialized with default state: black color, line width 1.0.
func (*CairoRenderer) Arc ¶
func (cr *CairoRenderer) Arc(xc, yc, radius, angle1, angle2 float64)
Arc adds a circular arc to the current path. xc, yc: center coordinates radius: arc radius angle1, angle2: start and end angles in radians This is equivalent to cairo_arc.
func (*CairoRenderer) ArcNegative ¶
func (cr *CairoRenderer) ArcNegative(xc, yc, radius, angle1, angle2 float64)
ArcNegative adds a circular arc in the negative direction. This is equivalent to cairo_arc_negative.
func (*CairoRenderer) ClosePath ¶
func (cr *CairoRenderer) ClosePath()
ClosePath closes the current sub-path by drawing a line back to the start. This is equivalent to cairo_close_path.
func (*CairoRenderer) CurveTo ¶
func (cr *CairoRenderer) CurveTo(x1, y1, x2, y2, x3, y3 float64)
CurveTo adds a cubic Bézier curve to the path. This is equivalent to cairo_curve_to. If there is no current point, it starts from (0,0) as per Cairo convention.
func (*CairoRenderer) DrawCircle ¶
func (cr *CairoRenderer) DrawCircle(xc, yc, radius float64)
DrawCircle draws a stroked circle. This is a convenience function that combines Arc and Stroke. Note: This function is NOT atomic - each internal method call acquires and releases the mutex independently. For atomic operations, use explicit locking at the caller level.
func (*CairoRenderer) DrawLine ¶
func (cr *CairoRenderer) DrawLine(x1, y1, x2, y2 float64)
DrawLine draws a line from (x1,y1) to (x2,y2) with the current color and line width. This is a convenience function that combines MoveTo, LineTo, and Stroke. DrawLine draws a line from (x1,y1) to (x2,y2) with the current color and line width. This is a convenience function that combines MoveTo, LineTo, and Stroke. Note: This function is NOT atomic - each internal method call acquires and releases the mutex independently. For atomic operations, use explicit locking at the caller level.
func (*CairoRenderer) DrawRectangle ¶
func (cr *CairoRenderer) DrawRectangle(x, y, width, height float64)
DrawRectangle draws a stroked rectangle. This is a convenience function that combines Rectangle and Stroke. Note: This function is NOT atomic - each internal method call acquires and releases the mutex independently. For atomic operations, use explicit locking at the caller level.
func (*CairoRenderer) Fill ¶
func (cr *CairoRenderer) Fill()
Fill fills the current path with the current color. This is equivalent to cairo_fill.
func (*CairoRenderer) FillCircle ¶
func (cr *CairoRenderer) FillCircle(xc, yc, radius float64)
FillCircle draws a filled circle. This is a convenience function that combines Arc and Fill. Note: This function is NOT atomic - each internal method call acquires and releases the mutex independently. For atomic operations, use explicit locking at the caller level.
func (*CairoRenderer) FillPreserve ¶
func (cr *CairoRenderer) FillPreserve()
FillPreserve fills the current path without clearing it. This is equivalent to cairo_fill_preserve.
func (*CairoRenderer) FillRectangle ¶
func (cr *CairoRenderer) FillRectangle(x, y, width, height float64)
FillRectangle draws a filled rectangle. This is a convenience function that combines Rectangle and Fill. Note: This function is NOT atomic - each internal method call acquires and releases the mutex independently. For atomic operations, use explicit locking at the caller level.
func (*CairoRenderer) GetAntialias ¶
func (cr *CairoRenderer) GetAntialias() bool
GetAntialias returns whether antialiasing is enabled.
func (*CairoRenderer) GetCurrentColor ¶
func (cr *CairoRenderer) GetCurrentColor() color.RGBA
GetCurrentColor returns the current drawing color.
func (*CairoRenderer) GetCurrentPoint ¶
func (cr *CairoRenderer) GetCurrentPoint() (x, y float64, hasPoint bool)
GetCurrentPoint returns the current point in the path.
func (*CairoRenderer) GetLineCap ¶
func (cr *CairoRenderer) GetLineCap() LineCap
GetLineCap returns the current line cap style.
func (*CairoRenderer) GetLineJoin ¶
func (cr *CairoRenderer) GetLineJoin() LineJoin
GetLineJoin returns the current line join style.
func (*CairoRenderer) GetLineWidth ¶
func (cr *CairoRenderer) GetLineWidth() float64
GetLineWidth returns the current line width.
func (*CairoRenderer) LineTo ¶
func (cr *CairoRenderer) LineTo(x, y float64)
LineTo adds a line from the current point to the given point. This is equivalent to cairo_line_to.
func (*CairoRenderer) MoveTo ¶
func (cr *CairoRenderer) MoveTo(x, y float64)
MoveTo begins a new sub-path at the given point. This is equivalent to cairo_move_to.
func (*CairoRenderer) NewPath ¶
func (cr *CairoRenderer) NewPath()
NewPath clears the current path and starts a new one. This is equivalent to cairo_new_path.
func (*CairoRenderer) Paint ¶
func (cr *CairoRenderer) Paint()
Paint fills the entire surface with the current color. This is equivalent to cairo_paint.
func (*CairoRenderer) PaintWithAlpha ¶
func (cr *CairoRenderer) PaintWithAlpha(alpha float64)
PaintWithAlpha fills the entire surface with the current color at the given alpha. This is equivalent to cairo_paint_with_alpha.
func (*CairoRenderer) Rectangle ¶
func (cr *CairoRenderer) Rectangle(x, y, width, height float64)
Rectangle adds a closed rectangular sub-path. This is equivalent to cairo_rectangle.
func (*CairoRenderer) Screen ¶
func (cr *CairoRenderer) Screen() *ebiten.Image
Screen returns the current target image.
func (*CairoRenderer) SetAntialias ¶
func (cr *CairoRenderer) SetAntialias(enabled bool)
SetAntialias enables or disables antialiasing. This is equivalent to cairo_set_antialias.
func (*CairoRenderer) SetLineCap ¶
func (cr *CairoRenderer) SetLineCap(capStyle LineCap)
SetLineCap sets the line cap style. This is equivalent to cairo_set_line_cap.
func (*CairoRenderer) SetLineJoin ¶
func (cr *CairoRenderer) SetLineJoin(join LineJoin)
SetLineJoin sets the line join style. This is equivalent to cairo_set_line_join.
func (*CairoRenderer) SetLineWidth ¶
func (cr *CairoRenderer) SetLineWidth(width float64)
SetLineWidth sets the line width for stroke operations. This is equivalent to cairo_set_line_width.
func (*CairoRenderer) SetScreen ¶
func (cr *CairoRenderer) SetScreen(screen *ebiten.Image)
SetScreen sets the target image for drawing operations. This must be called before any drawing functions.
func (*CairoRenderer) SetSourceRGB ¶
func (cr *CairoRenderer) SetSourceRGB(r, g, b float64)
SetSourceRGB sets the current drawing color using RGB values (0.0-1.0). This is equivalent to cairo_set_source_rgb.
func (*CairoRenderer) SetSourceRGBA ¶
func (cr *CairoRenderer) SetSourceRGBA(r, g, b, a float64)
SetSourceRGBA sets the current drawing color using RGBA values (0.0-1.0). This is equivalent to cairo_set_source_rgba.
func (*CairoRenderer) Stroke ¶
func (cr *CairoRenderer) Stroke()
Stroke draws the current path as a stroked line. This is equivalent to cairo_stroke.
func (*CairoRenderer) StrokePreserve ¶
func (cr *CairoRenderer) StrokePreserve()
StrokePreserve strokes the current path without clearing it. This is equivalent to cairo_stroke_preserve.
type Config ¶
type Config struct {
// Width is the window width in pixels.
Width int
// Height is the window height in pixels.
Height int
// Title is the window title.
Title string
// UpdateInterval is the time between system data updates.
UpdateInterval time.Duration
// BackgroundColor is the window background color.
BackgroundColor color.RGBA
}
Config holds the rendering configuration options.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible default values.
type DataProvider ¶
type DataProvider interface {
// Update refreshes the system data.
Update() error
}
DataProvider is an interface for providing system data to the renderer.
type DirtyRegion ¶
DirtyRegion represents a rectangular area that needs redrawing.
func (DirtyRegion) Contains ¶
func (r DirtyRegion) Contains(x, y float64) bool
Contains returns true if the region contains the given point.
func (DirtyRegion) Intersects ¶
func (r DirtyRegion) Intersects(other DirtyRegion) bool
Intersects returns true if this region overlaps with another.
func (DirtyRegion) Union ¶
func (r DirtyRegion) Union(other DirtyRegion) DirtyRegion
Union returns a region that encompasses both regions.
type DirtyTracker ¶
type DirtyTracker struct {
// contains filtered or unexported fields
}
DirtyTracker tracks regions of the screen that need redrawing. This enables partial screen updates for improved performance when only portions of the display change between frames.
func NewDirtyTracker ¶
func NewDirtyTracker(screenWidth, screenHeight int) *DirtyTracker
NewDirtyTracker creates a new DirtyTracker for the given screen dimensions.
func (*DirtyTracker) Clear ¶
func (dt *DirtyTracker) Clear()
Clear resets the dirty tracker for the next frame.
func (*DirtyTracker) DirtyRegions ¶
func (dt *DirtyTracker) DirtyRegions() []DirtyRegion
DirtyRegions returns a copy of the current dirty regions.
func (*DirtyTracker) IsEmpty ¶
func (dt *DirtyTracker) IsEmpty() bool
IsEmpty returns true if no regions are marked dirty.
func (*DirtyTracker) MarkDirty ¶
func (dt *DirtyTracker) MarkDirty(region DirtyRegion)
MarkDirty marks a region as needing redraw.
func (*DirtyTracker) MarkFullRedraw ¶
func (dt *DirtyTracker) MarkFullRedraw()
MarkFullRedraw marks the entire screen as needing redraw.
func (*DirtyTracker) NeedsFullRedraw ¶
func (dt *DirtyTracker) NeedsFullRedraw() bool
NeedsFullRedraw returns true if the entire screen needs redrawing.
func (*DirtyTracker) RegionCount ¶
func (dt *DirtyTracker) RegionCount() int
RegionCount returns the number of dirty regions.
func (*DirtyTracker) SetScreenSize ¶
func (dt *DirtyTracker) SetScreenSize(width, height int)
SetScreenSize updates the screen dimensions.
type DrawOptionsPool ¶
type DrawOptionsPool struct {
// contains filtered or unexported fields
}
DrawOptionsPool provides pooling for ebiten.DrawImageOptions to reduce allocations. This is particularly useful in high-frequency draw operations.
func NewDrawOptionsPool ¶
func NewDrawOptionsPool() *DrawOptionsPool
NewDrawOptionsPool creates a new DrawOptionsPool.
func (*DrawOptionsPool) Get ¶
func (p *DrawOptionsPool) Get() *ebiten.DrawImageOptions
Get retrieves a DrawImageOptions from the pool. The returned options are reset to default values.
func (*DrawOptionsPool) Put ¶
func (p *DrawOptionsPool) Put(op *ebiten.DrawImageOptions)
Put returns a DrawImageOptions to the pool.
type ErrorHandler ¶
type ErrorHandler func(err error)
ErrorHandler is a function type for handling errors during game updates.
type FontFamily ¶
type FontFamily struct {
// contains filtered or unexported fields
}
FontFamily represents a font family with multiple style variations.
func NewFontFamily ¶
func NewFontFamily(name string) *FontFamily
NewFontFamily creates a new FontFamily with the given name.
func (*FontFamily) AddFont ¶
func (ff *FontFamily) AddFont(style FontStyle, source *etext.GoTextFaceSource)
AddFont adds a font source to the family for a specific style.
func (*FontFamily) AvailableStyles ¶
func (ff *FontFamily) AvailableStyles() []FontStyle
AvailableStyles returns a sorted list of available font styles. The result is sorted for consistent ordering across calls.
func (*FontFamily) GetFont ¶
func (ff *FontFamily) GetFont(style FontStyle) *etext.GoTextFaceSource
GetFont returns the font source for a specific style, or nil if not found.
func (*FontFamily) GetFontWithFallback ¶
func (ff *FontFamily) GetFontWithFallback(style FontStyle) *etext.GoTextFaceSource
GetFontWithFallback returns the font source for a style with fallback logic. If the requested style is not available, it falls back to regular style.
func (*FontFamily) HasStyle ¶
func (ff *FontFamily) HasStyle(style FontStyle) bool
HasStyle returns true if the family has a font for the given style.
type FontManager ¶
type FontManager struct {
// contains filtered or unexported fields
}
FontManager manages font loading, caching, and fallback chains.
func NewFontManager ¶
func NewFontManager() *FontManager
NewFontManager creates a new FontManager with embedded Go fonts.
func (*FontManager) DefaultFamily ¶
func (fm *FontManager) DefaultFamily() string
DefaultFamily returns the default font family name.
func (*FontManager) FallbackChain ¶
func (fm *FontManager) FallbackChain() []string
FallbackChain returns a copy of the current fallback chain.
func (*FontManager) GetFamily ¶
func (fm *FontManager) GetFamily(name string) *FontFamily
GetFamily returns a font family by name, or nil if not found.
func (*FontManager) GetFont ¶
func (fm *FontManager) GetFont(familyName string, style FontStyle) *etext.GoTextFaceSource
GetFont returns the font source for a family and style. Returns nil if the family doesn't exist or if the family has no fonts available (even after style fallback within the family).
func (*FontManager) GetFontWithFallback ¶
func (fm *FontManager) GetFontWithFallback(familyName string, style FontStyle) *etext.GoTextFaceSource
GetFontWithFallback returns a font source, falling back through the chain if needed.
func (*FontManager) ListFamilies ¶
func (fm *FontManager) ListFamilies() []string
ListFamilies returns a list of canonical font family names. Aliases are excluded; only the primary name of each family is returned. The result is sorted for consistent ordering.
func (*FontManager) LoadFontFromData ¶
func (fm *FontManager) LoadFontFromData(familyName string, style FontStyle, data []byte) error
LoadFontFromData loads a font from byte data and registers it.
func (*FontManager) LoadFontFromFile ¶
func (fm *FontManager) LoadFontFromFile(familyName string, style FontStyle, filePath string) error
LoadFontFromFile loads a font from a file path and registers it with the given family and style.
func (*FontManager) RegisterAlias ¶
func (fm *FontManager) RegisterAlias(alias, familyName string) error
RegisterAlias registers an alias name for an existing family.
func (*FontManager) SetDefaultFamily ¶
func (fm *FontManager) SetDefaultFamily(familyName string)
SetDefaultFamily sets the default font family name.
func (*FontManager) SetFallbackChain ¶
func (fm *FontManager) SetFallbackChain(families []string)
SetFallbackChain sets the font family fallback chain.
type FontStyle ¶
type FontStyle int
FontStyle represents font style variations.
func ParseFontStyle ¶
ParseFontStyle parses a string into a FontStyle.
type FrameMetrics ¶
type FrameMetrics struct {
// contains filtered or unexported fields
}
FrameMetrics tracks frame timing and performance statistics. It provides real-time FPS monitoring and frame time analysis for performance optimization and debugging.
func NewFrameMetrics ¶
func NewFrameMetrics(updatePeriod time.Duration) *FrameMetrics
NewFrameMetrics creates a new FrameMetrics instance. The updatePeriod determines how often FPS is recalculated (default: 1 second).
func (*FrameMetrics) AverageFrameTime ¶
func (fm *FrameMetrics) AverageFrameTime() time.Duration
AverageFrameTime returns the average frame time since creation or last reset.
func (*FrameMetrics) FPS ¶
func (fm *FrameMetrics) FPS() float64
FPS returns the current frames per second.
func (*FrameMetrics) LastFrameTime ¶
func (fm *FrameMetrics) LastFrameTime() time.Duration
LastFrameTime returns the duration of the last frame.
func (*FrameMetrics) MaxFrameTime ¶
func (fm *FrameMetrics) MaxFrameTime() time.Duration
MaxFrameTime returns the maximum frame time recorded.
func (*FrameMetrics) MinFrameTime ¶
func (fm *FrameMetrics) MinFrameTime() time.Duration
MinFrameTime returns the minimum frame time recorded.
func (*FrameMetrics) RecordFrame ¶
func (fm *FrameMetrics) RecordFrame(frameTime time.Duration)
RecordFrame records a new frame with its duration. This should be called once per frame in the Update or Draw loop.
func (*FrameMetrics) Reset ¶
func (fm *FrameMetrics) Reset()
Reset clears all metrics to their initial state. Note: Reset is not atomic with respect to RecordFrame or metric reads. If called concurrently with RecordFrame or metric accessors like AverageFrameTime, callers may observe inconsistent intermediate states. For consistent behavior, ensure Reset is called when no other goroutines are accessing the metrics.
func (*FrameMetrics) TotalFrames ¶
func (fm *FrameMetrics) TotalFrames() int64
TotalFrames returns the total number of frames recorded since creation or last reset.
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game implements ebiten.Game interface and handles rendering.
func NewGameWithRenderer ¶
func NewGameWithRenderer(config Config, renderer TextRendererInterface) *Game
NewGameWithRenderer creates a new Game instance with a custom text renderer. This is useful for testing.
func (*Game) Draw ¶
Draw implements ebiten.Game.Draw. It is called every frame to render the screen.
func (*Game) Layout ¶
Layout implements ebiten.Game.Layout. It returns the game's logical screen size.
func (*Game) Run ¶
Run starts the Ebiten game loop. This function blocks until the window is closed.
func (*Game) SetDataProvider ¶
func (g *Game) SetDataProvider(dp DataProvider)
SetDataProvider sets the data provider for system monitoring updates.
func (*Game) SetErrorHandler ¶
func (g *Game) SetErrorHandler(handler ErrorHandler)
SetErrorHandler sets a custom error handler for update errors. If nil is passed, errors will be silently ignored.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge displays a circular or arc-shaped progress indicator. It shows a value as a filled arc, commonly used for speedometers, CPU meters, and similar radial displays.
func (*Gauge) Percentage ¶
Percentage returns the current value as a percentage (0-100).
func (*Gauge) SetAngles ¶
SetAngles sets the start and end angles for the gauge arc in radians. Angles are measured from the positive X axis (right), with positive values going clockwise. Common configurations: - Half circle (bottom): startAngle=π, endAngle=2π (or 0) - 270° arc: startAngle=0.75π, endAngle=2.25π
func (*Gauge) SetClockwise ¶
SetClockwise sets whether the gauge fills in clockwise direction.
func (*Gauge) SetPosition ¶
SetPosition sets the center position of the gauge.
func (*Gauge) SetRange ¶
SetRange sets the minimum and maximum values for the gauge. If maxVal <= minVal, the values are swapped to ensure a valid range.
func (*Gauge) SetStyle ¶
func (g *Gauge) SetStyle(style WidgetStyle)
SetStyle sets the visual style of the gauge.
func (*Gauge) SetThickness ¶
SetThickness sets the thickness of the gauge arc in pixels.
type Gradient ¶
type Gradient struct {
// contains filtered or unexported fields
}
Gradient represents a color gradient for smooth color transitions. Gradient is not thread-safe. If gradients are used across goroutines, callers must provide their own synchronization.
func NewGradient ¶
func NewGradient(stops ...GradientStop) *Gradient
NewGradient creates a new gradient with the specified color stops. Stops should be sorted by position, but will be auto-sorted if not.
func (*Gradient) AddStop ¶
AddStop adds a color stop to the gradient. Position is clamped to the [0, 1] range.
func (*Gradient) Stops ¶
func (g *Gradient) Stops() []GradientStop
Stops returns the gradient stops.
type GradientStop ¶
type GradientStop struct {
Position float64 // Position in range [0, 1]
Color color.RGBA // Color at this position
}
GradientStop represents a color at a specific position in a gradient.
type GraphStyle ¶
type GraphStyle struct {
// FillColor is the color used to fill graph elements.
FillColor color.RGBA
// StrokeColor is the color used for graph outlines and lines.
StrokeColor color.RGBA
// StrokeWidth is the width of lines in pixels.
StrokeWidth float32
// BackgroundColor is the background color of the graph area.
BackgroundColor color.RGBA
// ShowBackground indicates whether to draw the background.
ShowBackground bool
}
GraphStyle defines the visual appearance of graph widgets.
func DefaultGraphStyle ¶
func DefaultGraphStyle() GraphStyle
DefaultGraphStyle returns a GraphStyle with sensible defaults.
type GraphWidget ¶
type GraphWidget interface {
// Draw renders the graph onto the given screen.
Draw(screen *ebiten.Image)
// SetStyle sets the visual style of the graph.
SetStyle(style GraphStyle)
// SetPosition sets the top-left position of the graph.
SetPosition(x, y float64)
// SetSize sets the width and height of the graph.
SetSize(width, height float64)
}
GraphWidget is the interface that all graph widgets must implement.
type HSL ¶
type HSL struct {
H, S, L float64
}
HSL represents a color in Hue-Saturation-Lightness space. H is in range [0, 360), S and L are in range [0, 1].
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram displays the frequency distribution of data values. Values are grouped into bins and displayed as bars.
func NewHistogram ¶
NewHistogram creates a new histogram with the specified dimensions.
func (*Histogram) ClearData ¶
func (h *Histogram) ClearData()
ClearData removes all data from the histogram.
func (*Histogram) SetAutoRange ¶
SetAutoRange enables or disables automatic range detection.
func (*Histogram) SetBinCount ¶
SetBinCount sets the number of bins for the histogram.
func (*Histogram) SetPosition ¶
SetPosition sets the top-left position of the histogram.
func (*Histogram) SetRange ¶
SetRange sets the value range for binning. This disables auto-ranging. If maxVal <= minVal, the values are swapped to ensure a valid range.
func (*Histogram) SetStyle ¶
func (h *Histogram) SetStyle(style GraphStyle)
SetStyle sets the visual style of the histogram.
type ImageCache ¶
type ImageCache struct {
// contains filtered or unexported fields
}
ImageCache provides caching for loaded images to avoid reloading.
func (*ImageCache) Clear ¶
func (ic *ImageCache) Clear()
Clear removes all images from the cache and deallocates them.
func (*ImageCache) Get ¶
func (ic *ImageCache) Get(path string) *ebiten.Image
Get retrieves an image from the cache without loading. Returns nil if the image is not cached.
func (*ImageCache) Load ¶
func (ic *ImageCache) Load(path string) (*ebiten.Image, error)
Load loads an image from a file, using the cache if available. Uses double-checked locking to prevent race conditions and duplicate loads.
func (*ImageCache) Remove ¶
func (ic *ImageCache) Remove(path string)
Remove removes an image from the cache and deallocates it.
func (*ImageCache) Size ¶
func (ic *ImageCache) Size() int
Size returns the number of images in the cache.
type ImageLoader ¶
type ImageLoader struct{}
ImageLoader provides utilities for loading images without creating a widget. This is useful for caching and sharing images between multiple widgets.
func (*ImageLoader) LoadFile ¶
LoadFile loads an image from a file path. Returns the Ebiten image and its dimensions.
func (*ImageLoader) LoadReader ¶
LoadReader loads an image from an io.Reader. Returns the Ebiten image and its dimensions.
type ImageWidget ¶
type ImageWidget struct {
// contains filtered or unexported fields
}
ImageWidget displays an image loaded from a file or reader. It supports PNG, JPEG, and GIF formats and provides options for positioning, scaling, rotation, and opacity.
func NewImageWidget ¶
func NewImageWidget(x, y float64) *ImageWidget
NewImageWidget creates a new empty ImageWidget at the specified position. Use LoadFromFile or LoadFromReader to load an image.
func (*ImageWidget) CenterOrigin ¶
func (iw *ImageWidget) CenterOrigin() bool
CenterOrigin returns whether the position represents the center.
func (*ImageWidget) Clear ¶
func (iw *ImageWidget) Clear()
Clear removes the loaded image and resets dimensions.
func (*ImageWidget) Draw ¶
func (iw *ImageWidget) Draw(screen *ebiten.Image)
Draw renders the image onto the given screen. Does nothing if no image is loaded.
func (*ImageWidget) IsLoaded ¶
func (iw *ImageWidget) IsLoaded() bool
IsLoaded returns true if an image has been successfully loaded.
func (*ImageWidget) LoadFromFile ¶
func (iw *ImageWidget) LoadFromFile(path string) error
LoadFromFile loads an image from a file path. Supported formats: PNG, JPEG, GIF. Returns an error if the file cannot be read or decoded. If an image was previously loaded, it will be deallocated before loading the new one.
func (*ImageWidget) LoadFromImage ¶
func (iw *ImageWidget) LoadFromImage(img *ebiten.Image)
LoadFromImage loads an Ebiten image directly. This is useful when the image is already in memory. This method takes ownership of the provided image reference: the widget will keep a reference to img until another image is loaded (via any LoadFrom* method) or the widget is cleared, at which point the previous image will be deallocated. If the caller needs to retain independent ownership of the image, they should pass a separate copy instead of reusing the same *ebiten.Image.
func (*ImageWidget) LoadFromReader ¶
func (iw *ImageWidget) LoadFromReader(r io.Reader) error
LoadFromReader loads an image from an io.Reader. Supported formats: PNG, JPEG, GIF. Returns an error if the image cannot be decoded. If an image was previously loaded, it will be deallocated before loading the new one.
func (*ImageWidget) Opacity ¶
func (iw *ImageWidget) Opacity() float64
Opacity returns the current opacity value.
func (*ImageWidget) OriginalSize ¶
func (iw *ImageWidget) OriginalSize() (width, height int)
OriginalSize returns the original dimensions of the loaded image. Returns (0, 0) if no image is loaded.
func (*ImageWidget) Position ¶
func (iw *ImageWidget) Position() (x, y float64)
Position returns the current position of the image.
func (*ImageWidget) Rotation ¶
func (iw *ImageWidget) Rotation() float64
Rotation returns the current rotation angle in radians.
func (*ImageWidget) Scale ¶
func (iw *ImageWidget) Scale() (scaleX, scaleY float64)
Scale returns the current scale factors.
func (*ImageWidget) SetCenterOrigin ¶
func (iw *ImageWidget) SetCenterOrigin(centered bool)
SetCenterOrigin sets whether the position represents the center of the image. If true, the image is drawn centered at the position. If false (default), the position is the top-left corner.
func (*ImageWidget) SetOpacity ¶
func (iw *ImageWidget) SetOpacity(opacity float64)
SetOpacity sets the opacity of the image. Value should be between 0.0 (fully transparent) and 1.0 (fully opaque). Values outside this range are clamped.
func (*ImageWidget) SetPosition ¶
func (iw *ImageWidget) SetPosition(x, y float64)
SetPosition sets the position of the image. By default, this is the top-left corner. Use SetCenterOrigin(true) to make this the center of the image.
func (*ImageWidget) SetRotation ¶
func (iw *ImageWidget) SetRotation(radians float64)
SetRotation sets the rotation angle in radians. Positive values rotate clockwise.
func (*ImageWidget) SetScale ¶
func (iw *ImageWidget) SetScale(scaleX, scaleY float64)
SetScale sets the scale factors for the image. This overrides any size settings.
func (*ImageWidget) SetSize ¶
func (iw *ImageWidget) SetSize(width, height float64)
SetSize sets the display dimensions of the image. If width or height is 0, the original dimension is used. This overrides any scale settings.
func (*ImageWidget) SetUniformScale ¶
func (iw *ImageWidget) SetUniformScale(scale float64)
SetUniformScale sets both scale factors to the same value.
func (*ImageWidget) Size ¶
func (iw *ImageWidget) Size() (width, height float64)
Size returns the display dimensions of the image. Returns (0, 0) if no image is loaded.
type IndexPool ¶
type IndexPool struct {
// contains filtered or unexported fields
}
IndexPool provides pooling for index slices used in triangle drawing.
func (*IndexPool) Get ¶
Get retrieves an index slice from the pool. The returned slice has length 0 but may have capacity > 0.
type LineGraph ¶
type LineGraph struct {
// contains filtered or unexported fields
}
LineGraph displays data points connected by lines. It is suitable for showing trends over time.
func NewLineGraph ¶
NewLineGraph creates a new line graph with the specified dimensions.
func (*LineGraph) AddPoint ¶
AddPoint adds a new data point to the graph. Old points are removed when maxPoints is exceeded.
func (*LineGraph) ClearData ¶
func (lg *LineGraph) ClearData()
ClearData removes all data points from the graph.
func (*LineGraph) SetAutoScale ¶
SetAutoScale enables or disables automatic Y-axis scaling.
func (*LineGraph) SetMaxPoints ¶
SetMaxPoints sets the maximum number of data points to display.
func (*LineGraph) SetPosition ¶
SetPosition sets the top-left position of the graph.
func (*LineGraph) SetRange ¶
SetRange sets the minimum and maximum values for the Y axis. This disables auto-scaling. If maxVal <= minVal, the values are swapped to ensure a valid range.
func (*LineGraph) SetStyle ¶
func (lg *LineGraph) SetStyle(style GraphStyle)
SetStyle sets the visual style of the graph.
type PerformanceConfig ¶
type PerformanceConfig struct {
// TargetFPS is the target frame rate (default: 60).
TargetFPS int
// EnableDirtyTracking enables partial screen updates.
EnableDirtyTracking bool
// EnableObjectPooling enables object pooling for allocations.
EnableObjectPooling bool
// EnableMetrics enables frame timing metrics collection.
EnableMetrics bool
// MetricsUpdatePeriod is how often FPS is recalculated.
MetricsUpdatePeriod time.Duration
}
PerformanceConfig holds performance tuning settings.
func DefaultPerformanceConfig ¶
func DefaultPerformanceConfig() PerformanceConfig
DefaultPerformanceConfig returns a PerformanceConfig with sensible defaults.
type PerformanceManager ¶
type PerformanceManager struct {
// contains filtered or unexported fields
}
PerformanceManager coordinates performance optimization features.
func NewPerformanceManager ¶
func NewPerformanceManager(config PerformanceConfig, screenWidth, screenHeight int) *PerformanceManager
NewPerformanceManager creates a new PerformanceManager with the given config.
func (*PerformanceManager) Config ¶
func (pm *PerformanceManager) Config() PerformanceConfig
Config returns the current performance configuration. The config is read-only after PerformanceManager creation.
func (*PerformanceManager) DirtyTracker ¶
func (pm *PerformanceManager) DirtyTracker() *DirtyTracker
DirtyTracker returns the dirty region tracker, or nil if disabled.
func (*PerformanceManager) GetDrawOptions ¶
func (pm *PerformanceManager) GetDrawOptions() *ebiten.DrawImageOptions
GetDrawOptions retrieves a DrawImageOptions from the pool. If pooling is disabled, returns a new instance.
func (*PerformanceManager) GetIndices ¶
func (pm *PerformanceManager) GetIndices() []uint16
GetIndices retrieves an index slice from the pool.
func (*PerformanceManager) GetVertices ¶
func (pm *PerformanceManager) GetVertices() []ebiten.Vertex
GetVertices retrieves a vertex slice from the pool.
func (*PerformanceManager) Metrics ¶
func (pm *PerformanceManager) Metrics() *FrameMetrics
Metrics returns the frame metrics, or nil if disabled.
func (*PerformanceManager) PutDrawOptions ¶
func (pm *PerformanceManager) PutDrawOptions(op *ebiten.DrawImageOptions)
PutDrawOptions returns a DrawImageOptions to the pool. Does nothing if pooling is disabled.
func (*PerformanceManager) PutIndices ¶
func (pm *PerformanceManager) PutIndices(indices []uint16)
PutIndices returns an index slice to the pool.
func (*PerformanceManager) PutVertices ¶
func (pm *PerformanceManager) PutVertices(vertices []ebiten.Vertex)
PutVertices returns a vertex slice to the pool.
func (*PerformanceManager) RecordFrame ¶
func (pm *PerformanceManager) RecordFrame(frameTime time.Duration)
RecordFrame records a frame for metrics tracking.
func (*PerformanceManager) ResetStats ¶
func (pm *PerformanceManager) ResetStats()
ResetStats resets all performance statistics.
func (*PerformanceManager) SetScreenSize ¶
func (pm *PerformanceManager) SetScreenSize(width, height int)
SetScreenSize updates the screen size for dirty tracking.
func (*PerformanceManager) Stats ¶
func (pm *PerformanceManager) Stats() *RenderStats
Stats returns the render statistics.
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar displays a linear progress indicator. It can be horizontal or vertical, showing a filled portion representing a value between minimum and maximum.
func NewProgressBar ¶
func NewProgressBar(x, y, width, height float64) *ProgressBar
NewProgressBar creates a new progress bar with the specified dimensions.
func (*ProgressBar) Draw ¶
func (pb *ProgressBar) Draw(screen *ebiten.Image)
Draw renders the progress bar onto the given screen.
func (*ProgressBar) Percentage ¶
func (pb *ProgressBar) Percentage() float64
Percentage returns the current value as a percentage (0-100).
func (*ProgressBar) SetPosition ¶
func (pb *ProgressBar) SetPosition(x, y float64)
SetPosition sets the top-left position of the progress bar.
func (*ProgressBar) SetRange ¶
func (pb *ProgressBar) SetRange(minVal, maxVal float64)
SetRange sets the minimum and maximum values for the progress bar. If maxVal <= minVal, the values are swapped to ensure a valid range.
func (*ProgressBar) SetReversed ¶
func (pb *ProgressBar) SetReversed(reversed bool)
SetReversed sets whether the fill direction should be reversed. Horizontal: normally fills left-to-right, reversed fills right-to-left. Vertical: normally fills bottom-to-top, reversed fills top-to-bottom.
func (*ProgressBar) SetSize ¶
func (pb *ProgressBar) SetSize(width, height float64)
SetSize sets the width and height of the progress bar.
func (*ProgressBar) SetStyle ¶
func (pb *ProgressBar) SetStyle(style WidgetStyle)
SetStyle sets the visual style of the progress bar.
func (*ProgressBar) SetValue ¶
func (pb *ProgressBar) SetValue(value float64)
SetValue sets the current value of the progress bar. The value is clamped to the min/max range.
func (*ProgressBar) SetVertical ¶
func (pb *ProgressBar) SetVertical(vertical bool)
SetVertical sets whether the progress bar should be oriented vertically. Vertical bars fill from bottom to top by default.
func (*ProgressBar) Value ¶
func (pb *ProgressBar) Value() float64
Value returns the current value of the progress bar.
type RenderStats ¶
type RenderStats struct {
DrawCalls atomic.Int64
VertexCount atomic.Int64
TextDrawCalls atomic.Int64
LastResetTime atomic.Int64
}
RenderStats holds rendering performance statistics.
func NewRenderStats ¶
func NewRenderStats() *RenderStats
NewRenderStats creates a new RenderStats instance.
func (*RenderStats) RecordDrawCall ¶
func (rs *RenderStats) RecordDrawCall(vertices int)
RecordDrawCall records a draw call with its vertex count.
func (*RenderStats) RecordTextDraw ¶
func (rs *RenderStats) RecordTextDraw()
RecordTextDraw records a text drawing operation.
func (*RenderStats) Reset ¶
func (rs *RenderStats) Reset()
Reset clears all statistics. Note: Reset is not atomic with respect to RecordDrawCall, RecordTextDraw, or Stats. If called concurrently with recording or reading operations, callers may observe inconsistent intermediate states. For consistent behavior, ensure Reset is called when no other goroutines are accessing the stats.
func (*RenderStats) Stats ¶
func (rs *RenderStats) Stats() (drawCalls, vertices, textDraws int64)
Stats returns the current statistics.
func (*RenderStats) TimeSinceReset ¶
func (rs *RenderStats) TimeSinceReset() time.Duration
TimeSinceReset returns the duration since the last reset.
type TextLine ¶
type TextLine struct {
// Text is the string content that will be rendered.
Text string
// X is the horizontal position of the text's origin, in pixels from the
// left edge of the window (or drawing surface).
X float64
// Y is the vertical position of the text's baseline, in pixels from the
// top edge of the window (or drawing surface).
Y float64
// Color is the text color in RGBA format. The alpha channel controls
// the text's opacity if the renderer supports transparency.
Color color.RGBA
}
TextLine represents a line of text to be rendered.
type TextRenderer ¶
type TextRenderer struct {
// contains filtered or unexported fields
}
TextRenderer handles text rendering using Ebiten's text package. It supports multiple fonts through a FontManager and font style variations.
func NewTextRenderer ¶
func NewTextRenderer() *TextRenderer
NewTextRenderer creates a new TextRenderer with the default monospace font.
func NewTextRendererWithManager ¶
func NewTextRendererWithManager(fm *FontManager) *TextRenderer
NewTextRendererWithManager creates a TextRenderer using a shared FontManager. This allows multiple renderers to share font resources.
func (*TextRenderer) DrawText ¶
func (tr *TextRenderer) DrawText(screen *ebiten.Image, textStr string, x, y float64, clr color.RGBA)
DrawText renders text at the specified position with the given color.
func (*TextRenderer) DrawTextWithStyle ¶
func (tr *TextRenderer) DrawTextWithStyle(screen *ebiten.Image, textStr string, x, y float64, clr color.RGBA, style FontStyle)
DrawTextWithStyle renders text with a specific style override.
func (*TextRenderer) FontFamily ¶
func (tr *TextRenderer) FontFamily() string
FontFamily returns the current font family name.
func (*TextRenderer) FontManager ¶
func (tr *TextRenderer) FontManager() *FontManager
FontManager returns the underlying FontManager for advanced font operations.
func (*TextRenderer) FontSize ¶
func (tr *TextRenderer) FontSize() float64
FontSize returns the current font size.
func (*TextRenderer) FontStyle ¶
func (tr *TextRenderer) FontStyle() FontStyle
FontStyle returns the current font style.
func (*TextRenderer) LineHeight ¶
func (tr *TextRenderer) LineHeight() float64
LineHeight returns the height of a single line of text.
func (*TextRenderer) LoadFontFromFile ¶
func (tr *TextRenderer) LoadFontFromFile(familyName string, style FontStyle, filePath string) error
LoadFontFromFile loads a font from a file and registers it with the manager.
func (*TextRenderer) MeasureText ¶
func (tr *TextRenderer) MeasureText(textStr string) (width, height float64)
MeasureText returns the width and height of the given text string.
func (*TextRenderer) SetFont ¶
func (tr *TextRenderer) SetFont(family string, style FontStyle)
SetFont sets the font family and style for text rendering. If the family doesn't exist, the default family is used.
func (*TextRenderer) SetFontFamily ¶
func (tr *TextRenderer) SetFontFamily(family string)
SetFontFamily sets the font family for text rendering.
func (*TextRenderer) SetFontSize ¶
func (tr *TextRenderer) SetFontSize(size float64)
SetFontSize sets the font size for text rendering. If a non-positive size is provided, the font size is reset to defaultFontSize.
func (*TextRenderer) SetFontStyle ¶
func (tr *TextRenderer) SetFontStyle(style FontStyle)
SetFontStyle sets the font style (regular, bold, italic, bold-italic).
type TextRendererInterface ¶
type TextRendererInterface interface {
DrawText(screen *ebiten.Image, textStr string, x, y float64, clr color.RGBA)
MeasureText(textStr string) (width, height float64)
LineHeight() float64
SetFontSize(size float64)
FontSize() float64
}
TextRendererInterface defines the interface for text rendering. This allows for mocking in tests.
type VertexPool ¶
type VertexPool struct {
// contains filtered or unexported fields
}
VertexPool provides pooling for vertex slices used in triangle drawing.
func (*VertexPool) Get ¶
func (p *VertexPool) Get() []ebiten.Vertex
Get retrieves a vertex slice from the pool. The returned slice has length 0 but may have capacity > 0.
func (*VertexPool) Put ¶
func (p *VertexPool) Put(vertices []ebiten.Vertex)
Put returns a vertex slice to the pool. Note: This creates a new pointer allocation for &vertices on each call. While this adds a small overhead, it's necessary for correct sync.Pool usage with slice types and is the recommended pattern to avoid SA6002 warnings.
type Widget ¶
type Widget interface {
// Draw renders the widget onto the given screen.
Draw(screen *ebiten.Image)
// SetStyle sets the visual style of the widget.
SetStyle(style WidgetStyle)
// SetPosition sets the position of the widget.
SetPosition(x, y float64)
// SetValue sets the current value of the widget.
SetValue(value float64)
// SetRange sets the minimum and maximum values for the widget.
SetRange(minVal, maxVal float64)
// Value returns the current value of the widget.
Value() float64
// Percentage returns the current value as a percentage (0-100).
Percentage() float64
}
Widget is the interface that all progress-based widgets must implement. This provides consistency with GraphWidget and enables polymorphic usage.
type WidgetStyle ¶
type WidgetStyle struct {
// FillColor is the color used to fill the progress portion.
FillColor color.RGBA
// BackgroundColor is the background color of the widget area.
BackgroundColor color.RGBA
// BorderColor is the color used for the widget border.
BorderColor color.RGBA
// BorderWidth is the width of the border in pixels.
BorderWidth float32
// ShowBorder indicates whether to draw the border.
ShowBorder bool
// ShowBackground indicates whether to draw the background.
ShowBackground bool
}
WidgetStyle defines the visual appearance of progress bar and gauge widgets.
func DefaultWidgetStyle ¶
func DefaultWidgetStyle() WidgetStyle
DefaultWidgetStyle returns a WidgetStyle with sensible defaults.