borderbeam

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Border Beam — 原生 Go

将 Border Beam 的五种模式移植到 Golet 原生 UI,不使用 React、WebView、JavaScript 或运行时 WGSL。

borderbeam.Box(c, borderbeam.Options{
    Preset: borderbeam.Medium,
    Palette: borderbeam.Colorful,
    Strength: 1,
    Radius: 16,
}).Padding(24).Background(c.Theme().Surface).Children(func() {
    ui.Text(c, "Give your ideas an edge.").Bold()
    ui.Button(c, "继续")
})
Preset 动画 默认周期
Medium 局部色场、旋转锥形遮罩、内辉光 1.96 秒
Small 小半径色斑与独立遮罩,适合紧凑按钮 1.96 秒
Line 沿底边移动的光束、两端淡出、光柱 3.1 秒
PulseInner 色斑位移、宽高呼吸、分区透明度变化 2.3 秒
PulseOutside 边框呼吸与向外扩散的双层辉光 2.3 秒

Palette 支持 Colorful、Ocean、Sunset、Mono,以及跟随主题的默认 Theme;Colors 可以覆盖色板。Duration 调节运动周期;色相使用独立周期。StaticColors 只固定色相,不停止运动。Brightness、Saturation、HueRange 可调节颜色。

动画按 30 FPS 请求定时重绘,不创建后台 goroutine。Paused 保留相位,恢复后继续;Disabled 隐藏并停止请求帧;系统减少动态效果自动静止;不可见的控件不请求动画帧。装饰不拦截内容的点击。PulseOutside 应预留约 60 DIP 外部空间,父容器若裁剪会截掉外发光。

Studio → 插件 → 边框光束提供五种模式切换、四组配色、暂停/继续、隐藏、周期、强度和内辉光范围,并跟随 Studio 明暗主题。

来源与实现边界

reference/beam-color.wgsl 与 reference/border-beam.css 保存上游参考快照;reference/LICENSE 保留 Jakub Antalik 与 Frad 的 MIT 署名。go generate ./backend/plugins/borderbeam 用 Go 生成器从 WGSL 提取原始色斑与色板数值。参考文件不嵌入应用。

field.go 移植二维径向色场和脉冲振荡;render.go 实现各模式遮罩及分层混合;blur.go 在复用缓冲区中执行降采样高斯模糊。细边框单独保留高分辨率采样。应用不引入 CEF 或额外运行库。

这是原生渲染移植,不承诺与浏览器逐像素一致:颜色滤镜、降采样模糊和浏览器合成存在差异;当前没有移植 DOM 激活/消失时的 CSS 淡入淡出。原生窗口 GPU 端的实机视觉对比仍需单独验证。测试覆盖五种动画的运行、暂停、恢复、减少动态效果、离屏停止和内容交互。

Documentation

Overview

Author: HyperparameterSI

Package borderbeam ports the five Border Beam presets to Golet native UI. Color fields, masks and Gaussian bloom run in Go without a browser runtime. Reference source and MIT attribution are in reference/.

Author: HyperparameterSI Port of Frad's WGSL color fields. See reference/LICENSE for upstream credits.

Author: HyperparameterSI Native composition of the reference color fields and CSS masks.

Code generated by go generate; DO NOT EDIT. Derived from Frad / Jakub Antalik border-beam; MIT, see reference/LICENSE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Box

func Box(c *ui.Context, o Options) ui.Element

Box creates a normal layout container with decorative light over its border. Children remain interactive and accessible. It follows reduced motion and only requests repaint frames while visible and animated. Use a stable Key on an enclosing element when showing several reorderable containers.

Types

type Mode

type Mode uint8

Mode selects the animation of the edge light.

const (
	// Rotate moves the highlight and palette around the perimeter.
	Rotate Mode = iota
	// Pulse selects PulseInner when Preset is Medium; retained for compatibility.
	Pulse
)

type Options

type Options struct {
	// Preset selects Medium, Small, Line, PulseInner, or PulseOutside.
	Preset Preset
	// Brightness and Saturation override reference defaults when positive.
	Brightness, Saturation float32
	// HueRange overrides the rotating presets' hue excursion in degrees.
	HueRange float32
	// StaticColors disables hue changes, while retaining spatial animation.
	StaticColors bool
	// Strength scales the light from 0 to 1; zero selects the default 0.7. Use Disabled to hide it.
	Strength float32
	// Glow is the inward mask depth in DIPs, default 28, maximum 48.
	Glow float32
	// Palette selects the built-in colors when Colors is empty.
	Palette Palette
	// Radius is the container's corner radius; defaults to 16.
	Radius float32
	// Width is the crisp border width; defaults to 1, limited to 8.
	Width float32
	// Duration is one animation cycle; defaults to the reference preset cycle.
	Duration time.Duration
	// Colors is a cyclic palette, copied when Box is built. Empty uses the theme accent.
	Colors []ui.Color
	// Mode selects Rotate (default) or Pulse.
	Mode Mode
	// Paused holds the current animation phase, resuming from it when cleared.
	Paused bool
	// Disabled removes the effect and stops requesting frames.
	Disabled bool
}

Options configure a border. Zero values select the defaults documented below. Dimensions are in DIPs. Allow at least 12 DIPs of padding for content. PulseOutside also needs surrounding space for its exterior glow.

type Palette

type Palette uint8

Palette selects a built-in set of edge lights.

const (
	// Theme uses the current accent color.
	Theme Palette = iota
	Colorful
	Ocean
	Sunset
	Mono
)

type Preset

type Preset uint8

Preset selects one of the five reference animations.

const (
	Medium Preset = iota
	Small
	Line
	PulseInner
	PulseOutside
)

Directories

Path Synopsis
internal
gen command

Jump to

Keyboard shortcuts

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