More generics for coordinates

This commit is contained in:
Igor Karatayev 2024-02-27 21:28:11 +03:00
parent 713c31856c
commit 9d2fe11635
3 changed files with 6 additions and 6 deletions

View file

@ -575,8 +575,8 @@ type Rectangle struct {
}
// NewRectangle - Returns new Rectangle
func NewRectangle(x, y, width, height float32) Rectangle {
return Rectangle{x, y, width, height}
func NewRectangle[XT, YT, WT, HT CoordinateT](x XT, y YT, width WT, height HT) Rectangle {
return Rectangle{float32(x), float32(y), float32(width), float32(height)}
}
func (r *Rectangle) Delta(x, y, width, height float32) Rectangle {

View file

@ -18,7 +18,7 @@ func SetShapesTexture(texture Texture2D, source Rectangle) {
}
// DrawPixel - Draw a pixel
func DrawPixel(posX, posY int32, col color.RGBA) {
func DrawPixel[XT, YT CoordinateT](posX XT, posY YT, col color.RGBA) {
cposX := (C.int)(posX)
cposY := (C.int)(posY)
ccolor := colorCptr(col)
@ -33,7 +33,7 @@ func DrawPixelV(position Vector2, col color.RGBA) {
}
// DrawLine - Draw a line
func DrawLine(startPosX, startPosY, endPosX, endPosY int32, col color.RGBA) {
func DrawLine[SXT, SYT, EXT, EYT CoordinateT](startPosX SXT, startPosY SYT, endPosX EXT, endPosY EYT, col color.RGBA) {
cstartPosX := (C.int)(startPosX)
cstartPosY := (C.int)(startPosY)
cendPosX := (C.int)(endPosX)

View file

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