-
Notifications
You must be signed in to change notification settings - Fork 6
/
drawutil.go
42 lines (37 loc) · 1.04 KB
/
drawutil.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
package x11ui
import (
"image"
"image/color"
"github.com/BurntSushi/xgbutil/xgraphics"
)
func StrokeBorder(img *xgraphics.Image, clr xgraphics.BGRA, margin, width int) {
outset := img.Rect
// outset.Max.Sub(image.Point{5, 5})
size := outset.Size()
inset := outset.Inset(width)
for x := 0; x < size.X; x++ {
for y := 0; y < size.Y; y++ {
xcond := (outset.Min.X >= x && inset.Min.X > x) || (inset.Max.X < x)
ycond := (outset.Min.Y >= y && inset.Min.Y > y) || (inset.Max.Y < y)
if xcond || ycond {
img.SetBGRA(x, y, clr)
}
}
}
}
func StrokeBorderImg(img *image.RGBA, clr color.Color, margin, width int) {
outset := img.Rect
// outset.Max.Sub(image.Point{5, 5})
size := outset.Size()
inset := outset.Inset(width)
for x := 0; x < size.X; x++ {
for y := 0; y < size.Y; y++ {
xcond := (outset.Min.X >= x && inset.Min.X > x) || (inset.Max.X < x)
ycond := (outset.Min.Y >= y && inset.Min.Y > y) || (inset.Max.Y < y)
if xcond || ycond {
// xg.SetBGRA(x, y, clr)
img.SetRGBA(x, y, clr.(color.RGBA))
}
}
}
}