50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package igwrap
|
|
|
|
import (
|
|
"math"
|
|
|
|
"edgaru089.ink/go/gl01/internal/util/itype"
|
|
"github.com/inkyblackness/imgui-go/v4"
|
|
)
|
|
|
|
// Color converts non-premultiplied RGBA color into imgui.Vec4.
|
|
func Color(r, g, b, a uint8) imgui.Vec4 {
|
|
return imgui.Vec4{
|
|
X: float32(r) / 255,
|
|
Y: float32(g) / 255,
|
|
Z: float32(b) / 255,
|
|
W: float32(a) / 255,
|
|
}
|
|
}
|
|
|
|
// PackedColor converts RGBA to imgui.PackedColor.
|
|
func PackedColor(color itype.Vec4f) imgui.PackedColor {
|
|
return imgui.PackedColorFromVec4(Vec4(color))
|
|
}
|
|
|
|
// UnpackedColor unpacks a color to RGBA.
|
|
func UnpackedColor(color imgui.PackedColor) itype.Vec4f {
|
|
r, g, b, a := color.RGBA()
|
|
return itype.Vec4f{
|
|
float32(r) / float32(math.MaxUint32),
|
|
float32(g) / float32(math.MaxUint32),
|
|
float32(b) / float32(math.MaxUint32),
|
|
float32(a) / float32(math.MaxUint32),
|
|
}
|
|
}
|
|
|
|
// Vec2 converts itype.Vec2f to imgui.Vec2.
|
|
func Vec2(v itype.Vec2f) imgui.Vec2 {
|
|
return imgui.Vec2{X: v[0], Y: v[1]}
|
|
}
|
|
|
|
// Vec2f converts imgui.Vec2 to itype.Vec2f.
|
|
func Vec2f(v imgui.Vec2) itype.Vec2f {
|
|
return itype.Vec2f{v.X, v.Y}
|
|
}
|
|
|
|
// Vec4 converts itype.Vec4f to imgui.Vec4.
|
|
func Vec4(v itype.Vec4f) imgui.Vec4 {
|
|
return imgui.Vec4{X: v[0], Y: v[1], Z: v[2], W: v[3]}
|
|
}
|