Remove dependencies on fogleman/gg and golang/freetype (#28)

The waveshare2in13v2 example was evidently copied from the epd example,
but didn't comment out the code pulling in additional dependencies.
pull/29/head
hansmi 5 years ago committed by GitHub
parent d92a4ed45d
commit d09d487465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,8 +7,6 @@ module periph.io/x/devices/v3
go 1.13 go 1.13
require ( require (
github.com/fogleman/gg v1.3.0
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/maruel/ansi256 v1.0.2 github.com/maruel/ansi256 v1.0.2
github.com/mattn/go-colorable v0.1.11 github.com/mattn/go-colorable v0.1.11
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d

@ -1,7 +1,3 @@
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/maruel/ansi256 v1.0.2 h1:AE5gYrrZ5vQaFTTwy5vxva8Bak7p7wID3Uqu3t1j3No= github.com/maruel/ansi256 v1.0.2 h1:AE5gYrrZ5vQaFTTwy5vxva8Bak7p7wID3Uqu3t1j3No=

@ -13,10 +13,6 @@ import (
"golang.org/x/image/font/basicfont" "golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed" "golang.org/x/image/math/fixed"
"github.com/fogleman/gg"
"github.com/golang/freetype/truetype"
"golang.org/x/image/font/gofont/goregular"
"periph.io/x/conn/v3/spi/spireg" "periph.io/x/conn/v3/spi/spireg"
"periph.io/x/devices/v3/ssd1306/image1bit" "periph.io/x/devices/v3/ssd1306/image1bit"
"periph.io/x/devices/v3/waveshare2in13v2" "periph.io/x/devices/v3/waveshare2in13v2"
@ -87,42 +83,46 @@ func Example_other() {
} }
var img image.Image var img image.Image
bounds := dev.Bounds() // Note: this code is commented out so periph does not depend on:
w := bounds.Dx() // "github.com/fogleman/gg"
h := bounds.Dy() // "github.com/golang/freetype/truetype"
dc := gg.NewContext(w, h) // "golang.org/x/image/font/gofont/goregular"
im, err := gg.LoadPNG("gopher.png") // bounds := dev.Bounds()
if err != nil { // w := bounds.Dx()
panic(err) // h := bounds.Dy()
} // dc := gg.NewContext(w, h)
dc.SetRGB(1, 1, 1) // im, err := gg.LoadPNG("gopher.png")
dc.Clear() // if err != nil {
dc.SetRGB(0, 0, 0) // panic(err)
dc.Rotate(gg.Radians(90)) // }
dc.Translate(0.0, -float64(h/2)) // dc.SetRGB(1, 1, 1)
font, err := truetype.Parse(goregular.TTF) // dc.Clear()
if err != nil { // dc.SetRGB(0, 0, 0)
panic(err) // dc.Rotate(gg.Radians(90))
} // dc.Translate(0.0, -float64(h/2))
face := truetype.NewFace(font, &truetype.Options{ // font, err := truetype.Parse(goregular.TTF)
Size: 16, // if err != nil {
}) // panic(err)
dc.SetFontFace(face) // }
text := "Hello from periph!" // face := truetype.NewFace(font, &truetype.Options{
tw, th := dc.MeasureString(text) // Size: 16,
dc.DrawImage(im, 120, 30) // })
padding := 8.0 // dc.SetFontFace(face)
dc.DrawRoundedRectangle(padding*2, padding*2, tw+padding*2, th+padding, 10) // text := "Hello from periph!"
dc.Stroke() // tw, th := dc.MeasureString(text)
dc.DrawString(text, padding*3, padding*2+th) // dc.DrawImage(im, 120, 30)
for i := 0; i < 10; i++ { // padding := 8.0
dc.DrawCircle(float64(30+(10*i)), 100, 5) // dc.DrawRoundedRectangle(padding*2, padding*2, tw+padding*2, th+padding, 10)
} // dc.Stroke()
for i := 0; i < 10; i++ { // dc.DrawString(text, padding*3, padding*2+th)
dc.DrawRectangle(float64(30+(10*i)), 80, 5, 5) // for i := 0; i < 10; i++ {
} // dc.DrawCircle(float64(30+(10*i)), 100, 5)
dc.Fill() // }
img = dc.Image() // for i := 0; i < 10; i++ {
// dc.DrawRectangle(float64(30+(10*i)), 80, 5, 5)
// }
// dc.Fill()
// img = dc.Image()
if err := dev.Draw(dev.Bounds(), img, image.Point{}); err != nil { if err := dev.Draw(dev.Bounds(), img, image.Point{}); err != nil {
log.Fatal(err) log.Fatal(err)

Loading…
Cancel
Save