Skip to content

Commit

Permalink
Assume a DPI of 124
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jul 19, 2019
1 parent 8b18374 commit 9854632
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func drawImage(img *image.RGBA, path string, size uint, x uint, y uint) error {

func drawString(img *image.RGBA, ttf *truetype.Font, text string, fontsize float64, pt fixed.Point26_6) {
c := freetype.NewContext()
c.SetDPI(72)
c.SetDPI(124)
c.SetFont(ttf)
c.SetSrc(image.NewUniform(color.RGBA{0, 0, 0, 0}))
c.SetDst(img)
c.SetClip(img.Bounds())
c.SetHinting(font.HintingNone)
c.SetHinting(font.HintingFull)
c.SetFontSize(fontsize)

// find text entent
Expand Down
6 changes: 3 additions & 3 deletions widget_clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func (w *ClockWidget) Update(dev *streamdeck.Device) {
hour := t.Format("15")
min := t.Format("04")
sec := t.Format("05")
drawString(img, ttfBoldFont, hour, 22, freetype.Pt(-1, 20))
drawString(img, ttfFont, min, 22, freetype.Pt(-1, 43))
drawString(img, ttfThinFont, sec, 22, freetype.Pt(-1, 66))
drawString(img, ttfBoldFont, hour, 13, freetype.Pt(-1, 20))
drawString(img, ttfFont, min, 13, freetype.Pt(-1, 43))
drawString(img, ttfThinFont, sec, 13, freetype.Pt(-1, 66))

err := dev.SetImage(w.key, img)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions widget_top.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func (w *TopWidget) Update(dev *streamdeck.Device) {

draw.Draw(img, image.Rect(12, 6, 60, 54), &image.Uniform{color.RGBA{255, 255, 255, 255}}, image.ZP, draw.Src)
draw.Draw(img, image.Rect(13, 7, 59, 53), &image.Uniform{color.RGBA{0, 0, 0, 255}}, image.ZP, draw.Src)
draw.Draw(img, image.Rect(14, 7+int(46*(1-cpuUsage[0]/100)), 58, 53), &image.Uniform{color.RGBA{10, 10, 240, 255}}, image.ZP, draw.Src)
draw.Draw(img, image.Rect(14, 7+int(46*(1-cpuUsage[0]/100)), 58, 53), &image.Uniform{color.RGBA{215, 158, 147, 255}}, image.ZP, draw.Src)

drawString(img, ttfBoldFont, strconv.FormatInt(int64(cpuUsage[0]), 10), 20, freetype.Pt(-1, -1))
drawString(img, ttfBoldFont, "% CPU", 12, freetype.Pt(-1, img.Bounds().Dx()-4))
drawString(img, ttfFont, strconv.FormatInt(int64(cpuUsage[0]), 10), 12, freetype.Pt(-1, -1))
drawString(img, ttfFont, "% CPU", 7, freetype.Pt(-1, img.Bounds().Dx()-4))

err = dev.SetImage(w.key, img)
if err != nil {
Expand Down

0 comments on commit 9854632

Please sign in to comment.