forked from marcetin/parallelcoin
-
Notifications
You must be signed in to change notification settings - Fork 5
/
draw_rectangle.go
35 lines (30 loc) · 924 Bytes
/
draw_rectangle.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
package helpers
import (
"github.com/p9c/pod/pkg/gui/f32"
"github.com/p9c/pod/pkg/gui/layout"
"github.com/p9c/pod/pkg/gui/op/clip"
"github.com/p9c/pod/pkg/gui/op/paint"
"github.com/p9c/pod/pkg/gui/unit"
"image"
)
func DuoUIdrawRectangle(gtx *layout.Context, w, h int, color string, borderRadius [4]float32, padding [4]float32) {
in := layout.Inset{
Top: unit.Dp(padding[0]),
Right: unit.Dp(padding[1]),
Bottom: unit.Dp(padding[2]),
Left: unit.Dp(padding[3]),
}
in.Layout(gtx, func() {
square := f32.Rectangle{
Max: f32.Point{
X: float32(w),
Y: float32(h),
},
}
paint.ColorOp{Color: hexARGB(color)}.Add(gtx.Ops)
clip.Rect{Rect: square,
NE: borderRadius[0], NW: borderRadius[1], SE: borderRadius[2], SW: borderRadius[3]}.Op(gtx.Ops).Add(gtx.Ops) // HLdraw
paint.PaintOp{Rect: square}.Add(gtx.Ops)
gtx.Dimensions = layout.Dimensions{Size: image.Point{X: w, Y: h}}
})
}