aboutsummaryrefslogtreecommitdiffstats
path: root/gui/widget/text.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-01-19 22:07:42 -0500
committerSam Anthony <sam@samanthony.xyz>2024-01-19 22:07:42 -0500
commit54d71a24b6eaa191b2777f6070de252fc26801a3 (patch)
tree1d26f49dfcacc5578b4e6c91e8ffb31b09a9f662 /gui/widget/text.go
parent39a3b948e525fe2b22b90e07df323ab77f6a81f6 (diff)
downloadvolute-54d71a24b6eaa191b2777f6070de252fc26801a3.zip
add layout from Keitio
Diffstat (limited to 'gui/widget/text.go')
-rw-r--r--gui/widget/text.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/gui/widget/text.go b/gui/widget/text.go
index 5e37d70..e336874 100644
--- a/gui/widget/text.go
+++ b/gui/widget/text.go
@@ -5,6 +5,7 @@ import (
"sync"
"image"
+ "image/color"
"image/draw"
"golang.org/x/image/font"
@@ -14,12 +15,10 @@ import (
)
var (
- FONT = goregular.TTF
- FONT_SIZE = 15
- DPI = 72
- PADDING = 3
- BG_COLOR = image.White
- TEXT_COLOR = image.Black
+ FONT = goregular.TTF
+ FONT_SIZE = 15
+ DPI = 72
+ PADDING = 3
)
var face *concurrentFace
@@ -47,20 +46,20 @@ func TextHeight() int {
return FONT_SIZE + 2*PADDING
}
-func drawText(text []byte, dst draw.Image, r image.Rectangle) {
+func drawText(text []byte, dst draw.Image, r image.Rectangle, fg, bg color.Color) {
drawer := font.Drawer{
- Src: TEXT_COLOR,
+ Src: &image.Uniform{fg},
Face: face,
Dot: fixed.P(0, 0),
}
// background
- draw.Draw(dst, r, BG_COLOR, image.ZP, draw.Src)
+ draw.Draw(dst, r, &image.Uniform{bg}, image.ZP, draw.Src)
// text image
bounds := textBounds(text, drawer)
textImg := image.NewRGBA(bounds)
- draw.Draw(textImg, bounds, BG_COLOR, image.ZP, draw.Src)
+ draw.Draw(textImg, bounds, &image.Uniform{bg}, image.ZP, draw.Src)
drawer.Dst = textImg
drawer.DrawBytes(text)