Documentation
¶
Overview ¶
Package canvas contains all of the primitive CanvasObjects that make up a Bellui GUI.
The types implemented in this package are used as building blocks in order to build higher order functionality. These types are designed to be non-interactive, by design. If additional functionality is required, it's usually a sign that this type should be used as part of a custom widget.
Scene3D represents a 3D scene that can be rendered as a Bellui canvas object. It contains meshes, a camera, and lights, and renders them into a 2D image using software rasterization with perspective projection and z-buffering.
Since: 1.0
Index ¶
- Constants
- Variables
- func NewColorRGBAAnimation(start, stop color.Color, d time.Duration, fn func(color.Color)) *bellui.Animation
- func NewFloat32Animation(start, stop float32, d time.Duration, fn func(float32)) *bellui.Animation
- func NewKeyframeAnimation(keyframes []Keyframe, d time.Duration, fn func(float32)) *bellui.Animation
- func NewParallelAnimation(children ...*bellui.Animation) *bellui.Animation
- func NewPathAnimation(points []geo.Position, d time.Duration, fn func(geo.Position)) *bellui.Animation
- func NewPositionAnimation(start, stop geo.Position, d time.Duration, fn func(geo.Position)) *bellui.Animation
- func NewPositionKeyframeAnimation(keyframes []PositionKeyframe, d time.Duration, fn func(geo.Position)) *bellui.Animation
- func NewSequenceAnimation(children ...*bellui.Animation) *bellui.Animation
- func NewSizeAnimation(start, stop geo.Size, d time.Duration, fn func(geo.Size)) *bellui.Animation
- func NewSpringAnimation(config SpringConfig, fn func(float32)) *bellui.Animation
- func NewSpringFloat32Animation(start, stop float32, config SpringConfig, fn func(float32)) *bellui.Animation
- func NewStaggeredAnimation(entries []StaggeredEntry) *bellui.Animation
- func RecolorSVG(svgContent []byte, color color.Color) ([]byte, error)
- func Refresh(obj core.CanvasObject)
- type AnimatedFloat32
- type AnimatedPosition
- type Arc
- func (a *Arc) Hide()
- func (o *Arc) MinSize() geo.Size
- func (a *Arc) Move(pos geo.Position)
- func (o *Arc) Position() geo.Position
- func (a *Arc) Refresh()
- func (a *Arc) Resize(s geo.Size)
- func (o *Arc) SetMinSize(size geo.Size)
- func (o *Arc) SetTransform(m geo.Matrix)
- func (o *Arc) Show()
- func (o *Arc) Size() geo.Size
- func (o *Arc) Transform() geo.Matrix
- func (o *Arc) Visible() bool
- type AxisConfig3D
- type BackdropBlur
- func (b *BackdropBlur) Hide()
- func (b *BackdropBlur) MinSize() geo.Size
- func (b *BackdropBlur) Move(pos geo.Position)
- func (o *BackdropBlur) Position() geo.Position
- func (b *BackdropBlur) Refresh()
- func (b *BackdropBlur) Resize(s geo.Size)
- func (o *BackdropBlur) SetMinSize(size geo.Size)
- func (o *BackdropBlur) SetTransform(m geo.Matrix)
- func (o *BackdropBlur) Show()
- func (o *BackdropBlur) Size() geo.Size
- func (o *BackdropBlur) Transform() geo.Matrix
- func (o *BackdropBlur) Visible() bool
- type BoxShadow
- func (s *BoxShadow) Hide()
- func (o *BoxShadow) MinSize() geo.Size
- func (s *BoxShadow) Move(pos geo.Position)
- func (o *BoxShadow) Position() geo.Position
- func (s *BoxShadow) Refresh()
- func (s *BoxShadow) Resize(size geo.Size)
- func (o *BoxShadow) SetMinSize(size geo.Size)
- func (o *BoxShadow) SetTransform(m geo.Matrix)
- func (o *BoxShadow) Show()
- func (o *BoxShadow) Size() geo.Size
- func (o *BoxShadow) Transform() geo.Matrix
- func (o *BoxShadow) Visible() bool
- type Camera3D
- type Circle
- func (c *Circle) Hide()
- func (c *Circle) MinSize() geo.Size
- func (c *Circle) Move(pos geo.Position)
- func (c *Circle) Position() geo.Position
- func (c *Circle) Refresh()
- func (c *Circle) Resize(size geo.Size)
- func (c *Circle) SetTransform(m geo.Matrix)
- func (c *Circle) Show()
- func (c *Circle) Size() geo.Size
- func (c *Circle) Transform() geo.Matrix
- func (c *Circle) Visible() bool
- type Face
- type FillRule
- type GLAttribute
- type GLBuffer
- type GLContext
- type GLFramebuffer
- type GLProgram
- type GLShader
- type GLTexture
- type GLUniform
- type GLView
- func (v *GLView) Hide()
- func (o *GLView) MinSize() geo.Size
- func (v *GLView) Move(pos geo.Position)
- func (o *GLView) Position() geo.Position
- func (v *GLView) Refresh()
- func (v *GLView) Resize(s geo.Size)
- func (o *GLView) SetMinSize(size geo.Size)
- func (o *GLView) SetTransform(m geo.Matrix)
- func (o *GLView) Show()
- func (o *GLView) Size() geo.Size
- func (o *GLView) Transform() geo.Matrix
- func (o *GLView) Visible() bool
- type GradientStop
- type Image
- func (i *Image) Alpha() float64
- func (i *Image) Aspect() float32
- func (i *Image) Hide()
- func (i *Image) MinSize() geo.Size
- func (i *Image) Move(pos geo.Position)
- func (o *Image) Position() geo.Position
- func (i *Image) Refresh()
- func (i *Image) Resize(s geo.Size)
- func (o *Image) SetMinSize(size geo.Size)
- func (o *Image) SetTransform(m geo.Matrix)
- func (o *Image) Show()
- func (o *Image) Size() geo.Size
- func (o *Image) Transform() geo.Matrix
- func (o *Image) Visible() bool
- type ImageFill
- type ImageScale
- type Keyframe
- type Light3D
- type Line
- func (l *Line) Hide()
- func (l *Line) MinSize() geo.Size
- func (l *Line) Move(pos geo.Position)
- func (l *Line) Position() geo.Position
- func (l *Line) Refresh()
- func (l *Line) Resize(size geo.Size)
- func (l *Line) SetTransform(m geo.Matrix)
- func (l *Line) Show()
- func (l *Line) Size() geo.Size
- func (l *Line) Transform() geo.Matrix
- func (l *Line) Visible() bool
- type LineCap
- type LineJoin
- type LinearGradient
- func (g *LinearGradient) Generate(iw, ih int) image.Image
- func (g *LinearGradient) Hide()
- func (o *LinearGradient) MinSize() geo.Size
- func (g *LinearGradient) Move(pos geo.Position)
- func (o *LinearGradient) Position() geo.Position
- func (g *LinearGradient) Refresh()
- func (g *LinearGradient) Resize(size geo.Size)
- func (o *LinearGradient) SetMinSize(size geo.Size)
- func (o *LinearGradient) SetTransform(m geo.Matrix)
- func (o *LinearGradient) Show()
- func (o *LinearGradient) Size() geo.Size
- func (o *LinearGradient) Transform() geo.Matrix
- func (o *LinearGradient) Visible() bool
- type Mat4
- type Mesh3D
- type OrbitCamera
- type Path
- func (p *Path) Bounds() (minX, minY, maxX, maxY float32)
- func (p *Path) Close()
- func (p *Path) CubicTo(cx1, cy1, cx2, cy2, x, y float32)
- func (p *Path) Elements() []PathElement
- func (p *Path) Hide()
- func (p *Path) LineTo(x, y float32)
- func (o *Path) MinSize() geo.Size
- func (p *Path) Move(pos geo.Position)
- func (p *Path) MoveTo(x, y float32)
- func (o *Path) Position() geo.Position
- func (p *Path) QuadTo(cx, cy, x, y float32)
- func (p *Path) Refresh()
- func (p *Path) Reset()
- func (p *Path) Resize(s geo.Size)
- func (o *Path) SetMinSize(size geo.Size)
- func (o *Path) SetTransform(m geo.Matrix)
- func (o *Path) Show()
- func (o *Path) Size() geo.Size
- func (o *Path) Transform() geo.Matrix
- func (o *Path) Visible() bool
- type PathCommand
- type PathElement
- type Polygon
- func (r *Polygon) Hide()
- func (o *Polygon) MinSize() geo.Size
- func (r *Polygon) Move(pos geo.Position)
- func (o *Polygon) Position() geo.Position
- func (r *Polygon) Refresh()
- func (r *Polygon) Resize(s geo.Size)
- func (o *Polygon) SetMinSize(size geo.Size)
- func (o *Polygon) SetTransform(m geo.Matrix)
- func (o *Polygon) Show()
- func (o *Polygon) Size() geo.Size
- func (o *Polygon) Transform() geo.Matrix
- func (o *Polygon) Visible() bool
- type PositionKeyframe
- type RadialGradient
- func (g *RadialGradient) Generate(iw, ih int) image.Image
- func (g *RadialGradient) Hide()
- func (o *RadialGradient) MinSize() geo.Size
- func (g *RadialGradient) Move(pos geo.Position)
- func (o *RadialGradient) Position() geo.Position
- func (g *RadialGradient) Refresh()
- func (g *RadialGradient) Resize(size geo.Size)
- func (o *RadialGradient) SetMinSize(size geo.Size)
- func (o *RadialGradient) SetTransform(m geo.Matrix)
- func (o *RadialGradient) Show()
- func (o *RadialGradient) Size() geo.Size
- func (o *RadialGradient) Transform() geo.Matrix
- func (o *RadialGradient) Visible() bool
- type Raster
- func (r *Raster) Alpha() float64
- func (r *Raster) Hide()
- func (o *Raster) MinSize() geo.Size
- func (r *Raster) Move(pos geo.Position)
- func (r *Raster) PixelImage(w, h int) image.Image
- func (o *Raster) Position() geo.Position
- func (r *Raster) Refresh()
- func (r *Raster) Resize(s geo.Size)
- func (o *Raster) SetMinSize(size geo.Size)
- func (r *Raster) SetPixels(pix []byte, width, height int)
- func (o *Raster) SetTransform(m geo.Matrix)
- func (o *Raster) Show()
- func (o *Raster) Size() geo.Size
- func (o *Raster) Transform() geo.Matrix
- func (o *Raster) Visible() bool
- type Rectangle
- func (r *Rectangle) Hide()
- func (o *Rectangle) MinSize() geo.Size
- func (r *Rectangle) Move(pos geo.Position)
- func (o *Rectangle) Position() geo.Position
- func (r *Rectangle) Refresh()
- func (r *Rectangle) Resize(s geo.Size)
- func (o *Rectangle) SetMinSize(size geo.Size)
- func (o *Rectangle) SetTransform(m geo.Matrix)
- func (o *Rectangle) Show()
- func (o *Rectangle) Size() geo.Size
- func (o *Rectangle) Transform() geo.Matrix
- func (o *Rectangle) Visible() bool
- type Ripple
- func (r *Ripple) Hide()
- func (o *Ripple) MinSize() geo.Size
- func (r *Ripple) Move(pos geo.Position)
- func (o *Ripple) Position() geo.Position
- func (r *Ripple) Refresh()
- func (r *Ripple) Resize(s geo.Size)
- func (o *Ripple) SetMinSize(size geo.Size)
- func (o *Ripple) SetTransform(m geo.Matrix)
- func (o *Ripple) Show()
- func (o *Ripple) Size() geo.Size
- func (o *Ripple) Transform() geo.Matrix
- func (o *Ripple) Visible() bool
- type Scene3D
- func (s *Scene3D) AddAxes(xCfg, yCfg, zCfg AxisConfig3D)
- func (s *Scene3D) AddMesh(m Mesh3D)
- func (s *Scene3D) Hide()
- func (o *Scene3D) MinSize() geo.Size
- func (s *Scene3D) Move(pos geo.Position)
- func (o *Scene3D) Position() geo.Position
- func (s *Scene3D) Refresh()
- func (s *Scene3D) Render(width, height int) *image.NRGBA
- func (s *Scene3D) Resize(size geo.Size)
- func (o *Scene3D) SetMinSize(size geo.Size)
- func (o *Scene3D) SetTransform(m geo.Matrix)
- func (o *Scene3D) Show()
- func (o *Scene3D) Size() geo.Size
- func (o *Scene3D) Transform() geo.Matrix
- func (o *Scene3D) Visible() bool
- type SpringConfig
- type StaggeredEntry
- type StyledText
- func (st *StyledText) Hide()
- func (st *StyledText) MinSize() geo.Size
- func (st *StyledText) Move(pos geo.Position)
- func (o *StyledText) Position() geo.Position
- func (st *StyledText) Refresh()
- func (st *StyledText) Resize(s geo.Size)
- func (st *StyledText) SetMinSize(geo.Size)
- func (o *StyledText) SetTransform(m geo.Matrix)
- func (o *StyledText) Show()
- func (o *StyledText) Size() geo.Size
- func (o *StyledText) Transform() geo.Matrix
- func (o *StyledText) Visible() bool
- type Text
- func (t *Text) Hide()
- func (t *Text) MinSize() geo.Size
- func (t *Text) MinSizeWithBaseline() (geo.Size, float32)
- func (t *Text) Move(pos geo.Position)
- func (o *Text) Position() geo.Position
- func (t *Text) Refresh()
- func (t *Text) Resize(s geo.Size)
- func (t *Text) Rotation() float32
- func (t *Text) SetMinSize(geo.Size)
- func (t *Text) SetRotation(degrees float32)
- func (t *Text) SetTransform(m geo.Matrix)
- func (o *Text) Show()
- func (o *Text) Size() geo.Size
- func (t *Text) Transform() geo.Matrix
- func (o *Text) Visible() bool
- type TextOnPath
- func (t *TextOnPath) Close()
- func (t *TextOnPath) CubicTo(cx1, cy1, cx2, cy2, x, y float32)
- func (t *TextOnPath) Elements() []PathElement
- func (t *TextOnPath) Hide()
- func (t *TextOnPath) LineTo(x, y float32)
- func (t *TextOnPath) MinSize() geo.Size
- func (t *TextOnPath) Move(pos geo.Position)
- func (t *TextOnPath) MoveTo(x, y float32)
- func (o *TextOnPath) Position() geo.Position
- func (t *TextOnPath) QuadTo(cx, cy, x, y float32)
- func (t *TextOnPath) Refresh()
- func (t *TextOnPath) Reset()
- func (t *TextOnPath) Resize(s geo.Size)
- func (t *TextOnPath) SetMinSize(geo.Size)
- func (o *TextOnPath) SetTransform(m geo.Matrix)
- func (o *TextOnPath) Show()
- func (o *TextOnPath) Size() geo.Size
- func (o *TextOnPath) Transform() geo.Matrix
- func (o *TextOnPath) Visible() bool
- type TextRun
- type Vec3
Constants ¶
const ( // DurationStandard is the time a standard interface animation will run. // // Since: 1.0 DurationStandard = time.Millisecond * 300 // DurationShort is the time a subtle or small transition should use. // // Since: 1.0 DurationShort = time.Millisecond * 150 // MD3 duration tokens. DurationShort1 = time.Millisecond * 50 DurationShort2 = time.Millisecond * 100 DurationShort3 = DurationShort // 150ms DurationShort4 = time.Millisecond * 200 DurationMedium1 = time.Millisecond * 250 DurationMedium2 = DurationStandard // 300ms DurationMedium3 = time.Millisecond * 350 DurationMedium4 = time.Millisecond * 400 DurationLong1 = time.Millisecond * 450 DurationLong2 = time.Millisecond * 500 )
const ( // Texture targets GL_TEXTURE_2D = 0x0DE1 GL_TEXTURE0 = 0x84C0 // Pixel formats GL_RGBA = 0x1908 GL_RGB = 0x1907 GL_UNSIGNED_BYTE = 0x1401 // Texture parameters GL_TEXTURE_MIN_FILTER = 0x2801 GL_TEXTURE_MAG_FILTER = 0x2800 GL_TEXTURE_WRAP_S = 0x2802 GL_TEXTURE_WRAP_T = 0x2803 GL_LINEAR = 0x2601 GL_NEAREST = 0x2600 GL_CLAMP_TO_EDGE = 0x812F GL_REPEAT = 0x2901 // Buffer targets GL_ARRAY_BUFFER = 0x8892 GL_ELEMENT_ARRAY_BUFFER = 0x8893 // Buffer usage GL_STATIC_DRAW = 0x88E4 GL_DYNAMIC_DRAW = 0x88E8 // Data types GL_FLOAT = 0x1406 GL_UNSIGNED_SHORT = 0x1403 // Shader types GL_VERTEX_SHADER = 0x8B31 GL_FRAGMENT_SHADER = 0x8B30 GL_COMPILE_STATUS = 0x8B81 GL_LINK_STATUS = 0x8B82 // Draw modes GL_POINTS = 0x0000 GL_LINES = 0x0001 GL_LINE_STRIP = 0x0003 GL_TRIANGLES = 0x0004 GL_TRIANGLE_STRIP = 0x0005 GL_TRIANGLE_FAN = 0x0006 // Blend factors GL_ZERO = 0 GL_ONE = 1 GL_SRC_ALPHA = 0x0302 GL_ONE_MINUS_SRC_ALPHA = 0x0303 // Clear bits GL_COLOR_BUFFER_BIT = 0x00004000 GL_DEPTH_BUFFER_BIT = 0x00000100 GL_STENCIL_BUFFER_BIT = 0x00000400 // Capabilities GL_BLEND = 0x0BE2 GL_DEPTH_TEST = 0x0B71 GL_SCISSOR_TEST = 0x0C11 GL_STENCIL_TEST = 0x0B90 // Depth GL_DEPTH_ATTACHMENT = 0x8D00 GL_DEPTH_COMPONENT = 0x1902 // Framebuffer GL_FRAMEBUFFER = 0x8D40 GL_COLOR_ATTACHMENT0 = 0x8CE0 GL_FRAMEBUFFER_COMPLETE = 0x8CD5 // Stencil ops GL_KEEP = 0x1E00 GL_REPLACE = 0x1E01 GL_ALWAYS = 0x0207 GL_EQUAL = 0x0202 // Boolean GL_TRUE = 1 GL_FALSE = 0 )
Standard OpenGL constants. These match the OpenGL/ES specification values and can be passed directly to GLContext methods.
const ( // RadiusMaximum can be applied to a canvas corner radius to achieve fully rounded corners. // This constant represents the maximum possible corner radius, resulting in a circular appearance. // Since: 1.0 RadiusMaximum float32 = math.MaxFloat32 )
Variables ¶
var ( // SpringGentle is a soft, slow spring with moderate oscillation. SpringGentle = SpringConfig{Stiffness: 120, Damping: 14, Mass: 1, MaxDuration: 2 * time.Second} // SpringBouncy is a lively spring with visible oscillation before settling. SpringBouncy = SpringConfig{Stiffness: 300, Damping: 10, Mass: 1, MaxDuration: 2 * time.Second} // SpringStiff is a fast, snappy spring with minimal oscillation. SpringStiff = SpringConfig{Stiffness: 400, Damping: 28, Mass: 1, MaxDuration: time.Second} )
Preset spring configurations.
Functions ¶
func NewColorRGBAAnimation ¶
func NewColorRGBAAnimation(start, stop color.Color, d time.Duration, fn func(color.Color)) *bellui.Animation
NewColorRGBAAnimation sets up a new animation that will transition from the start to stop Color over the specified Duration. The colour transition will move linearly through the RGB colour space. The content of fn should apply the color values to an object and refresh it. You should call Start() on the returned animation to start it.
Since: 1.0
func NewFloat32Animation ¶
NewFloat32Animation sets up a new animation that will transition from start to stop over the specified Duration. This is the general-purpose scalar interpolation, suitable for animating opacity, rotation angles, scale factors, or any single float32 property. The content of fn should apply the value to an object and refresh it. You should call Start() on the returned animation to start it.
func NewKeyframeAnimation ¶
func NewKeyframeAnimation(keyframes []Keyframe, d time.Duration, fn func(float32)) *bellui.Animation
NewKeyframeAnimation creates an animation that transitions through the given keyframes over the specified duration. Each keyframe specifies a value at a progress point, with optional per-segment easing curves.
Requirements:
- At least 2 keyframes
- First keyframe must have Progress == 0.0 (within a small epsilon)
- Last keyframe must have Progress == 1.0 (within a small epsilon)
- Keyframes must be sorted by Progress (ascending)
Panics if requirements are not met. The first/last Progress checks use an epsilon tolerance so a caller computing progress as a float (e.g. 0.9999998) does not panic. The returned animation uses AnimationLinear because per-segment curves handle easing. You should call Start() on the returned animation.
func NewParallelAnimation ¶
NewParallelAnimation creates an animation that runs all children simultaneously. The duration is the maximum of the children's durations. Children with shorter durations reach their final value and hold it until the overall animation completes.
Each child's own Curve is applied; the returned animation uses AnimationLinear so children control their own easing. Children's RepeatCount and AutoReverse fields are ignored — set those on the returned animation if needed.
func NewPathAnimation ¶
func NewPathAnimation(points []geo.Position, d time.Duration, fn func(geo.Position)) *bellui.Animation
NewPathAnimation sets up a new animation that will move through the given waypoints over the specified Duration. The points are traversed in order with equal time per segment. At least 2 points are required. The content of fn should apply the position to an object and refresh it. You should call Start() on the returned animation to start it.
func NewPositionAnimation ¶
func NewPositionAnimation(start, stop geo.Position, d time.Duration, fn func(geo.Position)) *bellui.Animation
NewPositionAnimation sets up a new animation that will transition from the start to stop Position over the specified Duration. The content of fn should apply the position value to an object for the change to be visible. You should call Start() on the returned animation to start it.
Since: 1.0
func NewPositionKeyframeAnimation ¶
func NewPositionKeyframeAnimation(keyframes []PositionKeyframe, d time.Duration, fn func(geo.Position)) *bellui.Animation
NewPositionKeyframeAnimation creates an animation that transitions through position keyframes over the specified duration. See NewKeyframeAnimation for requirements.
func NewSequenceAnimation ¶
NewSequenceAnimation creates an animation that runs children one after another in the order given. The total duration is the sum of all children's durations.
Each child's own Curve is applied; the returned animation uses AnimationLinear. Children's RepeatCount and AutoReverse fields are ignored.
func NewSizeAnimation ¶
NewSizeAnimation sets up a new animation that will transition from the start to stop Size over the specified Duration. The content of fn should apply the size value to an object for the change to be visible. You should call Start() on the returned animation to start it.
Since: 1.0
func NewSpringAnimation ¶
func NewSpringAnimation(config SpringConfig, fn func(float32)) *bellui.Animation
NewSpringAnimation creates a physics-based spring animation. The callback fn receives values from 0.0 (start) to 1.0 (settled), following spring dynamics that may overshoot and oscillate depending on the configuration.
The animation runs for at most config.MaxDuration. The spring typically settles well before that. The returned animation uses AnimationLinear because the spring equation provides its own easing.
You should call Start() on the returned animation to start it.
func NewSpringFloat32Animation ¶
func NewSpringFloat32Animation(start, stop float32, config SpringConfig, fn func(float32)) *bellui.Animation
NewSpringFloat32Animation creates a spring animation that transitions from start to stop with spring dynamics. This is a convenience wrapper around NewSpringAnimation.
You should call Start() on the returned animation to start it.
func NewStaggeredAnimation ¶
func NewStaggeredAnimation(entries []StaggeredEntry) *bellui.Animation
NewStaggeredAnimation creates an animation that runs children with staggered start offsets. Each entry specifies an animation and its delay from the start of the overall animation. The total duration is max(entry.Delay + entry.Animation.Duration) across all entries.
Each child's own Curve is applied; the returned animation uses AnimationLinear. Children's RepeatCount and AutoReverse fields are ignored.
func RecolorSVG ¶
RecolorSVG takes a []byte containing SVG content, and returns new SVG content, re-colorized to be monochrome with the given color. The content can be assigned to a new bellui.StaticResource with an appropriate name to be used in a widget.Button, canvas.Image, etc.
If an error occurs, the returned content will be the original un-modified content, and a non-nil error is returned.
Since: 1.0
func Refresh ¶
func Refresh(obj core.CanvasObject)
Refresh instructs the containing canvas to refresh the specified obj.
Types ¶
type AnimatedFloat32 ¶
type AnimatedFloat32 struct {
// contains filtered or unexported fields
}
AnimatedFloat32 tracks a float32 value that can be smoothly animated to new targets. When AnimateTo is called while an animation is running, the current (interrupted) value is captured as the start of the new animation, enabling seamless transitions.
AnimatedFloat32 must only be used from the main thread (the same goroutine that processes UI events and animation ticks).
func NewAnimatedFloat32 ¶
func NewAnimatedFloat32(initial float32) *AnimatedFloat32
NewAnimatedFloat32 creates an AnimatedFloat32 with the given initial value.
func (*AnimatedFloat32) AnimateTo ¶
func (a *AnimatedFloat32) AnimateTo(target float32, d time.Duration, curve bellui.AnimationCurve, fn func(float32))
AnimateTo starts a new animation from the current value to target. If an animation is already running, it is stopped and the new animation starts from the interrupted value. The fn callback is called each frame with the current value; it should apply the value to a canvas object and refresh it.
func (*AnimatedFloat32) Stop ¶
func (a *AnimatedFloat32) Stop()
Stop stops the current animation if one is running. The value remains at its current (interrupted) position.
func (*AnimatedFloat32) Value ¶
func (a *AnimatedFloat32) Value() float32
Value returns the current animated value.
type AnimatedPosition ¶
type AnimatedPosition struct {
// contains filtered or unexported fields
}
AnimatedPosition tracks a position that can be smoothly animated to new targets. When AnimateTo is called while an animation is running, the current (interrupted) position is captured as the start of the new animation.
AnimatedPosition must only be used from the main thread.
func NewAnimatedPosition ¶
func NewAnimatedPosition(initial geo.Position) *AnimatedPosition
NewAnimatedPosition creates an AnimatedPosition with the given initial position.
func (*AnimatedPosition) AnimateTo ¶
func (a *AnimatedPosition) AnimateTo(target geo.Position, d time.Duration, curve bellui.AnimationCurve, fn func(geo.Position))
AnimateTo starts a new animation from the current position to target. If an animation is already running, it is stopped and the new animation starts from the interrupted position.
func (*AnimatedPosition) Stop ¶
func (a *AnimatedPosition) Stop()
Stop stops the current animation if one is running. The position remains at its current (interrupted) value.
func (*AnimatedPosition) Value ¶
func (a *AnimatedPosition) Value() geo.Position
Value returns the current animated position.
type Arc ¶
type Arc struct {
FillColor color.Color // The arc fill colour
StartAngle float32 // Start angle in degrees
EndAngle float32 // End angle in degrees
CornerRadius float32 // Radius used to round the corners
StrokeColor color.Color // The arc stroke color
StrokeWidth float32 // The stroke width of the arc
CutoutRatio float32 // Controls what portion of the inner should be cut out. A value of 0.0 results in a pie slice, while 1.0 results in a stroke.
// contains filtered or unexported fields
}
Arc represents a filled arc or annular sector primitive that can be drawn on a Bellui canvas. It allows for the creation of circular, ring-shaped or pie-shaped segment, with configurable cutout ratio as well as customizable start and end angles to define the arc's length as the absolute difference between the two angles. The arc is always centered on its position. The arc is drawn from StartAngle to EndAngle (in degrees, positive is clockwise, negative is counter-clockwise). 0°/360 is top, 90° is right, 180° is bottom, 270° is left 0°/-360 is top, -90° is left, -180° is bottom, -270° is right
Since: 1.0
func NewArc ¶
NewArc returns a new Arc instance with the specified start and end angles (in degrees), fill color and cutout ratio.
func NewDoughnutArc ¶
NewDoughnutArc returns a new doughnut-shaped Arc instance with the specified start and end angles (in degrees), fill color and cutout ratio set to 0.5.
func NewPieArc ¶
NewPieArc returns a new pie-shaped Arc instance with the specified start and end angles (in degrees), fill color and cutout ratio set to 0.
func (*Arc) Move ¶
Move the arc to a new position, relative to its parent / canvas. The position specifies the **center** of the arc.
func (*Arc) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Arc) Refresh ¶
func (a *Arc) Refresh()
Refresh causes this arc to be redrawn with its configured state.
func (*Arc) Resize ¶
Resize updates the logical size of the arc. The arc is always drawn centered on its Position().
func (*Arc) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Arc) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type AxisConfig3D ¶
type AxisConfig3D struct {
Label string
Min, Max float32
Ticks int // number of tick marks (default 5)
Color color.Color
}
AxisConfig3D configures one axis of a 3D chart.
type BackdropBlur ¶
type BackdropBlur struct {
// BlurRadius is the blur radius in logical pixels, as for BoxShadow: the
// content behind is blurred by a Gaussian of sigma BlurRadius/2.
BlurRadius float32
// contains filtered or unexported fields
}
BackdropBlur is a canvas object that captures the content behind it, applies a Gaussian blur, and renders the blurred result as a background.
WARNING: This uses GPU readback (ReadPixels) which is expensive. Use sparingly — one or two BackdropBlur objects per window is fine, but many will impact frame rate.
The blurred content is cached and only re-captured when Refresh() is called.
func NewBackdropBlur ¶
func NewBackdropBlur(radius float32) *BackdropBlur
NewBackdropBlur creates a backdrop blur canvas object.
func (*BackdropBlur) Hide ¶
func (b *BackdropBlur) Hide()
Hide will set this backdrop blur to not be visible.
func (*BackdropBlur) MinSize ¶
func (b *BackdropBlur) MinSize() geo.Size
MinSize returns the minimum size — backdrop blur has no inherent size.
func (*BackdropBlur) Move ¶
func (b *BackdropBlur) Move(pos geo.Position)
Move the backdrop blur to a new position, relative to its parent.
func (*BackdropBlur) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*BackdropBlur) Refresh ¶
func (b *BackdropBlur) Refresh()
Refresh marks this backdrop blur for re-capture on the next frame.
func (*BackdropBlur) Resize ¶
func (b *BackdropBlur) Resize(s geo.Size)
Resize sets a new size for the backdrop blur.
func (*BackdropBlur) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*BackdropBlur) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type BoxShadow ¶
type BoxShadow struct {
// Color is the shadow base color (typically black with some alpha).
Color color.Color
// BlurRadius is the blur radius in logical pixels, as in CSS box-shadow:
// the shadow is blurred by a Gaussian of sigma BlurRadius/2, so its edge
// fades over about BlurRadius either side. Larger values produce softer,
// more spread-out shadows.
BlurRadius float32
// OffsetX and OffsetY shift the shadow relative to the widget.
OffsetX, OffsetY float32
// CornerRadius matches the parent widget's corner rounding.
CornerRadius float32
// contains filtered or unexported fields
}
BoxShadow is a canvas object that renders a blurred shadow behind a widget. When the GL painter supports FBO blur, this produces a soft Gaussian-blurred shadow. On software painters or when FBO is unavailable, it falls back to a solid colored rectangle with reduced opacity.
func NewBoxShadow ¶
NewBoxShadow creates a new box shadow with the given color and blur radius.
func (*BoxShadow) MinSize ¶
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*BoxShadow) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*BoxShadow) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*BoxShadow) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type Camera3D ¶
type Camera3D struct {
Position Vec3 // camera position in world space
Target Vec3 // point the camera looks at
Up Vec3 // up direction (usually {0, 1, 0})
FOV float32 // field of view in degrees (default 45)
Near float32 // near clipping plane (default 0.1)
Far float32 // far clipping plane (default 1000)
}
Camera3D defines the viewpoint for a 3D scene.
func DefaultCamera ¶
func DefaultCamera() Camera3D
DefaultCamera returns a camera with sensible defaults.
type Circle ¶
type Circle struct {
Position1 geo.Position // The current top-left position of the Circle
Position2 geo.Position // The current bottomright position of the Circle
Hidden bool // Is this circle currently hidden
FillColor color.Color // The circle fill color
StrokeColor color.Color // The circle stroke color
StrokeWidth float32 // The stroke width of the circle
// contains filtered or unexported fields
}
Circle describes a colored circle primitive in a Bellui canvas
func (*Circle) MinSize ¶
MinSize for a Circle simply returns Size{1, 1} as there is no explicit content
func (*Circle) Position ¶
Position gets the current top-left position of this circle object, relative to its parent / canvas
func (*Circle) Refresh ¶
func (c *Circle) Refresh()
Refresh causes this object to be redrawn with its configured state.
func (*Circle) Resize ¶
Resize sets a new bottom-right position for the circle object If it has a stroke width this will cause it to Refresh.
func (*Circle) SetTransform ¶
SetTransform sets the local affine transform for this circle. Use geo.Identity to clear the transform.
type Face ¶
type Face struct {
A, B, C int // indices into Mesh3D.Vertices
}
Face defines a triangle by three vertex indices.
type GLAttribute ¶
type GLAttribute int32
GL handle types — thin wrappers over the underlying integer types used by OpenGL.
Experimental: these, GLContext, GLView and the GL_* constants below are not covered by the compatibility promise and may change or be removed. See GLView for why.
type GLBuffer ¶
type GLBuffer uint32
GL handle types — thin wrappers over the underlying integer types used by OpenGL.
Experimental: these, GLContext, GLView and the GL_* constants below are not covered by the compatibility promise and may change or be removed. See GLView for why.
type GLContext ¶
type GLContext interface {
// Texture operations
CreateTexture() GLTexture
DeleteTexture(texture GLTexture)
ActiveTexture(textureUnit uint32)
BindTexture(target uint32, texture GLTexture)
TexImage2D(target uint32, level, width, height int, colorFormat, typ uint32, data []uint8)
TexSubImage2D(target uint32, level, x, y, width, height int, colorFormat, typ uint32, data []uint8)
TexParameteri(target, param uint32, value int32)
// Buffer operations
CreateBuffer() GLBuffer
DeleteBuffer(buffer GLBuffer)
BindBuffer(target uint32, buf GLBuffer)
BufferData(target uint32, points []float32, usage uint32)
BufferSubData(target uint32, points []float32)
// Shader operations
CreateShader(typ uint32) GLShader
CompileShader(shader GLShader)
ShaderSource(shader GLShader, source string)
GetShaderi(shader GLShader, param uint32) int
GetShaderInfoLog(shader GLShader) string
// Program operations
CreateProgram() GLProgram
AttachShader(program GLProgram, shader GLShader)
LinkProgram(program GLProgram)
GetProgrami(program GLProgram, param uint32) int
GetProgramInfoLog(program GLProgram) string
UseProgram(program GLProgram)
// Vertex attributes
GetAttribLocation(program GLProgram, name string) GLAttribute
EnableVertexAttribArray(attribute GLAttribute)
VertexAttribPointerWithOffset(attribute GLAttribute, size int, typ uint32, normalized bool, stride, offset int)
// Uniforms
GetUniformLocation(program GLProgram, name string) GLUniform
Uniform1f(uniform GLUniform, v float32)
Uniform2f(uniform GLUniform, v0, v1 float32)
Uniform3f(uniform GLUniform, v0, v1, v2 float32)
Uniform4f(uniform GLUniform, v0, v1, v2, v3 float32)
UniformMatrix3fv(uniform GLUniform, value [9]float32)
UniformMatrix4fv(uniform GLUniform, value [16]float32)
// Drawing
DrawArrays(mode uint32, first, count int)
Viewport(x, y, width, height int)
Clear(mask uint32)
ClearColor(r, g, b, a float32)
// Blending
BlendFunc(srcFactor, destFactor uint32)
BlendColor(r, g, b, a float32)
// Clipping
Scissor(x, y, w, h int32)
Enable(capability uint32)
Disable(capability uint32)
// Framebuffer objects
CreateFramebuffer() GLFramebuffer
DeleteFramebuffer(fb GLFramebuffer)
BindFramebuffer(target uint32, fb GLFramebuffer)
FramebufferTexture2D(target, attachment uint32, texture GLTexture, level int32)
CheckFramebufferStatus(target uint32) uint32
// Stencil
ClearStencil(s int32)
StencilFunc(fn uint32, ref int32, mask uint32)
StencilOp(sfail, dpfail, dppass uint32)
StencilMask(mask uint32)
ColorMask(r, g, b, a bool)
// Pixel readback
ReadBuffer(src uint32)
ReadPixels(x, y, width, height int, colorFormat, typ uint32, pixels []uint8)
// Error
GetError() uint32
}
GLContext provides access to OpenGL operations during a GLView render callback. It is only valid for the duration of the callback — do not store references.
Experimental: not covered by the compatibility promise and may change or be removed. This interface is the largest part of that promise — sixty-odd methods mirroring the OpenGL API — and it can only ever be implemented by a painter that has an OpenGL context. See GLView.
type GLFramebuffer ¶
type GLFramebuffer uint32
GL handle types — thin wrappers over the underlying integer types used by OpenGL.
Experimental: these, GLContext, GLView and the GL_* constants below are not covered by the compatibility promise and may change or be removed. See GLView for why.
type GLProgram ¶
type GLProgram uint32
GL handle types — thin wrappers over the underlying integer types used by OpenGL.
Experimental: these, GLContext, GLView and the GL_* constants below are not covered by the compatibility promise and may change or be removed. See GLView for why.
type GLShader ¶
type GLShader uint32
GL handle types — thin wrappers over the underlying integer types used by OpenGL.
Experimental: these, GLContext, GLView and the GL_* constants below are not covered by the compatibility promise and may change or be removed. See GLView for why.
type GLTexture ¶
type GLTexture uint32
GL handle types — thin wrappers over the underlying integer types used by OpenGL.
Experimental: these, GLContext, GLView and the GL_* constants below are not covered by the compatibility promise and may change or be removed. See GLView for why.
type GLUniform ¶
type GLUniform int32
GL handle types — thin wrappers over the underlying integer types used by OpenGL.
Experimental: these, GLContext, GLView and the GL_* constants below are not covered by the compatibility promise and may change or be removed. See GLView for why.
type GLView ¶
type GLView struct {
// Render is called on the GL thread during each paint. The viewport
// is pre-configured to this view's screen area. The context is only
// valid for the duration of the callback.
Render func(ctx GLContext, width, height int, pixelScale float32)
// contains filtered or unexported fields
}
GLView is a canvas object that renders custom OpenGL content. The Render callback is invoked on the GL thread during the paint phase with the viewport set to the view's pixel bounds. The callback receives a GLContext for issuing GL commands, the pixel dimensions, and the display scale factor.
GLView requires the GL painter ¶
It hands the application a live OpenGL context and lets it draw into the window's GL framebuffer, so it only works under the GL painter — built with -tags gl, and the default on targets that have no WebGPU backend. The WebGPU painter, which is the default on desktop, has no OpenGL context to hand out: a GLView placed there draws nothing and reports why, once, to the error log (#213).
For GPU-drawn content that works under every painter, use Scene3D: it describes meshes, a camera and lights declaratively rather than issuing GL calls, and every painter can draw it.
Experimental ¶
GLView, GLContext, the GL handle types and the GL_* constants are **not covered by the compatibility promise** and may change or be removed.
The reason is above: this is an escape hatch bound to one painter, and the painter it is bound to is not the default. Promising its shape would freeze GLContext's sixty-odd methods for the life of the major version, in exchange for an API that a default-configured app cannot use. A portable custom-draw surface is the intended replacement if a consumer needs one; until then Scene3D, a streaming Raster and the built-in GPU effects cover the ground between them.
func NewGLView ¶
NewGLView creates a new GLView with the given render callback.
Experimental: see GLView.
func (*GLView) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*GLView) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*GLView) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type GradientStop ¶
GradientStop defines a color at a specific position in a multi-stop gradient.
type Image ¶
type Image struct {
// one of the following sources will provide our image data
File string // Load the image from a file
Resource bellui.Resource // Load the image from an in-memory resource
Image image.Image // Specify a loaded image to use in this canvas object
Translucency float64 // Set a translucency value > 0.0 to fade the image
FillMode ImageFill // Specify how the image should expand to fill or fit the available space
ScaleMode ImageScale // Specify the type of scaling interpolation applied to the image
// CornerRadius specifies a radius to apply to round corners of the image.
//
// Since: 1.0
CornerRadius float32
// contains filtered or unexported fields
}
Image describes a drawable image area that can render in a Bellui canvas The image may be a vector or a bitmap representation, it will fill the area. The fill mode can be changed by setting FillMode to a different ImageFill.
func NewImageFromFile ¶
NewImageFromFile creates a new image from a local file. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
func NewImageFromImage ¶
NewImageFromImage returns a new Image instance that is rendered from the Go image.Image passed in. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
func NewImageFromReader ¶
NewImageFromReader creates a new image from a data stream. The name parameter is required to uniquely identify this image (for caching etc.). If the image in this io.Reader is an SVG, the name should end ".svg". Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
Since: 1.0
func NewImageFromResource ¶
NewImageFromResource creates a new image by loading the specified resource. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
func NewImageFromURI ¶
NewImageFromURI creates a new image from named resource. File URIs will read the file path and other schemes will download the data into a resource. HTTP and HTTPs URIs will use the GET method by default to request the resource. Images returned from this method will scale to fit the canvas object. The method for scaling can be set using the Fill field.
Since: 1.0
func (*Image) Alpha ¶
Alpha is a convenience function that returns the alpha value for an image based on its Translucency value. The result is 1.0 - Translucency.
func (*Image) Aspect ¶
Aspect will return the original content aspect after it was last refreshed. Aspect is safe for concurrent use.
Since: 1.0
func (*Image) Move ¶
Move the image object to a new position, relative to its parent top, left corner.
func (*Image) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Image) Refresh ¶
func (i *Image) Refresh()
Refresh causes this image to be redrawn with its configured state.
func (*Image) Resize ¶
Resize on an image will scale the content or reposition it according to FillMode. It will normally cause a Refresh to ensure the pixels are recalculated.
func (*Image) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Image) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type ImageFill ¶
type ImageFill int
ImageFill defines the different type of ways an image can stretch to fill its space.
const ( // ImageFillStretch will scale the image to match the Size() values. // This is the default and does not maintain aspect ratio. ImageFillStretch ImageFill = iota // ImageFillContain makes the image fit within the object Size(), // centrally and maintaining aspect ratio. // There may be transparent sections top and bottom or left and right. ImageFillContain // (Fit) // ImageFillOriginal ensures that the container grows to the pixel dimensions // required to fit the original image. The aspect of the image will be maintained so, // as with ImageFillContain there may be transparent areas around the image. // Note that the minSize may be smaller than the image dimensions if scale > 1. ImageFillOriginal // ImageFillCover maintains the image aspect ratio whilst filling the space. // The image content will be centered on the available space meaning that an equal amount of top and bottom // or left and right will be clipped if the output aspect ratio does not match the source image. // Since: 1.0 ImageFillCover )
type ImageScale ¶
type ImageScale int32
ImageScale defines the different scaling filters used to scaling images
const ( // ImageScaleSmooth will scale the image using ApproxBiLinear filter (or GL equivalent) ImageScaleSmooth ImageScale = iota // ImageScalePixels will scale the image using NearestNeighbor filter (or GL equivalent) ImageScalePixels // ImageScaleFastest will scale the image using hardware GPU if available // // Since: 1.0 ImageScaleFastest )
type Keyframe ¶
type Keyframe struct {
Progress float32 // 0.0 to 1.0
Value float32 // value at this keyframe
Curve bellui.AnimationCurve // easing from previous keyframe to this one; nil = linear
}
Keyframe defines a value at a specific point in an animation's progress. The Curve field specifies the easing from the previous keyframe to this one; nil means linear interpolation for that segment.
type Light3D ¶
type Light3D struct {
Direction Vec3 // light direction (normalized)
Color color.Color // light color
Ambient float32 // ambient factor [0, 1]
}
Light3D defines a directional light source.
func DefaultLight ¶
func DefaultLight() Light3D
DefaultLight returns a light with sensible defaults.
type Line ¶
type Line struct {
Position1 geo.Position // The current top-left position of the Line
Position2 geo.Position // The current bottom-right position of the Line
Hidden bool // Is this Line currently hidden
StrokeColor color.Color // The line stroke color
StrokeWidth float32 // The stroke width of the line
// contains filtered or unexported fields
}
Line describes a colored line primitive in a Bellui canvas. Lines are special as they can have a negative width or height to indicate an inverse slope (i.e. slope up vs down).
func (*Line) Position ¶
Position gets the current top-left position of this line object, relative to its parent / canvas
func (*Line) Refresh ¶
func (l *Line) Refresh()
Refresh causes this line to be redrawn with its configured state.
func (*Line) Resize ¶
Resize sets a new bottom-right position for the line object, then it will then be refreshed.
func (*Line) SetTransform ¶
SetTransform sets the local affine transform for this line. Use geo.Identity to clear the transform.
type LineCap ¶
type LineCap uint8
LineCap defines the shape at the endpoints of an open path stroke.
type LineJoin ¶
type LineJoin uint8
LineJoin defines the shape at the junction of two path segments.
type LinearGradient ¶
type LinearGradient struct {
StartColor color.Color // The beginning color of the gradient
EndColor color.Color // The end color of the gradient
Angle float64 // The angle of the gradient (0/180 for vertical; 90/270 for horizontal)
// Stops defines a multi-stop gradient. When non-empty, StartColor and EndColor are ignored.
// Stops must be sorted by Position (0.0 to 1.0).
Stops []GradientStop
// contains filtered or unexported fields
}
LinearGradient defines a Gradient travelling straight at a given angle. The only supported values for the angle are `0.0` (vertical) and `90.0` (horizontal), currently.
func NewHorizontalGradient ¶
func NewHorizontalGradient(start, end color.Color) *LinearGradient
NewHorizontalGradient creates a new horizontally travelling linear gradient. The start color will be at the left of the gradient and the end color will be at the right.
func NewLinearGradient ¶
func NewLinearGradient(start, end color.Color, angle float64) *LinearGradient
NewLinearGradient creates a linear gradient at the specified angle. The angle parameter is the degree angle along which the gradient is calculated. A NewHorizontalGradient uses 270 degrees and NewVerticalGradient is 0 degrees.
func NewVerticalGradient ¶
func NewVerticalGradient(start color.Color, end color.Color) *LinearGradient
NewVerticalGradient creates a new vertically travelling linear gradient. The start color will be at the top of the gradient and the end color will be at the bottom.
func (*LinearGradient) Generate ¶
func (g *LinearGradient) Generate(iw, ih int) image.Image
Generate calculates an image of the gradient with the specified width and height.
func (*LinearGradient) Hide ¶
func (g *LinearGradient) Hide()
Hide will set this gradient to not be visible
func (*LinearGradient) MinSize ¶
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*LinearGradient) Move ¶
func (g *LinearGradient) Move(pos geo.Position)
Move the gradient to a new position, relative to its parent / canvas
func (*LinearGradient) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*LinearGradient) Refresh ¶
func (g *LinearGradient) Refresh()
Refresh causes this gradient to be redrawn with its configured state.
func (*LinearGradient) Resize ¶
func (g *LinearGradient) Resize(size geo.Size)
Resize resizes the gradient to a new size.
func (*LinearGradient) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*LinearGradient) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
func (*LinearGradient) Show ¶
func (o *LinearGradient) Show()
Show will set this object to be visible.
type Mat4 ¶
type Mat4 [16]float32
Mat4 is a 4x4 matrix in column-major order.
func LookAtMatrix ¶
LookAtMatrix builds a view matrix from eye position, center/target, and up vector.
func PerspectiveMatrix ¶
PerspectiveMatrix builds a perspective projection matrix. fovDeg is the vertical field of view in degrees, aspect is width/height.
type Mesh3D ¶
type Mesh3D struct {
Vertices []Vec3
Faces []Face
FillColor color.Color
// FaceColors overrides FillColor per-face (if len matches Faces).
FaceColors []color.Color
}
Mesh3D defines a 3D mesh with vertices, faces, and colors.
type OrbitCamera ¶
type OrbitCamera struct {
Target Vec3 // point to orbit around
Distance float32 // distance from target
Theta float32 // horizontal angle in radians (azimuth)
Phi float32 // vertical angle in radians (elevation), clamped to avoid poles
Up Vec3
// MinDistance and MaxDistance bound [OrbitCamera.Zoom]. Either left at or
// below zero falls back to its default — 0.5 and 100 respectively — so a
// zero-value OrbitCamera zooms exactly as it always has. Set them for a
// scene authored at a different scale, where the defaults would snap the
// camera to a limit on the first zoom.
MinDistance float32
MaxDistance float32
}
OrbitCamera provides orbit controls for a Camera3D: rotate around a target and zoom in/out by changing the distance.
func NewOrbitCamera ¶
func NewOrbitCamera(cam Camera3D) *OrbitCamera
NewOrbitCamera creates an OrbitCamera from a Camera3D position and target.
A camera positioned outside the default zoom range gets limits scaled to its own distance, so orbiting a large or a miniature scene does not yank the camera to a limit the moment the user zooms.
func (*OrbitCamera) Camera ¶
func (o *OrbitCamera) Camera(fov, near, far float32) Camera3D
Camera returns the Camera3D corresponding to the current orbit state.
Non-positive fov, near and far resolve to defaults; the near default scales with the orbit distance in both directions, while the far default only grows with it. Callers that feed a resolved Near or Far back into the next call freeze that default at its first value — keep passing zero (or an explicit choice) to let it track the zoom.
func (*OrbitCamera) Rotate ¶
func (o *OrbitCamera) Rotate(dTheta, dPhi float32)
Rotate adjusts the orbit angles by the given deltas (in radians).
func (*OrbitCamera) Zoom ¶
func (o *OrbitCamera) Zoom(factor float32)
Zoom changes the distance from the target by a factor, bounded by OrbitCamera.MinDistance and OrbitCamera.MaxDistance. factor > 1 zooms out, factor < 1 zooms in.
type Path ¶
type Path struct {
FillColor color.Color // The path fill color
FillRule FillRule // The fill rule (even-odd or winding)
StrokeColor color.Color // The path stroke color
StrokeWidth float32 // The stroke width
LineCap LineCap // The stroke cap style
LineJoin LineJoin // The stroke join style
MiterLimit float32 // The miter limit for miter joins (0 uses default of 4)
DashPattern []float32 // The stroke dash pattern (alternating dash/gap lengths)
DashOffset float32 // The starting offset into the dash pattern
// contains filtered or unexported fields
}
Path describes an arbitrary 2D vector path in a Bellui canvas. It supports fill, stroke with configurable width/caps/joins/dashes, and is rendered through the GPU pipeline.
func (*Path) Bounds ¶
Bounds returns the axis-aligned bounding box of the path's control points as (minX, minY, maxX, maxY) in path-local coordinates.
func (*Path) Close ¶
func (p *Path) Close()
Close closes the current subpath by drawing a straight line back to the starting point of the subpath.
func (*Path) CubicTo ¶
CubicTo adds a cubic Bezier curve from the current point, with control points (cx1, cy1), (cx2, cy2) and endpoint (x, y).
func (*Path) Elements ¶
func (p *Path) Elements() []PathElement
Elements returns the path elements. The returned slice must not be modified.
func (*Path) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Path) QuadTo ¶
QuadTo adds a quadratic Bezier curve from the current point, with control point (cx, cy) and endpoint (x, y).
func (*Path) Refresh ¶
func (p *Path) Refresh()
Refresh causes this path to be redrawn with its configured state.
func (*Path) Reset ¶
func (p *Path) Reset()
Reset clears all path commands, restoring the path to an empty state.
func (*Path) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Path) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type PathCommand ¶
type PathCommand uint8
PathCommand identifies a path drawing command.
const ( // PathMoveTo begins a new subpath at the given point. PathMoveTo PathCommand = iota // PathLineTo adds a straight line from the current point. PathLineTo // PathQuadTo adds a quadratic Bezier curve from the current point. PathQuadTo // PathCubicTo adds a cubic Bezier curve from the current point. PathCubicTo // PathClose closes the current subpath with a straight line back to the start. PathClose )
type PathElement ¶
type PathElement struct {
// contains filtered or unexported fields
}
PathElement stores a single path command with its control points.
type Polygon ¶
type Polygon struct {
FillColor color.Color // The polygon fill color
StrokeColor color.Color // The polygon stroke color
StrokeWidth float32 // The stroke width of the polygon
CornerRadius float32 // The radius of the polygon corners
Angle float32 // Angle of polygon, in degrees (positive means clockwise, negative means counter-clockwise direction).
Sides uint // Amount of sides of polygon.
// contains filtered or unexported fields
}
Polygon describes a colored regular polygon primitive in a Bellui canvas. The rendered portion will be in the center of the available space.
Since: 1.0
func NewPolygon ¶
NewPolygon returns a new Polygon instance
func (*Polygon) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Polygon) Refresh ¶
func (r *Polygon) Refresh()
Refresh causes this polygon to be redrawn with its configured state.
func (*Polygon) Resize ¶
Resize on a polygon updates the new size of this object. If it has a stroke width this will cause it to Refresh.
func (*Polygon) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Polygon) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type PositionKeyframe ¶
type PositionKeyframe struct {
Progress float32
Value geo.Position
Curve bellui.AnimationCurve // easing from previous keyframe to this one; nil = linear
}
PositionKeyframe defines a position at a specific point in an animation's progress.
type RadialGradient ¶
type RadialGradient struct {
StartColor color.Color // The beginning color of the gradient
EndColor color.Color // The end color of the gradient
// The offset of the center for generation of the gradient.
// This is not a DP measure but relates to the width/height.
// A value of 0.5 would move the center by the half width/height.
CenterOffsetX, CenterOffsetY float64
// Stops defines a multi-stop gradient. When non-empty, StartColor and EndColor are ignored.
Stops []GradientStop
// contains filtered or unexported fields
}
RadialGradient defines a Gradient travelling radially from a center point outward.
func NewRadialGradient ¶
func NewRadialGradient(start, end color.Color) *RadialGradient
NewRadialGradient creates a new radial gradient.
func (*RadialGradient) Generate ¶
func (g *RadialGradient) Generate(iw, ih int) image.Image
Generate calculates an image of the gradient with the specified width and height.
func (*RadialGradient) Hide ¶
func (g *RadialGradient) Hide()
Hide will set this gradient to not be visible
func (*RadialGradient) MinSize ¶
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*RadialGradient) Move ¶
func (g *RadialGradient) Move(pos geo.Position)
Move the gradient to a new position, relative to its parent / canvas
func (*RadialGradient) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*RadialGradient) Refresh ¶
func (g *RadialGradient) Refresh()
Refresh causes this gradient to be redrawn with its configured state.
func (*RadialGradient) Resize ¶
func (g *RadialGradient) Resize(size geo.Size)
Resize resizes the gradient to a new size.
func (*RadialGradient) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*RadialGradient) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
func (*RadialGradient) Show ¶
func (o *RadialGradient) Show()
Show will set this object to be visible.
type Raster ¶
type Raster struct {
// Render the raster image from code
Generator func(w, h int) image.Image
// Set a translucency value > 0.0 to fade the raster
Translucency float64
// Specify the type of scaling interpolation applied to the raster if it is not full-size
// Since: 1.0
ScaleMode ImageScale
// Streaming enables in-place texture updates.
// When true, Refresh() reuses the existing GPU texture — uploading only the
// new pixels — instead of deleting and recreating it on every frame. Ideal
// for video playback. Honoured by the GL and WebGPU painters; the software
// painter re-draws the current pixels each paint, so Streaming is a no-op
// there rather than a behaviour change.
Streaming bool
// StreamMu protects the streaming pixel fields (StreamPix, StreamPixW,
// StreamPixH, StreamTexW, StreamTexH) from concurrent access between
// SetPixels (user goroutine) and the GL painter thread.
StreamMu sync.Mutex
// StreamPix holds raw premultiplied-RGBA pixel data set via SetPixels.
// Read by the painter; do not set directly — use SetPixels.
StreamPix []byte
// StreamPixW and StreamPixH are the dimensions of StreamPix data.
StreamPixW, StreamPixH int
// StreamTexW and StreamTexH track the allocated GL texture dimensions.
// Managed by the painter to detect size changes.
StreamTexW, StreamTexH int
// contains filtered or unexported fields
}
Raster describes a raster image area that can render in a Bellui canvas
func NewRaster ¶
NewRaster returns a new Image instance that is rendered dynamically using the specified generate function. Images returned from this method should draw dynamically to fill the width and height parameters passed to pixelColor.
func NewRasterFromImage ¶
NewRasterFromImage returns a new Raster instance that is rendered from the Go image.Image passed in. Rasters returned from this method will map pixel for pixel to the screen starting img.Bounds().Min pixels from the top left of the canvas object. Truncates rather than scales the image. If smaller than the target space, the image will be padded with zero-pixels to the target size.
func NewRasterWithPixels ¶
NewRasterWithPixels returns a new Image instance that is rendered dynamically by iterating over the specified pixelColor function for each x, y pixel. Images returned from this method should draw dynamically to fill the width and height parameters passed to pixelColor.
func (*Raster) Alpha ¶
Alpha is a convenience function that returns the alpha value for a raster based on its Translucency value. The result is 1.0 - Translucency.
func (*Raster) PixelImage ¶
PixelImage returns the raster's current content at the requested size: the data supplied by Raster.SetPixels when there is any, otherwise the output of Generator. It returns nil when the raster has neither, so painters can skip an empty raster instead of dereferencing a nil Generator.
The pixel data is copied, so the caller may keep the result after the next SetPixels call. Painters with an in-place upload path should read StreamPix under StreamMu directly rather than pay for that copy every frame.
Since: 1.0
func (*Raster) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Raster) Refresh ¶
func (r *Raster) Refresh()
Refresh causes this raster to be redrawn with its configured state.
func (*Raster) Resize ¶
Resize on a raster image causes the new size to be set and then calls Refresh. This causes the underlying data to be recalculated and a new output to be drawn.
func (*Raster) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Raster) SetPixels ¶
SetPixels updates the raster's pixel data directly with raw RGBA bytes. The provided data must be premultiplied RGBA with 4 bytes per pixel, and width*height*4 must equal len(pix). This is the fastest path for video frame updates when Streaming is true. It automatically calls Refresh to trigger a repaint.
A raster driven purely by SetPixels needs no Generator: every painter reads the supplied pixels in preference to it. Until the first SetPixels call such a raster simply has no content and draws nothing.
func (*Raster) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type Rectangle ¶
type Rectangle struct {
FillColor color.Color // The rectangle fill color
StrokeColor color.Color // The rectangle stroke color
StrokeWidth float32 // The stroke width of the rectangle
// The radius of the rectangle corners
//
// Since: 1.0
CornerRadius float32
// Enforce an aspect ratio for the rectangle, the content will be made shorter or narrower
// to meet the requested aspect, if set.
//
// Since: 1.0
Aspect float32
// The radius of the rectangle top-right corner only.
//
// Since: 1.0
TopRightCornerRadius float32
// The radius of the rectangle top-left corner only.
//
// Since: 1.0
TopLeftCornerRadius float32
// The radius of the rectangle bottom-right corner only.
//
// Since: 1.0
BottomRightCornerRadius float32
// The radius of the rectangle bottom-left corner only.
//
// Since: 1.0
BottomLeftCornerRadius float32
// contains filtered or unexported fields
}
Rectangle describes a colored rectangle primitive in a Bellui canvas
func NewRectangle ¶
NewRectangle returns a new Rectangle instance
func NewSquare ¶
NewSquare returns a new Rectangle instance that has a square aspect ratio.
Since: 1.0
func (*Rectangle) MinSize ¶
MinSize returns the specified minimum size, if set, or {1, 1} otherwise.
func (*Rectangle) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Rectangle) Refresh ¶
func (r *Rectangle) Refresh()
Refresh causes this rectangle to be redrawn with its configured state.
func (*Rectangle) Resize ¶
Resize on a rectangle updates the new size of this object. If it has a stroke width this will cause it to Refresh. If Aspect is non-zero it may cause the rectangle to be smaller than the requested size.
func (*Rectangle) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Rectangle) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type Ripple ¶
type Ripple struct {
// Center is the ripple origin relative to the widget's top-left.
Center geo.Position
// Radius is the current ripple radius in logical pixels (animated).
Radius float32
// Color is the ripple overlay color (typically the widget's content color).
Color color.Color
// Opacity is the current ripple opacity (0.0–1.0, animated).
Opacity float32
// CornerRadius is the corner radius for SDF clipping to the parent shape.
CornerRadius float32
// contains filtered or unexported fields
}
Ripple is a canvas object that renders a radial ripple effect from a center point, clipped to a rounded rectangle shape. It is used for MD3-style touch feedback on interactive widgets.
func (*Ripple) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Ripple) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Ripple) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type Scene3D ¶
type Scene3D struct {
Camera Camera3D
Meshes []Mesh3D
Lights []Light3D
// Background color for the scene (default transparent).
Background color.Color
// BackfaceCulling, when true, skips triangles whose normals face away from
// the camera. When false (default), both sides of every triangle are rendered
// with correct lighting (normals are flipped toward the viewer).
BackfaceCulling bool
// contains filtered or unexported fields
}
Scene3D is a canvas object that renders a 3D scene using software rasterization. It contains meshes, a camera, and lights, and produces a 2D image via perspective projection and z-buffering. It integrates with the Bellui rendering pipeline as a standard CanvasObject.
Since: 1.0
func NewScene3D ¶
func NewScene3D() *Scene3D
NewScene3D creates a Scene3D with a default camera and light.
Since: 1.0
func (*Scene3D) AddAxes ¶
func (s *Scene3D) AddAxes(xCfg, yCfg, zCfg AxisConfig3D)
AddAxes adds X, Y, Z axis lines with tick marks and ground grid to the scene.
func (*Scene3D) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Scene3D) SetMinSize ¶
SetMinSize specifies the smallest size this object should be.
func (*Scene3D) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type SpringConfig ¶
type SpringConfig struct {
Stiffness float32 // spring constant (default 170)
Damping float32 // damping coefficient (default 26)
Mass float32 // mass (default 1)
MaxDuration time.Duration // safety duration cap (default 2s)
}
SpringConfig configures the physics of a spring animation. Default values are applied for zero fields: Stiffness=170, Damping=26, Mass=1, MaxDuration=2s.
type StaggeredEntry ¶
StaggeredEntry pairs an animation with a start delay for use with NewStaggeredAnimation.
type StyledText ¶
type StyledText struct {
Alignment bellui.TextAlign // The alignment of the text content
Color color.Color // The default text draw color (used when a run's Color is nil)
TextSize float32 // The default font size (used when a run's TextSize is 0)
Runs []TextRun // The styled text runs
// contains filtered or unexported fields
}
StyledText describes multi-styled inline text in a Bellui canvas. Each run can have independent color, size, style, and font. This is a single-line primitive; use widget.RichText for wrapping.
Since: 1.0
func NewStyledText ¶
func NewStyledText(runs []TextRun, defaultColor color.Color) *StyledText
NewStyledText returns a new StyledText with the given runs and default color.
Since: 1.0
func (*StyledText) MinSize ¶
func (st *StyledText) MinSize() geo.Size
MinSize returns the minimum size of this styled text based on font sizes and content.
func (*StyledText) Move ¶
func (st *StyledText) Move(pos geo.Position)
Move the styled text to a new position, relative to its parent / canvas.
func (*StyledText) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*StyledText) Refresh ¶
func (st *StyledText) Refresh()
Refresh causes this styled text to be redrawn with its configured state.
func (*StyledText) Resize ¶
func (st *StyledText) Resize(s geo.Size)
Resize updates the size of this object.
func (*StyledText) SetMinSize ¶
func (st *StyledText) SetMinSize(geo.Size)
SetMinSize has no effect as the smallest size is based on font sizes and content.
func (*StyledText) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type Text ¶
type Text struct {
Alignment bellui.TextAlign // The alignment of the text content
Color color.Color // The main text draw color
Text string // The string content of this Text
TextSize float32 // Size of the text - if the Canvas scale is 1.0 this will be equivalent to point size
TextStyle bellui.TextStyle // The style of the text content
// SubPixel disables pixel-grid rounding of the text texture size during
// GL rendering. Enable this for precise positioning in data-visualization
// layouts where labels must sit at exact fractional coordinates.
SubPixel bool
// FontSource defines a resource that can be used instead of the theme for looking up the font.
// When a font source is set the `TextStyle` may not be effective, as it will be limited to the styles
// present in the data provided.
//
// Since: 1.0
FontSource bellui.Resource
// contains filtered or unexported fields
}
Text describes a text primitive in a Bellui canvas. A text object can have a style set which will apply to the whole string. No formatting or text parsing will be performed
func (*Text) MinSize ¶
MinSize returns the minimum size of this text object based on its font size and content. This is normally determined by the render implementation.
The measurement is memoised per object: while Text, TextSize, TextStyle and FontSource are unchanged (and the theme/font caches have not reset) the last result is returned without consulting the driver, so measure-heavy layouts do not re-hash unchanged strings through the global metrics cache (pre-rebrand tracker #923).
func (*Text) MinSizeWithBaseline ¶
MinSizeWithBaseline returns Text.MinSize together with the distance from the top of the text to its baseline, both served from the same per-object measurement memo.
Note that TextStyle is compared as a value: its pointer fields (Weight, LineHeightScale, LetterSpacing) are compared by pointer, so a caller mutating a pointee in place must assign a fresh pointer (or style) for the change to be measured.
Since: 1.0
func (*Text) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*Text) Refresh ¶
func (t *Text) Refresh()
Refresh causes this text to be redrawn with its configured state.
func (*Text) Resize ¶
Resize on a text updates the new size of this object, which may not result in a visual change, depending on alignment.
func (*Text) Rotation ¶
Rotation returns the rotation angle in degrees set by [SetRotation]. If the transform was set directly via [SetTransform], this returns 0.
func (*Text) SetMinSize ¶
SetMinSize has no effect as the smallest size this canvas object can be is based on its font size and content.
func (*Text) SetRotation ¶
SetRotation sets the rotation angle in degrees. The text is rotated around its visual center (half of the un-rotated MinSize). The rotation is recomputed automatically when the text content or size changes.
SetRotation and [SetTransform] are mutually exclusive — calling one clears the effect of the other.
func (*Text) SetTransform ¶
SetTransform sets an arbitrary affine transform and clears any rotation previously set via [SetRotation].
type TextOnPath ¶
type TextOnPath struct {
Color color.Color // The text draw color
Text string // The string content
TextSize float32 // Font size
TextStyle bellui.TextStyle // Style for the text
FontSource bellui.Resource // Custom font resource; nil means use theme font
// Offset is the starting distance along the path where text begins.
// Default 0 means text starts at the path's first point.
Offset float32
// BaselineShift moves glyphs perpendicular to the path direction.
// Positive values shift upward (away from the path's convex side).
// Default 0 places the text baseline on the path.
BaselineShift float32
// contains filtered or unexported fields
}
TextOnPath describes text that follows a path, with each glyph positioned and rotated along the path's arc length.
Since: 1.0
func NewTextOnPath ¶
func NewTextOnPath(text string, color color.Color, buildPath func(*TextOnPath)) *TextOnPath
NewTextOnPath creates a new TextOnPath and calls the build function to construct the path.
Since: 1.0
func (*TextOnPath) Close ¶
func (t *TextOnPath) Close()
Close closes the current subpath by drawing a straight line back to the starting point of the subpath.
func (*TextOnPath) CubicTo ¶
func (t *TextOnPath) CubicTo(cx1, cy1, cx2, cy2, x, y float32)
CubicTo adds a cubic Bezier curve from the current point, with control points (cx1, cy1), (cx2, cy2) and endpoint (x, y).
func (*TextOnPath) Elements ¶
func (t *TextOnPath) Elements() []PathElement
Elements returns the path elements. The returned slice must not be modified.
func (*TextOnPath) LineTo ¶
func (t *TextOnPath) LineTo(x, y float32)
LineTo adds a straight line segment from the current point to (x, y).
func (*TextOnPath) MinSize ¶
func (t *TextOnPath) MinSize() geo.Size
MinSize returns the minimum size based on the path bounds expanded by the text height (glyphs can extend beyond the path due to rotation).
func (*TextOnPath) Move ¶
func (t *TextOnPath) Move(pos geo.Position)
Move the text on path to a new position, relative to its parent / canvas.
func (*TextOnPath) MoveTo ¶
func (t *TextOnPath) MoveTo(x, y float32)
MoveTo begins a new subpath at the given point.
func (*TextOnPath) Position ¶
Position gets the current position of this canvas object, relative to its parent.
func (*TextOnPath) QuadTo ¶
func (t *TextOnPath) QuadTo(cx, cy, x, y float32)
QuadTo adds a quadratic Bezier curve from the current point, with control point (cx, cy) and endpoint (x, y).
func (*TextOnPath) Refresh ¶
func (t *TextOnPath) Refresh()
Refresh causes this text on path to be redrawn with its configured state.
func (*TextOnPath) Resize ¶
func (t *TextOnPath) Resize(s geo.Size)
Resize updates the size of this object.
func (*TextOnPath) SetMinSize ¶
func (t *TextOnPath) SetMinSize(geo.Size)
SetMinSize has no effect as the smallest size is based on the path and text content.
func (*TextOnPath) SetTransform ¶
SetTransform sets the local affine transform for this object. Use geo.Identity to clear the transform. SetTransform is safe for concurrent use.
type TextRun ¶
type TextRun struct {
Text string // The string content of this run
Color color.Color // Color for this run; nil means use StyledText.Color
TextSize float32 // Font size for this run; 0 means use StyledText.TextSize
TextStyle bellui.TextStyle // Style for this run
FontSource bellui.Resource // Custom font resource; nil means use theme font
}
TextRun defines a run of text with its own styling properties. Fields left at their zero value inherit from the parent StyledText.
Since: 1.0