Add new shapes functions
This commit is contained in:
parent
3f31944caf
commit
635c63d7cc
3 changed files with 29 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
package rl
|
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"
|
import "C"
|
||||||
|
|
|
@ -157,7 +157,7 @@
|
||||||
//#define SUPPORT_FILEFORMAT_ASTC 1
|
//#define SUPPORT_FILEFORMAT_ASTC 1
|
||||||
//#define SUPPORT_FILEFORMAT_PKM 1
|
//#define SUPPORT_FILEFORMAT_PKM 1
|
||||||
//#define SUPPORT_FILEFORMAT_PVR 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)
|
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
|
||||||
#define SUPPORT_IMAGE_EXPORT 1
|
#define SUPPORT_IMAGE_EXPORT 1
|
||||||
|
|
|
@ -10,6 +10,13 @@ import (
|
||||||
"unsafe"
|
"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
|
// DrawPixel - Draw a pixel
|
||||||
func DrawPixel(posX, posY int32, col color.RGBA) {
|
func DrawPixel(posX, posY int32, col color.RGBA) {
|
||||||
cposX := (C.int)(posX)
|
cposX := (C.int)(posX)
|
||||||
|
@ -82,6 +89,24 @@ func DrawLineBezierCubic(startPos Vector2, endPos Vector2, startControlPos Vecto
|
||||||
C.DrawLineBezierCubic(*cstartPos, *cendPos, *cstartControlPos, *cendControlPos, cthick, *ccolor)
|
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
|
// DrawLineStrip - Draw lines sequence
|
||||||
func DrawLineStrip(points []Vector2, pointCount int32, col color.RGBA) {
|
func DrawLineStrip(points []Vector2, pointCount int32, col color.RGBA) {
|
||||||
cpoints := (*C.Vector2)(unsafe.Pointer(&points[0]))
|
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)
|
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) {
|
func DrawRing(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, col color.RGBA) {
|
||||||
ccenter := center.cptr()
|
ccenter := center.cptr()
|
||||||
cinnerRadius := (C.float)(innerRadius)
|
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)
|
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) {
|
func DrawRingLines(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, col color.RGBA) {
|
||||||
ccenter := center.cptr()
|
ccenter := center.cptr()
|
||||||
cinnerRadius := (C.float)(innerRadius)
|
cinnerRadius := (C.float)(innerRadius)
|
||||||
|
@ -463,10 +488,3 @@ func GetCollisionRec(rec1, rec2 Rectangle) Rectangle {
|
||||||
v := newRectangleFromPointer(unsafe.Pointer(&ret))
|
v := newRectangleFromPointer(unsafe.Pointer(&ret))
|
||||||
return v
|
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)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue