Add text components 021-040 with demos and behavior tests

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 18:20:12 -04:00
1 parent 43098065bf
commit 59fde4096d
30 files changed
+1702 -7

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
package text
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type CodeOptions struct {
Slot pixel.Slot
}
// Code is an inline chip on Well, bordered in Edge.
func Code(c *ui.Context, s string, o CodeOptions) *ui.Element {
k := pixel.K(c)
return block(c, k, s, pixel.Measure(s)+6, pixel.LineHeight+2, func(g pixel.Canvas) {
g.Frame(0, 0, g.W, g.H, pixel.Flat, pixel.Well)
g.Text(3, 1, s, o.Slot, 1)
})
}