Documentation
¶
Overview ¶
Package render defines fluo's abstract 2D drawing surface: the Renderer interface (FillRect/FillRoundedRect/StrokeRoundedRect/DrawShadow/ DrawBackdropBlur/DrawQuad/DrawSDFQuads plus texture management and clip push/pop) and the plain-data geometry types every other package builds on — Point, Size, Rect (with Thickness-based Inset), and Color (0..1 float components, with RGB/RGBA byte-based constructors). It has no dependency on any particular graphics API; render/gl is the OpenGL 3.3 implementation of Renderer that the app package wires up, and core's layout engine, text's glyph drawing, and every controls widget speak only in terms of the types and interface defined here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color struct {
R, G, B, A float32
}
Color represents an RGBA color with components in the range [0, 1].
type GlyphQuad ¶
type GlyphQuad struct {
Dst, Src Rect
}
GlyphQuad represents a glyph quad with destination and source rectangles.
type Point ¶
type Point struct {
X, Y float32
}
Point represents a 2D point with X and Y coordinates.
type Rect ¶
type Rect struct {
X, Y, W, H float32
}
Rect represents a rectangle with top-left position and size.
func (Rect) Contains ¶
Contains checks if a point is inside the rectangle (half-open interval [X, Right) × [Y, Bottom)).
type Renderer ¶
type Renderer interface {
// Begin starts a new frame with the given framebuffer dimensions (in device pixels) and scale factor.
Begin(fbWidth, fbHeight int, scale float32)
// End flushes the current frame.
End()
// FillRect fills a rectangle with a solid color.
FillRect(r Rect, c Color)
// FillRoundedRect fills a rectangle with rounded corners with a solid color.
FillRoundedRect(r Rect, radius float32, c Color)
// DrawGradientRect fills r with a linear gradient from `from` to `to`:
// horizontal (left->right) when horizontal is true, else vertical (top->bottom).
DrawGradientRect(r Rect, from, to Color, horizontal bool)
// StrokeRoundedRect draws the stroke of a rectangle with rounded corners (stroke inside edge).
StrokeRoundedRect(r Rect, radius, width float32, c Color)
// DrawShadow draws a soft shadow of a rounded rectangle.
DrawShadow(r Rect, radius, blur float32, c Color)
// DrawBackdropBlur draws an acrylic/mica-style backdrop-blur surface:
// it snapshots whatever has already been drawn beneath r, blurs it, and
// composites the result back into r (rounded by radius) tinted by c —
// approximating WinUI's acrylic material. Because it samples already-
// rendered content, callers must invoke it AFTER painting whatever
// should show through, and BEFORE drawing anything meant to sit on top
// of the acrylic surface (e.g. its children). An implementation that
// cannot obtain a true mid-frame snapshot may instead degrade to a
// flat, tinted, translucent rounded fill (equivalent to
// FillRoundedRect(r, radius, c)); any such degrade must be prominently
// documented at the implementation site.
DrawBackdropBlur(r Rect, radius float32, tint Color)
// CreateTexture creates a new texture from RGBA8 data.
// The rgba slice must have length w*h*4; if rgba is non-nil and shorter
// than that, implementations panic. A nil rgba allocates storage without
// uploading pixels.
CreateTexture(w, h int, rgba []byte) TextureID
// UpdateTexture updates a region of an existing texture.
// The rgba slice must have length w*h*4; implementations panic if it is
// shorter (rgba must not be nil here, unlike CreateTexture).
UpdateTexture(id TextureID, x, y, w, h int, rgba []byte)
// DeleteTexture frees a texture created by CreateTexture; NoTexture is a
// no-op.
DeleteTexture(id TextureID)
// DrawQuad draws a textured quad with the source rectangle in UV coordinates (0..1) and a tint color.
DrawQuad(dst, src Rect, tex TextureID, tint Color)
// DrawSDFQuads draws glyphs from an SDF alpha atlas with the given color.
// Retained for future scaled/animated text; text.Face.Draw's default
// (HD) path uses DrawGlyphs instead.
DrawSDFQuads(quads []GlyphQuad, tex TextureID, c Color)
// DrawGlyphs draws grayscale-coverage glyph quads from a coverage atlas
// (alpha = texture.r) tinted with c. Quads' Dst is in logical px (the
// vertex shader applies uScale); Src is 0..1 atlas UV. Used by
// text.Face for crisp, direct grayscale-AA UI text. Distinct from
// DrawSDFQuads (SDF path, retained for future scaled/animated text).
DrawGlyphs(quads []GlyphQuad, tex TextureID, c Color)
// Scale returns the current frame's device-pixels-per-logical-pixel
// factor (as passed to Begin). Valid between Begin and End. The text
// layer uses it to rasterize glyphs at device resolution and to
// pixel-snap; no other code should multiply by scale (the vertex
// shader applies uScale exactly once).
Scale() float32
// PushClip pushes a new clip rectangle that intersects with the current clip.
PushClip(r Rect)
// PopClip pops the current clip rectangle.
PopClip()
}
Renderer is the interface for rendering graphics operations.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gl implements render.Renderer on top of OpenGL 3.3 core.
|
Package gl implements render.Renderer on top of OpenGL 3.3 core. |
|
gltest
Package gltest is a golden-image test harness for OpenGL rendering code.
|
Package gltest is a golden-image test harness for OpenGL rendering code. |