func (p *clock) Draw(dst draw.Image) error { format := p.Format if format == "" { format = DefaultFormat } msg := time.Now().Format(format) return p.font.Text(dst, msg, truetype.Foreground(p.state.Config.Foreground)) }
func (p *batteries) Draw(dst draw.Image) error { // TODO handle >1 battery bats, err := battery.GetAll() if err != nil { return fmt.Errorf("cannot access power supply state: %v", err) } buf := bytes.NewBufferString("bat:") for i, bat := range bats { if bat.Full == 0.0 { return fmt.Errorf("battery #%d full energy level is zero", i) } fmt.Fprintf(buf, " %.0f%%", bat.Current/bat.Full*100) switch bat.State { case battery.Charging: fmt.Fprint(buf, " AC") } } msg := buf.String() return p.font.Text(dst, msg, truetype.Foreground(p.state.Config.Foreground)) }
func (p *placeholder) Draw(dst draw.Image) error { msg := fmt.Sprintf("%dx%d", dst.Bounds().Dx(), dst.Bounds().Dy()) // TODO centered return p.font.Text(dst, msg, truetype.Foreground(p.state.Config.Foreground)) }