forked from google/periph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
displaytest.go
45 lines (35 loc) · 943 Bytes
/
displaytest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
package displaytest
import (
"image"
"image/color"
"image/draw"
"periph.io/x/periph/conn/display"
)
// Drawer is a fake display.Drawer.
type Drawer struct {
Img *image.NRGBA
}
func (d *Drawer) String() string {
return "Drawer"
}
// Halt implements conn.Resource. It is a noop.
func (d *Drawer) Halt() error {
return nil
}
// ColorModel implements image.Image.
func (d *Drawer) ColorModel() color.Model {
return d.Img.ColorModel()
}
// Bounds implements image.Image.
func (d *Drawer) Bounds() image.Rectangle {
return d.Img.Bounds()
}
// Draw implements draw.Image.
func (d *Drawer) Draw(dstRect image.Rectangle, src image.Image, sp image.Point) error {
draw.Draw(d.Img, dstRect, src, sp, draw.Src)
return nil
}
var _ display.Drawer = &Drawer{}