Add new shapes functions

This commit is contained in:
Milan Nikolic 2023-11-08 19:34:50 +01:00
parent 3f31944caf
commit 635c63d7cc
No known key found for this signature in database
GPG key ID: 9229D0EAA3AA4E75
3 changed files with 29 additions and 11 deletions

View file

@ -1,6 +1,6 @@
package rl
/*
#cgo CFLAGS: -std=gnu99 -Wno-missing-braces -Wno-unused-result -Wno-implicit-function-declaration
#cgo CFLAGS: -std=gnu99 -Wno-missing-braces -Wno-unused-result -Wno-implicit-function-declaration -Wno-discarded-qualifiers
*/
import "C"

View file

@ -157,7 +157,7 @@
//#define SUPPORT_FILEFORMAT_ASTC 1
//#define SUPPORT_FILEFORMAT_PKM 1
//#define SUPPORT_FILEFORMAT_PVR 1
#define SUPPORT_FILEFORMAT_SVG 1
//#define SUPPORT_FILEFORMAT_SVG 1
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
#define SUPPORT_IMAGE_EXPORT 1

View file

@ -10,6 +10,13 @@ import (
"unsafe"
)
// SetShapesTexture - Define default texture used to draw shapes
func SetShapesTexture(texture Texture2D, source Rectangle) {
ctexture := texture.cptr()
csource := source.cptr()
C.SetShapesTexture(*ctexture, *csource)
}
// DrawPixel - Draw a pixel
func DrawPixel(posX, posY int32, col color.RGBA) {
cposX := (C.int)(posX)
@ -82,6 +89,24 @@ func DrawLineBezierCubic(startPos Vector2, endPos Vector2, startControlPos Vecto
C.DrawLineBezierCubic(*cstartPos, *cendPos, *cstartControlPos, *cendControlPos, cthick, *ccolor)
}
// DrawLineBSpline - Draw a B-Spline line, minimum 4 points
func DrawLineBSpline(points []Vector2, pointCount int32, thick float32, col color.RGBA) {
cpoints := (*C.Vector2)(unsafe.Pointer(&points[0]))
cpointCount := (C.int)(pointCount)
cthick := (C.float)(thick)
ccolor := colorCptr(col)
C.DrawLineBSpline(cpoints, cpointCount, cthick, *ccolor)
}
// DrawLineCatmullRom - Draw a Catmull Rom spline line, minimum 4 points
func DrawLineCatmullRom(points []Vector2, pointCount int32, thick float32, col color.RGBA) {
cpoints := (*C.Vector2)(unsafe.Pointer(&points[0]))
cpointCount := (C.int)(pointCount)
cthick := (C.float)(thick)
ccolor := colorCptr(col)
C.DrawLineCatmullRom(cpoints, cpointCount, cthick, *ccolor)
}
// DrawLineStrip - Draw lines sequence
func DrawLineStrip(points []Vector2, pointCount int32, col color.RGBA) {
cpoints := (*C.Vector2)(unsafe.Pointer(&points[0]))
@ -168,7 +193,7 @@ func DrawEllipseLines(centerX, centerY int32, radiusH, radiusV float32, col colo
C.DrawEllipseLines(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor)
}
// DrawRing -
// DrawRing - Draw ring
func DrawRing(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, col color.RGBA) {
ccenter := center.cptr()
cinnerRadius := (C.float)(innerRadius)
@ -180,7 +205,7 @@ func DrawRing(center Vector2, innerRadius, outerRadius, startAngle, endAngle flo
C.DrawRing(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor)
}
// DrawRingLines -
// DrawRingLines - Draw ring outline
func DrawRingLines(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, col color.RGBA) {
ccenter := center.cptr()
cinnerRadius := (C.float)(innerRadius)
@ -463,10 +488,3 @@ func GetCollisionRec(rec1, rec2 Rectangle) Rectangle {
v := newRectangleFromPointer(unsafe.Pointer(&ret))
return v
}
// SetShapesTexture - Define default texture used to draw shapes
func SetShapesTexture(texture Texture2D, source Rectangle) {
ctexture := texture.cptr()
csource := source.cptr()
C.SetShapesTexture(*ctexture, *csource)
}