Add text components 021-040 with demos and behavior tests
This commit is contained in:
30 files changed
+1702
-7
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package text
|
||||
|
||||
import (
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||||
)
|
||||
|
||||
type GradientTextOptions struct {
|
||||
// Top is zero for AccentLit; Bottom is zero for Accent.
|
||||
Top, Bottom pixel.Slot
|
||||
Scale int
|
||||
}
|
||||
|
||||
// GradientText dithers glyph dots from Top down to Bottom.
|
||||
func GradientText(c *ui.Context, s string, o GradientTextOptions) *ui.Element {
|
||||
k, sc := pixel.K(c), scale(o.Scale)
|
||||
top, bottom := slotOr(o.Top, pixel.AccentLit), slotOr(o.Bottom, pixel.Accent)
|
||||
return block(c, k, s, pixel.Measure(s)*sc, pixel.LineHeight*sc, func(g pixel.Canvas) {
|
||||
g.TextBlend(0, 0, s, top, bottom, sc)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user