Add: components, progress bar
This commit is contained in:
@ -2,7 +2,7 @@ package drawer
|
||||
|
||||
import "math"
|
||||
|
||||
func (d *drawer) FillBar(sx, sy, ex, ey, color int) {
|
||||
func (d *drawer) FillBar(sx, sy, ex, ey int, color byte) {
|
||||
d.dev.LockImg()
|
||||
defer d.dev.UnlockImg()
|
||||
|
||||
@ -18,12 +18,12 @@ func (d *drawer) FillBar(sx, sy, ex, ey, color int) {
|
||||
addr := lineaddr
|
||||
le := addr + w
|
||||
for ; addr < le; addr++ {
|
||||
d.img.Pix[addr] = 255
|
||||
d.img.Pix[addr] = color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *drawer) PutBar(sx, sy, ex, ey, color int) {
|
||||
func (d *drawer) PutBar(sx, sy, ex, ey int, color byte) {
|
||||
d.dev.LockImg()
|
||||
defer d.dev.UnlockImg()
|
||||
|
||||
@ -36,7 +36,7 @@ func (d *drawer) PutBar(sx, sy, ex, ey, color int) {
|
||||
x1 := int(math.Min(float64(ex), float64(bounds.Dx())))
|
||||
|
||||
for addr := sy*bounds.Dx() + x0; addr < sy*bounds.Dx()+x1; addr++ {
|
||||
d.img.Pix[addr] = 255
|
||||
d.img.Pix[addr] = color
|
||||
}
|
||||
}
|
||||
// Bottom
|
||||
@ -45,7 +45,7 @@ func (d *drawer) PutBar(sx, sy, ex, ey, color int) {
|
||||
x1 := int(math.Min(float64(ex), float64(bounds.Dx())))
|
||||
|
||||
for addr := (ey-1)*bounds.Dx() + x0; addr < (ey-1)*bounds.Dx()+x1; addr++ {
|
||||
d.img.Pix[addr] = 255
|
||||
d.img.Pix[addr] = color
|
||||
}
|
||||
}
|
||||
// Left
|
||||
@ -54,7 +54,7 @@ func (d *drawer) PutBar(sx, sy, ex, ey, color int) {
|
||||
y1 := int(math.Min(float64(ey), float64(bounds.Dy())))
|
||||
|
||||
for addr := y0*bounds.Dx() + sx; addr < y1*bounds.Dx()+sx; addr += bounds.Dx() {
|
||||
d.img.Pix[addr] = 255
|
||||
d.img.Pix[addr] = color
|
||||
}
|
||||
}
|
||||
// Right
|
||||
@ -63,7 +63,7 @@ func (d *drawer) PutBar(sx, sy, ex, ey, color int) {
|
||||
y1 := int(math.Min(float64(ey), float64(bounds.Dy())))
|
||||
|
||||
for addr := y0*bounds.Dx() + (ex - 1); addr < y1*bounds.Dx()+(ex-1); addr += bounds.Dx() {
|
||||
d.img.Pix[addr] = 255
|
||||
d.img.Pix[addr] = color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,16 @@ type drawer struct {
|
||||
type Drawer interface {
|
||||
GetDisplay() display.Display
|
||||
|
||||
W() int
|
||||
H() int
|
||||
|
||||
Clear()
|
||||
Flush()
|
||||
|
||||
PutText(x, y int, text string)
|
||||
|
||||
PutBar(x0, y0, x1, y1, color int)
|
||||
FillBar(x0, y0, x1, y1, color int)
|
||||
PutBar(x0, y0, x1, y1 int, color byte)
|
||||
FillBar(x0, y0, x1, y1 int, color byte)
|
||||
}
|
||||
|
||||
func New(dev display.Display) Drawer {
|
||||
@ -37,6 +40,14 @@ func (d *drawer) GetDisplay() display.Display {
|
||||
return d.dev
|
||||
}
|
||||
|
||||
func (d *drawer) W() int {
|
||||
return d.img.Rect.Dx()
|
||||
}
|
||||
|
||||
func (d *drawer) H() int {
|
||||
return d.img.Rect.Dy()
|
||||
}
|
||||
|
||||
func (d *drawer) Clear() {
|
||||
d.dev.LockImg()
|
||||
defer d.dev.UnlockImg()
|
||||
|
@ -11,6 +11,7 @@ const (
|
||||
LineGap = 1
|
||||
FontCharW = 5
|
||||
FontCharH = 7
|
||||
LineH = FontCharH + LineGap
|
||||
)
|
||||
|
||||
// Standard ASCII 5x7 font
|
||||
|
Reference in New Issue
Block a user