Adding template for coordiantes.

This commit is contained in:
Igor Karatayev 2024-02-27 21:11:26 +03:00
parent f840c9ccd5
commit 713c31856c
2 changed files with 6 additions and 2 deletions

View file

@ -20,6 +20,10 @@ func init() {
runtime.LockOSThread() runtime.LockOSThread()
} }
type CoordinateT interface {
int | int32 | int64 | float32 | float64
}
// Wave type, defines audio wave data // Wave type, defines audio wave data
type Wave struct { type Wave struct {
// Number of samples // Number of samples

View file

@ -126,14 +126,14 @@ func UnloadFont(font Font) {
} }
// DrawFPS - Shows current FPS // DrawFPS - Shows current FPS
func DrawFPS(posX int32, posY int32) { func DrawFPS[PT CoordinateT](posX PT, posY PT) {
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
C.DrawFPS(cposX, cposY) C.DrawFPS(cposX, cposY)
} }
// DrawText - Draw text (using default font) // DrawText - Draw text (using default font)
func DrawText(text string, posX int32, posY int32, fontSize int32, col color.RGBA) { func DrawText[PT CoordinateT](text string, posX PT, posY PT, fontSize int32, col color.RGBA) {
ctext := C.CString(text) ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext)) defer C.free(unsafe.Pointer(ctext))
cposX := (C.int)(posX) cposX := (C.int)(posX)