Use color.RGBA, fixes 144

This commit is contained in:
Milan Nikolic 2021-11-14 12:16:02 +01:00
parent ca8ab655a8
commit 29ba3cc508
No known key found for this signature in database
GPG key ID: 9229D0EAA3AA4E75
6 changed files with 241 additions and 231 deletions

View file

@ -42,6 +42,7 @@ package rl
import "C" import "C"
import ( import (
"image" "image"
"image/color"
"io" "io"
"runtime" "runtime"
"unsafe" "unsafe"
@ -558,21 +559,17 @@ func NewQuaternion(x, y, z, w float32) Quaternion {
} }
// Color type, RGBA (32bit) // Color type, RGBA (32bit)
type Color struct { // TODO remove later, keep type for now to not break code
R uint8 type Color = color.RGBA
G uint8
B uint8
A uint8
}
// NewColor - Returns new Color // NewColor - Returns new Color
func NewColor(r, g, b, a uint8) Color { func NewColor(r, g, b, a uint8) color.RGBA {
return Color{r, g, b, a} return color.RGBA{r, g, b, a}
} }
// newColorFromPointer - Returns new Color from pointer // newColorFromPointer - Returns new Color from pointer
func newColorFromPointer(ptr unsafe.Pointer) Color { func newColorFromPointer(ptr unsafe.Pointer) color.RGBA {
return *(*Color)(ptr) return *(*color.RGBA)(ptr)
} }
// Rectangle type // Rectangle type
@ -840,7 +837,7 @@ type MaterialMap struct {
// Texture // Texture
Texture Texture2D Texture Texture2D
// Color // Color
Color Color Color color.RGBA
// Value // Value
Value float32 Value float32
} }
@ -1112,7 +1109,7 @@ func NewImageFromImage(img image.Image) *Image {
cx := (C.int)(size.X) cx := (C.int)(size.X)
cy := (C.int)(size.Y) cy := (C.int)(size.Y)
ccolor := White.cptr() ccolor := colorCptr(White)
ret := C.GenImageColor(cx, cy, *ccolor) ret := C.GenImageColor(cx, cy, *ccolor)
for y := 0; y < size.Y; y++ { for y := 0; y < size.Y; y++ {
@ -1120,7 +1117,7 @@ func NewImageFromImage(img image.Image) *Image {
color := img.At(x, y) color := img.At(x, y)
r, g, b, a := color.RGBA() r, g, b, a := color.RGBA()
rcolor := NewColor(uint8(r), uint8(g), uint8(b), uint8(a)) rcolor := NewColor(uint8(r), uint8(g), uint8(b), uint8(a))
ccolor = rcolor.cptr() ccolor = colorCptr(rcolor)
cx = (C.int)(x) cx = (C.int)(x)
cy = (C.int)(y) cy = (C.int)(y)

View file

@ -7,6 +7,7 @@ package rl
import "C" import "C"
import ( import (
"image/color"
"unsafe" "unsafe"
) )
@ -30,9 +31,9 @@ func (m *Matrix) cptr() *C.Matrix {
return (*C.Matrix)(unsafe.Pointer(m)) return (*C.Matrix)(unsafe.Pointer(m))
} }
// cptr returns C pointer // colorCptr returns color C pointer
func (color *Color) cptr() *C.Color { func colorCptr(col color.RGBA) *C.Color {
return (*C.Color)(unsafe.Pointer(color)) return (*C.Color)(unsafe.Pointer(&col))
} }
// cptr returns C pointer // cptr returns C pointer
@ -309,8 +310,8 @@ func GetClipboardText() string {
} }
// ClearBackground - Sets Background Color // ClearBackground - Sets Background Color
func ClearBackground(color Color) { func ClearBackground(col color.RGBA) {
ccolor := color.cptr() ccolor := colorCptr(col)
C.ClearBackground(*ccolor) C.ClearBackground(*ccolor)
} }
@ -451,8 +452,8 @@ func GetTime() float32 {
} }
// Fade - Returns color with alpha applied, alpha goes from 0.0f to 1.0f // Fade - Returns color with alpha applied, alpha goes from 0.0f to 1.0f
func Fade(color Color, alpha float32) Color { func Fade(col color.RGBA, alpha float32) color.RGBA {
ccolor := color.cptr() ccolor := colorCptr(col)
calpha := (C.float)(alpha) calpha := (C.float)(alpha)
ret := C.Fade(*ccolor, calpha) ret := C.Fade(*ccolor, calpha)
v := newColorFromPointer(unsafe.Pointer(&ret)) v := newColorFromPointer(unsafe.Pointer(&ret))
@ -460,26 +461,27 @@ func Fade(color Color, alpha float32) Color {
} }
// ColorToInt - Returns hexadecimal value for a Color // ColorToInt - Returns hexadecimal value for a Color
func ColorToInt(color Color) int32 { func ColorToInt(col color.RGBA) int32 {
ccolor := color.cptr() ccolor := colorCptr(col)
ret := C.ColorToInt(*ccolor) ret := C.ColorToInt(*ccolor)
v := (int32)(ret) v := (int32)(ret)
return v return v
} }
// ColorNormalize - Returns color normalized as float [0..1] // ColorNormalize - Returns color normalized as float [0..1]
func ColorNormalize(color Color) Vector4 { func ColorNormalize(col color.RGBA) Vector4 {
result := Vector4{} result := Vector4{}
result.X = float32(color.R) / 255 r, g, b, a := col.RGBA()
result.Y = float32(color.G) / 255 result.X = float32(r) / 255
result.Z = float32(color.B) / 255 result.Y = float32(g) / 255
result.W = float32(color.A) / 255 result.Z = float32(b) / 255
result.W = float32(a) / 255
return result return result
} }
// ColorFromNormalized - Returns Color from normalized values [0..1] // ColorFromNormalized - Returns Color from normalized values [0..1]
func ColorFromNormalized(normalized Vector4) Color { func ColorFromNormalized(normalized Vector4) color.RGBA {
cnormalized := normalized.cptr() cnormalized := normalized.cptr()
ret := C.ColorFromNormalized(*cnormalized) ret := C.ColorFromNormalized(*cnormalized)
v := newColorFromPointer(unsafe.Pointer(&ret)) v := newColorFromPointer(unsafe.Pointer(&ret))
@ -487,15 +489,15 @@ func ColorFromNormalized(normalized Vector4) Color {
} }
// ColorToHSV - Returns HSV values for a Color, hue [0..360], saturation/value [0..1] // ColorToHSV - Returns HSV values for a Color, hue [0..360], saturation/value [0..1]
func ColorToHSV(color Color) Vector3 { func ColorToHSV(col color.RGBA) Vector3 {
ccolor := color.cptr() ccolor := colorCptr(col)
ret := C.ColorToHSV(*ccolor) ret := C.ColorToHSV(*ccolor)
v := newVector3FromPointer(unsafe.Pointer(&ret)) v := newVector3FromPointer(unsafe.Pointer(&ret))
return v return v
} }
// ColorFromHSV - Returns a Color from HSV values, hue [0..360], saturation/value [0..1] // ColorFromHSV - Returns a Color from HSV values, hue [0..360], saturation/value [0..1]
func ColorFromHSV(hue, saturation, value float32) Color { func ColorFromHSV(hue, saturation, value float32) color.RGBA {
chue := (C.float)(hue) chue := (C.float)(hue)
csaturation := (C.float)(saturation) csaturation := (C.float)(saturation)
cvalue := (C.float)(value) cvalue := (C.float)(value)
@ -505,22 +507,22 @@ func ColorFromHSV(hue, saturation, value float32) Color {
} }
// ColorAlpha - Returns color with alpha applied, alpha goes from 0.0f to 1.0f // ColorAlpha - Returns color with alpha applied, alpha goes from 0.0f to 1.0f
func ColorAlpha(color Color, alpha float32) Color { func ColorAlpha(col color.RGBA, alpha float32) color.RGBA {
return Fade(color, alpha) return Fade(col, alpha)
} }
// ColorAlphaBlend - Returns src alpha-blended into dst color with tint // ColorAlphaBlend - Returns src alpha-blended into dst color with tint
func ColorAlphaBlend(src, dst, tint Color) Color { func ColorAlphaBlend(src, dst, tint color.RGBA) color.RGBA {
csrc := src.cptr() csrc := colorCptr(src)
cdst := dst.cptr() cdst := colorCptr(dst)
ctint := tint.cptr() ctint := colorCptr(tint)
ret := C.ColorAlphaBlend(*csrc, *cdst, *ctint) ret := C.ColorAlphaBlend(*csrc, *cdst, *ctint)
v := newColorFromPointer(unsafe.Pointer(&ret)) v := newColorFromPointer(unsafe.Pointer(&ret))
return v return v
} }
// GetColor - Returns a Color struct from hexadecimal value // GetColor - Returns a Color struct from hexadecimal value
func GetColor(hexValue uint) Color { func GetColor(hexValue uint) color.RGBA {
chexValue := (C.uint)(hexValue) chexValue := (C.uint)(hexValue)
ret := C.GetColor(chexValue) ret := C.GetColor(chexValue)
v := newColorFromPointer(unsafe.Pointer(&ret)) v := newColorFromPointer(unsafe.Pointer(&ret))

View file

@ -5,7 +5,11 @@ package rl
#include <stdlib.h> #include <stdlib.h>
*/ */
import "C" import "C"
import "unsafe"
import (
"image/color"
"unsafe"
)
// cptr returns C pointer // cptr returns C pointer
func (m *Mesh) cptr() *C.Mesh { func (m *Mesh) cptr() *C.Mesh {
@ -28,139 +32,139 @@ func (r *Ray) cptr() *C.Ray {
} }
// DrawLine3D - Draw a line in 3D world space // DrawLine3D - Draw a line in 3D world space
func DrawLine3D(startPos Vector3, endPos Vector3, color Color) { func DrawLine3D(startPos Vector3, endPos Vector3, col color.RGBA) {
cstartPos := startPos.cptr() cstartPos := startPos.cptr()
cendPos := endPos.cptr() cendPos := endPos.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawLine3D(*cstartPos, *cendPos, *ccolor) C.DrawLine3D(*cstartPos, *cendPos, *ccolor)
} }
// DrawPoint3D - Draw a point in 3D space, actually a small line // DrawPoint3D - Draw a point in 3D space, actually a small line
func DrawPoint3D(position Vector3, color Color) { func DrawPoint3D(position Vector3, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawPoint3D(*cposition, *ccolor) C.DrawPoint3D(*cposition, *ccolor)
} }
// DrawCircle3D - Draw a circle in 3D world space // DrawCircle3D - Draw a circle in 3D world space
func DrawCircle3D(center Vector3, radius float32, rotationAxis Vector3, rotationAngle float32, color Color) { func DrawCircle3D(center Vector3, radius float32, rotationAxis Vector3, rotationAngle float32, col color.RGBA) {
ccenter := center.cptr() ccenter := center.cptr()
cradius := (C.float)(radius) cradius := (C.float)(radius)
crotationAxis := rotationAxis.cptr() crotationAxis := rotationAxis.cptr()
crotationAngle := (C.float)(rotationAngle) crotationAngle := (C.float)(rotationAngle)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCircle3D(*ccenter, cradius, *crotationAxis, crotationAngle, *ccolor) C.DrawCircle3D(*ccenter, cradius, *crotationAxis, crotationAngle, *ccolor)
} }
// DrawCube - Draw cube // DrawCube - Draw cube
func DrawCube(position Vector3, width float32, height float32, length float32, color Color) { func DrawCube(position Vector3, width float32, height float32, length float32, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
cwidth := (C.float)(width) cwidth := (C.float)(width)
cheight := (C.float)(height) cheight := (C.float)(height)
clength := (C.float)(length) clength := (C.float)(length)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCube(*cposition, cwidth, cheight, clength, *ccolor) C.DrawCube(*cposition, cwidth, cheight, clength, *ccolor)
} }
// DrawCubeV - Draw cube (Vector version) // DrawCubeV - Draw cube (Vector version)
func DrawCubeV(position Vector3, size Vector3, color Color) { func DrawCubeV(position Vector3, size Vector3, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
csize := size.cptr() csize := size.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCubeV(*cposition, *csize, *ccolor) C.DrawCubeV(*cposition, *csize, *ccolor)
} }
// DrawCubeWires - Draw cube wires // DrawCubeWires - Draw cube wires
func DrawCubeWires(position Vector3, width float32, height float32, length float32, color Color) { func DrawCubeWires(position Vector3, width float32, height float32, length float32, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
cwidth := (C.float)(width) cwidth := (C.float)(width)
cheight := (C.float)(height) cheight := (C.float)(height)
clength := (C.float)(length) clength := (C.float)(length)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCubeWires(*cposition, cwidth, cheight, clength, *ccolor) C.DrawCubeWires(*cposition, cwidth, cheight, clength, *ccolor)
} }
// DrawCubeWiresV - Draw cube wires (Vector version) // DrawCubeWiresV - Draw cube wires (Vector version)
func DrawCubeWiresV(position Vector3, size Vector3, color Color) { func DrawCubeWiresV(position Vector3, size Vector3, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
csize := size.cptr() csize := size.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCubeWiresV(*cposition, *csize, *ccolor) C.DrawCubeWiresV(*cposition, *csize, *ccolor)
} }
// DrawCubeTexture - Draw cube textured // DrawCubeTexture - Draw cube textured
func DrawCubeTexture(texture Texture2D, position Vector3, width float32, height float32, length float32, color Color) { func DrawCubeTexture(texture Texture2D, position Vector3, width float32, height float32, length float32, col color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
cposition := position.cptr() cposition := position.cptr()
cwidth := (C.float)(width) cwidth := (C.float)(width)
cheight := (C.float)(height) cheight := (C.float)(height)
clength := (C.float)(length) clength := (C.float)(length)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCubeTexture(*ctexture, *cposition, cwidth, cheight, clength, *ccolor) C.DrawCubeTexture(*ctexture, *cposition, cwidth, cheight, clength, *ccolor)
} }
// DrawSphere - Draw sphere // DrawSphere - Draw sphere
func DrawSphere(centerPos Vector3, radius float32, color Color) { func DrawSphere(centerPos Vector3, radius float32, col color.RGBA) {
ccenterPos := centerPos.cptr() ccenterPos := centerPos.cptr()
cradius := (C.float)(radius) cradius := (C.float)(radius)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawSphere(*ccenterPos, cradius, *ccolor) C.DrawSphere(*ccenterPos, cradius, *ccolor)
} }
// DrawSphereEx - Draw sphere with extended parameters // DrawSphereEx - Draw sphere with extended parameters
func DrawSphereEx(centerPos Vector3, radius float32, rings int32, slices int32, color Color) { func DrawSphereEx(centerPos Vector3, radius float32, rings int32, slices int32, col color.RGBA) {
ccenterPos := centerPos.cptr() ccenterPos := centerPos.cptr()
cradius := (C.float)(radius) cradius := (C.float)(radius)
crings := (C.int)(rings) crings := (C.int)(rings)
cslices := (C.int)(slices) cslices := (C.int)(slices)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawSphereEx(*ccenterPos, cradius, crings, cslices, *ccolor) C.DrawSphereEx(*ccenterPos, cradius, crings, cslices, *ccolor)
} }
// DrawSphereWires - Draw sphere wires // DrawSphereWires - Draw sphere wires
func DrawSphereWires(centerPos Vector3, radius float32, rings int32, slices int32, color Color) { func DrawSphereWires(centerPos Vector3, radius float32, rings int32, slices int32, col color.RGBA) {
ccenterPos := centerPos.cptr() ccenterPos := centerPos.cptr()
cradius := (C.float)(radius) cradius := (C.float)(radius)
crings := (C.int)(rings) crings := (C.int)(rings)
cslices := (C.int)(slices) cslices := (C.int)(slices)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawSphereWires(*ccenterPos, cradius, crings, cslices, *ccolor) C.DrawSphereWires(*ccenterPos, cradius, crings, cslices, *ccolor)
} }
// DrawCylinder - Draw a cylinder/cone // DrawCylinder - Draw a cylinder/cone
func DrawCylinder(position Vector3, radiusTop float32, radiusBottom float32, height float32, slices int32, color Color) { func DrawCylinder(position Vector3, radiusTop float32, radiusBottom float32, height float32, slices int32, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
cradiusTop := (C.float)(radiusTop) cradiusTop := (C.float)(radiusTop)
cradiusBottom := (C.float)(radiusBottom) cradiusBottom := (C.float)(radiusBottom)
cheight := (C.float)(height) cheight := (C.float)(height)
cslices := (C.int)(slices) cslices := (C.int)(slices)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCylinder(*cposition, cradiusTop, cradiusBottom, cheight, cslices, *ccolor) C.DrawCylinder(*cposition, cradiusTop, cradiusBottom, cheight, cslices, *ccolor)
} }
// DrawCylinderWires - Draw a cylinder/cone wires // DrawCylinderWires - Draw a cylinder/cone wires
func DrawCylinderWires(position Vector3, radiusTop float32, radiusBottom float32, height float32, slices int32, color Color) { func DrawCylinderWires(position Vector3, radiusTop float32, radiusBottom float32, height float32, slices int32, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
cradiusTop := (C.float)(radiusTop) cradiusTop := (C.float)(radiusTop)
cradiusBottom := (C.float)(radiusBottom) cradiusBottom := (C.float)(radiusBottom)
cheight := (C.float)(height) cheight := (C.float)(height)
cslices := (C.int)(slices) cslices := (C.int)(slices)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCylinderWires(*cposition, cradiusTop, cradiusBottom, cheight, cslices, *ccolor) C.DrawCylinderWires(*cposition, cradiusTop, cradiusBottom, cheight, cslices, *ccolor)
} }
// DrawPlane - Draw a plane XZ // DrawPlane - Draw a plane XZ
func DrawPlane(centerPos Vector3, size Vector2, color Color) { func DrawPlane(centerPos Vector3, size Vector2, col color.RGBA) {
ccenterPos := centerPos.cptr() ccenterPos := centerPos.cptr()
csize := size.cptr() csize := size.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawPlane(*ccenterPos, *csize, *ccolor) C.DrawPlane(*ccenterPos, *csize, *ccolor)
} }
// DrawRay - Draw a ray line // DrawRay - Draw a ray line
func DrawRay(ray Ray, color Color) { func DrawRay(ray Ray, col color.RGBA) {
cray := ray.cptr() cray := ray.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRay(*cray, *ccolor) C.DrawRay(*cray, *ccolor)
} }
@ -377,70 +381,70 @@ func SetModelMeshMaterial(model *Model, meshId int32, materialId int32) {
} }
// DrawModel - Draw a model (with texture if set) // DrawModel - Draw a model (with texture if set)
func DrawModel(model Model, position Vector3, scale float32, tint Color) { func DrawModel(model Model, position Vector3, scale float32, tint color.RGBA) {
cmodel := model.cptr() cmodel := model.cptr()
cposition := position.cptr() cposition := position.cptr()
cscale := (C.float)(scale) cscale := (C.float)(scale)
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawModel(*cmodel, *cposition, cscale, *ctint) C.DrawModel(*cmodel, *cposition, cscale, *ctint)
} }
// DrawModelEx - Draw a model with extended parameters // DrawModelEx - Draw a model with extended parameters
func DrawModelEx(model Model, position Vector3, rotationAxis Vector3, rotationAngle float32, scale Vector3, tint Color) { func DrawModelEx(model Model, position Vector3, rotationAxis Vector3, rotationAngle float32, scale Vector3, tint color.RGBA) {
cmodel := model.cptr() cmodel := model.cptr()
cposition := position.cptr() cposition := position.cptr()
crotationAxis := rotationAxis.cptr() crotationAxis := rotationAxis.cptr()
crotationAngle := (C.float)(rotationAngle) crotationAngle := (C.float)(rotationAngle)
cscale := scale.cptr() cscale := scale.cptr()
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawModelEx(*cmodel, *cposition, *crotationAxis, crotationAngle, *cscale, *ctint) C.DrawModelEx(*cmodel, *cposition, *crotationAxis, crotationAngle, *cscale, *ctint)
} }
// DrawModelWires - Draw a model wires (with texture if set) // DrawModelWires - Draw a model wires (with texture if set)
func DrawModelWires(model Model, position Vector3, scale float32, tint Color) { func DrawModelWires(model Model, position Vector3, scale float32, tint color.RGBA) {
cmodel := model.cptr() cmodel := model.cptr()
cposition := position.cptr() cposition := position.cptr()
cscale := (C.float)(scale) cscale := (C.float)(scale)
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawModelWires(*cmodel, *cposition, cscale, *ctint) C.DrawModelWires(*cmodel, *cposition, cscale, *ctint)
} }
// DrawModelWiresEx - Draw a model wires (with texture if set) with extended parameters // DrawModelWiresEx - Draw a model wires (with texture if set) with extended parameters
func DrawModelWiresEx(model Model, position Vector3, rotationAxis Vector3, rotationAngle float32, scale Vector3, tint Color) { func DrawModelWiresEx(model Model, position Vector3, rotationAxis Vector3, rotationAngle float32, scale Vector3, tint color.RGBA) {
cmodel := model.cptr() cmodel := model.cptr()
cposition := position.cptr() cposition := position.cptr()
crotationAxis := rotationAxis.cptr() crotationAxis := rotationAxis.cptr()
crotationAngle := (C.float)(rotationAngle) crotationAngle := (C.float)(rotationAngle)
cscale := scale.cptr() cscale := scale.cptr()
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawModelWiresEx(*cmodel, *cposition, *crotationAxis, crotationAngle, *cscale, *ctint) C.DrawModelWiresEx(*cmodel, *cposition, *crotationAxis, crotationAngle, *cscale, *ctint)
} }
// DrawBoundingBox - Draw bounding box (wires) // DrawBoundingBox - Draw bounding box (wires)
func DrawBoundingBox(box BoundingBox, color Color) { func DrawBoundingBox(box BoundingBox, col color.RGBA) {
cbox := box.cptr() cbox := box.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawBoundingBox(*cbox, *ccolor) C.DrawBoundingBox(*cbox, *ccolor)
} }
// DrawBillboard - Draw a billboard texture // DrawBillboard - Draw a billboard texture
func DrawBillboard(camera Camera, texture Texture2D, center Vector3, size float32, tint Color) { func DrawBillboard(camera Camera, texture Texture2D, center Vector3, size float32, tint color.RGBA) {
ccamera := camera.cptr() ccamera := camera.cptr()
ctexture := texture.cptr() ctexture := texture.cptr()
ccenter := center.cptr() ccenter := center.cptr()
csize := (C.float)(size) csize := (C.float)(size)
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawBillboard(*ccamera, *ctexture, *ccenter, csize, *ctint) C.DrawBillboard(*ccamera, *ctexture, *ccenter, csize, *ctint)
} }
// DrawBillboardRec - Draw a billboard texture defined by sourceRec // DrawBillboardRec - Draw a billboard texture defined by sourceRec
func DrawBillboardRec(camera Camera, texture Texture2D, sourceRec Rectangle, center Vector3, size Vector2, tint Color) { func DrawBillboardRec(camera Camera, texture Texture2D, sourceRec Rectangle, center Vector3, size Vector2, tint color.RGBA) {
ccamera := camera.cptr() ccamera := camera.cptr()
ctexture := texture.cptr() ctexture := texture.cptr()
csourceRec := sourceRec.cptr() csourceRec := sourceRec.cptr()
ccenter := center.cptr() ccenter := center.cptr()
csize := size.cptr() csize := size.cptr()
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawBillboardRec(*ccamera, *ctexture, *csourceRec, *ccenter, *csize, *ctint) C.DrawBillboardRec(*ccamera, *ctexture, *csourceRec, *ccenter, *csize, *ctint)
} }

View file

@ -5,315 +5,318 @@ package rl
#include <stdlib.h> #include <stdlib.h>
*/ */
import "C" import "C"
import "unsafe" import (
"image/color"
"unsafe"
)
// DrawPixel - Draw a pixel // DrawPixel - Draw a pixel
func DrawPixel(posX, posY int32, color Color) { func DrawPixel(posX, posY int32, col color.RGBA) {
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawPixel(cposX, cposY, *ccolor) C.DrawPixel(cposX, cposY, *ccolor)
} }
// DrawPixelV - Draw a pixel (Vector version) // DrawPixelV - Draw a pixel (Vector version)
func DrawPixelV(position Vector2, color Color) { func DrawPixelV(position Vector2, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawPixelV(*cposition, *ccolor) C.DrawPixelV(*cposition, *ccolor)
} }
// DrawLine - Draw a line // DrawLine - Draw a line
func DrawLine(startPosX, startPosY, endPosX, endPosY int32, color Color) { func DrawLine(startPosX, startPosY, endPosX, endPosY int32, col color.RGBA) {
cstartPosX := (C.int)(startPosX) cstartPosX := (C.int)(startPosX)
cstartPosY := (C.int)(startPosY) cstartPosY := (C.int)(startPosY)
cendPosX := (C.int)(endPosX) cendPosX := (C.int)(endPosX)
cendPosY := (C.int)(endPosY) cendPosY := (C.int)(endPosY)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawLine(cstartPosX, cstartPosY, cendPosX, cendPosY, *ccolor) C.DrawLine(cstartPosX, cstartPosY, cendPosX, cendPosY, *ccolor)
} }
// DrawLineV - Draw a line (Vector version) // DrawLineV - Draw a line (Vector version)
func DrawLineV(startPos, endPos Vector2, color Color) { func DrawLineV(startPos, endPos Vector2, col color.RGBA) {
cstartPos := startPos.cptr() cstartPos := startPos.cptr()
cendPos := endPos.cptr() cendPos := endPos.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawLineV(*cstartPos, *cendPos, *ccolor) C.DrawLineV(*cstartPos, *cendPos, *ccolor)
} }
// DrawLineEx - Draw a line defining thickness // DrawLineEx - Draw a line defining thickness
func DrawLineEx(startPos, endPos Vector2, thick float32, color Color) { func DrawLineEx(startPos, endPos Vector2, thick float32, col color.RGBA) {
cstartPos := startPos.cptr() cstartPos := startPos.cptr()
cendPos := endPos.cptr() cendPos := endPos.cptr()
cthick := (C.float)(thick) cthick := (C.float)(thick)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawLineEx(*cstartPos, *cendPos, cthick, *ccolor) C.DrawLineEx(*cstartPos, *cendPos, cthick, *ccolor)
} }
// DrawLineBezier - Draw a line using cubic-bezier curves in-out // DrawLineBezier - Draw a line using cubic-bezier curves in-out
func DrawLineBezier(startPos, endPos Vector2, thick float32, color Color) { func DrawLineBezier(startPos, endPos Vector2, thick float32, col color.RGBA) {
cstartPos := startPos.cptr() cstartPos := startPos.cptr()
cendPos := endPos.cptr() cendPos := endPos.cptr()
cthick := (C.float)(thick) cthick := (C.float)(thick)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawLineBezier(*cstartPos, *cendPos, cthick, *ccolor) C.DrawLineBezier(*cstartPos, *cendPos, cthick, *ccolor)
} }
// DrawCircle - Draw a color-filled circle // DrawCircle - Draw a color-filled circle
func DrawCircle(centerX, centerY int32, radius float32, color Color) { func DrawCircle(centerX, centerY int32, radius float32, col color.RGBA) {
ccenterX := (C.int)(centerX) ccenterX := (C.int)(centerX)
ccenterY := (C.int)(centerY) ccenterY := (C.int)(centerY)
cradius := (C.float)(radius) cradius := (C.float)(radius)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCircle(ccenterX, ccenterY, cradius, *ccolor) C.DrawCircle(ccenterX, ccenterY, cradius, *ccolor)
} }
// DrawCircleSector - Draw a piece of a circle // DrawCircleSector - Draw a piece of a circle
func DrawCircleSector(center Vector2, radius, startAngle, endAngle float32, segments int32, color Color) { func DrawCircleSector(center Vector2, radius, startAngle, endAngle float32, segments int32, col color.RGBA) {
ccenter := center.cptr() ccenter := center.cptr()
cradius := (C.float)(radius) cradius := (C.float)(radius)
cstartAngle := (C.float)(startAngle) cstartAngle := (C.float)(startAngle)
cendAngle := (C.float)(endAngle) cendAngle := (C.float)(endAngle)
csegments := (C.int)(segments) csegments := (C.int)(segments)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCircleSector(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor) C.DrawCircleSector(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor)
} }
// DrawCircleSectorLines - // DrawCircleSectorLines -
func DrawCircleSectorLines(center Vector2, radius, startAngle, endAngle float32, segments int32, color Color) { func DrawCircleSectorLines(center Vector2, radius, startAngle, endAngle float32, segments int32, col color.RGBA) {
ccenter := center.cptr() ccenter := center.cptr()
cradius := (C.float)(radius) cradius := (C.float)(radius)
cstartAngle := (C.float)(startAngle) cstartAngle := (C.float)(startAngle)
cendAngle := (C.float)(endAngle) cendAngle := (C.float)(endAngle)
csegments := (C.int)(segments) csegments := (C.int)(segments)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCircleSectorLines(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor) C.DrawCircleSectorLines(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor)
} }
// DrawCircleGradient - Draw a gradient-filled circle // DrawCircleGradient - Draw a gradient-filled circle
func DrawCircleGradient(centerX, centerY int32, radius float32, color1, color2 Color) { func DrawCircleGradient(centerX, centerY int32, radius float32, col1, col2 color.RGBA) {
ccenterX := (C.int)(centerX) ccenterX := (C.int)(centerX)
ccenterY := (C.int)(centerY) ccenterY := (C.int)(centerY)
cradius := (C.float)(radius) cradius := (C.float)(radius)
ccolor1 := color1.cptr() ccolor1 := colorCptr(col1)
ccolor2 := color2.cptr() ccolor2 := colorCptr(col2)
C.DrawCircleGradient(ccenterX, ccenterY, cradius, *ccolor1, *ccolor2) C.DrawCircleGradient(ccenterX, ccenterY, cradius, *ccolor1, *ccolor2)
} }
// DrawCircleV - Draw a color-filled circle (Vector version) // DrawCircleV - Draw a color-filled circle (Vector version)
func DrawCircleV(center Vector2, radius float32, color Color) { func DrawCircleV(center Vector2, radius float32, col color.RGBA) {
ccenter := center.cptr() ccenter := center.cptr()
cradius := (C.float)(radius) cradius := (C.float)(radius)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCircleV(*ccenter, cradius, *ccolor) C.DrawCircleV(*ccenter, cradius, *ccolor)
} }
// DrawCircleLines - Draw circle outline // DrawCircleLines - Draw circle outline
func DrawCircleLines(centerX, centerY int32, radius float32, color Color) { func DrawCircleLines(centerX, centerY int32, radius float32, col color.RGBA) {
ccenterX := (C.int)(centerX) ccenterX := (C.int)(centerX)
ccenterY := (C.int)(centerY) ccenterY := (C.int)(centerY)
cradius := (C.float)(radius) cradius := (C.float)(radius)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawCircleLines(ccenterX, ccenterY, cradius, *ccolor) C.DrawCircleLines(ccenterX, ccenterY, cradius, *ccolor)
} }
// DrawEllipse - Draw ellipse // DrawEllipse - Draw ellipse
func DrawEllipse(centerX, centerY int32, radiusH, radiusV float32, color Color) { func DrawEllipse(centerX, centerY int32, radiusH, radiusV float32, col color.RGBA) {
ccenterX := (C.int)(centerX) ccenterX := (C.int)(centerX)
ccenterY := (C.int)(centerY) ccenterY := (C.int)(centerY)
cradiusH := (C.float)(radiusH) cradiusH := (C.float)(radiusH)
cradiusV := (C.float)(radiusV) cradiusV := (C.float)(radiusV)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawEllipse(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor) C.DrawEllipse(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor)
} }
// DrawEllipseLines - Draw ellipse outline // DrawEllipseLines - Draw ellipse outline
func DrawEllipseLines(centerX, centerY int32, radiusH, radiusV float32, color Color) { func DrawEllipseLines(centerX, centerY int32, radiusH, radiusV float32, col color.RGBA) {
ccenterX := (C.int)(centerX) ccenterX := (C.int)(centerX)
ccenterY := (C.int)(centerY) ccenterY := (C.int)(centerY)
cradiusH := (C.float)(radiusH) cradiusH := (C.float)(radiusH)
cradiusV := (C.float)(radiusV) cradiusV := (C.float)(radiusV)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawEllipseLines(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor) C.DrawEllipseLines(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor)
} }
// DrawRing - // DrawRing -
func DrawRing(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, color Color) { 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)
couterRadius := (C.float)(outerRadius) couterRadius := (C.float)(outerRadius)
cstartAngle := (C.float)(startAngle) cstartAngle := (C.float)(startAngle)
cendAngle := (C.float)(endAngle) cendAngle := (C.float)(endAngle)
csegments := (C.int)(segments) csegments := (C.int)(segments)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRing(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor) C.DrawRing(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor)
} }
// DrawRingLines - // DrawRingLines -
func DrawRingLines(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, color Color) { 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)
couterRadius := (C.float)(outerRadius) couterRadius := (C.float)(outerRadius)
cstartAngle := (C.float)(startAngle) cstartAngle := (C.float)(startAngle)
cendAngle := (C.float)(endAngle) cendAngle := (C.float)(endAngle)
csegments := (C.int)(segments) csegments := (C.int)(segments)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRingLines(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor) C.DrawRingLines(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor)
} }
// DrawRectangle - Draw a color-filled rectangle // DrawRectangle - Draw a color-filled rectangle
func DrawRectangle(posX, posY, width, height int32, color Color) { func DrawRectangle(posX, posY, width, height int32, col color.RGBA) {
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectangle(cposX, cposY, cwidth, cheight, *ccolor) C.DrawRectangle(cposX, cposY, cwidth, cheight, *ccolor)
} }
// DrawRectangleRec - Draw a color-filled rectangle // DrawRectangleRec - Draw a color-filled rectangle
func DrawRectangleRec(rec Rectangle, color Color) { func DrawRectangleRec(rec Rectangle, col color.RGBA) {
crec := rec.cptr() crec := rec.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectangleRec(*crec, *ccolor) C.DrawRectangleRec(*crec, *ccolor)
} }
// DrawRectanglePro - Draw a color-filled rectangle with pro parameters // DrawRectanglePro - Draw a color-filled rectangle with pro parameters
func DrawRectanglePro(rec Rectangle, origin Vector2, rotation float32, color Color) { func DrawRectanglePro(rec Rectangle, origin Vector2, rotation float32, col color.RGBA) {
crec := rec.cptr() crec := rec.cptr()
corigin := origin.cptr() corigin := origin.cptr()
crotation := (C.float)(rotation) crotation := (C.float)(rotation)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectanglePro(*crec, *corigin, crotation, *ccolor) C.DrawRectanglePro(*crec, *corigin, crotation, *ccolor)
} }
// DrawRectangleGradientV - Draw a vertical-gradient-filled rectangle // DrawRectangleGradientV - Draw a vertical-gradient-filled rectangle
func DrawRectangleGradientV(posX, posY, width, height int32, color1, color2 Color) { func DrawRectangleGradientV(posX, posY, width, height int32, col1, col2 color.RGBA) {
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
ccolor1 := color1.cptr() ccolor1 := colorCptr(col1)
ccolor2 := color2.cptr() ccolor2 := colorCptr(col2)
C.DrawRectangleGradientV(cposX, cposY, cwidth, cheight, *ccolor1, *ccolor2) C.DrawRectangleGradientV(cposX, cposY, cwidth, cheight, *ccolor1, *ccolor2)
} }
// DrawRectangleGradientH - Draw a horizontal-gradient-filled rectangle // DrawRectangleGradientH - Draw a horizontal-gradient-filled rectangle
func DrawRectangleGradientH(posX, posY, width, height int32, color1, color2 Color) { func DrawRectangleGradientH(posX, posY, width, height int32, col1, col2 color.RGBA) {
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
ccolor1 := color1.cptr() ccolor1 := colorCptr(col1)
ccolor2 := color2.cptr() ccolor2 := colorCptr(col2)
C.DrawRectangleGradientH(cposX, cposY, cwidth, cheight, *ccolor1, *ccolor2) C.DrawRectangleGradientH(cposX, cposY, cwidth, cheight, *ccolor1, *ccolor2)
} }
// DrawRectangleGradientEx - Draw a gradient-filled rectangle with custom vertex colors // DrawRectangleGradientEx - Draw a gradient-filled rectangle with custom vertex colors
func DrawRectangleGradientEx(rec Rectangle, color1, color2, color3, color4 Color) { func DrawRectangleGradientEx(rec Rectangle, col1, col2, col3, col4 color.RGBA) {
crec := rec.cptr() crec := rec.cptr()
ccolor1 := color1.cptr() ccolor1 := colorCptr(col1)
ccolor2 := color2.cptr() ccolor2 := colorCptr(col2)
ccolor3 := color3.cptr() ccolor3 := colorCptr(col3)
ccolor4 := color4.cptr() ccolor4 := colorCptr(col4)
C.DrawRectangleGradientEx(*crec, *ccolor1, *ccolor2, *ccolor3, *ccolor4) C.DrawRectangleGradientEx(*crec, *ccolor1, *ccolor2, *ccolor3, *ccolor4)
} }
// DrawRectangleV - Draw a color-filled rectangle (Vector version) // DrawRectangleV - Draw a color-filled rectangle (Vector version)
func DrawRectangleV(position Vector2, size Vector2, color Color) { func DrawRectangleV(position Vector2, size Vector2, col color.RGBA) {
cposition := position.cptr() cposition := position.cptr()
csize := size.cptr() csize := size.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectangleV(*cposition, *csize, *ccolor) C.DrawRectangleV(*cposition, *csize, *ccolor)
} }
// DrawRectangleLines - Draw rectangle outline // DrawRectangleLines - Draw rectangle outline
func DrawRectangleLines(posX, posY, width, height int32, color Color) { func DrawRectangleLines(posX, posY, width, height int32, col color.RGBA) {
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectangleLines(cposX, cposY, cwidth, cheight, *ccolor) C.DrawRectangleLines(cposX, cposY, cwidth, cheight, *ccolor)
} }
// DrawRectangleLinesEx - Draw rectangle outline with extended parameters // DrawRectangleLinesEx - Draw rectangle outline with extended parameters
func DrawRectangleLinesEx(rec Rectangle, lineThick float32, color Color) { func DrawRectangleLinesEx(rec Rectangle, lineThick float32, col color.RGBA) {
crec := rec.cptr() crec := rec.cptr()
clineThick := (C.float)(lineThick) clineThick := (C.float)(lineThick)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectangleLinesEx(*crec, clineThick, *ccolor) C.DrawRectangleLinesEx(*crec, clineThick, *ccolor)
} }
// DrawRectangleRounded - Draw rectangle with rounded edges // DrawRectangleRounded - Draw rectangle with rounded edges
func DrawRectangleRounded(rec Rectangle, roundness float32, segments int32, color Color) { func DrawRectangleRounded(rec Rectangle, roundness float32, segments int32, col color.RGBA) {
crec := rec.cptr() crec := rec.cptr()
croundness := (C.float)(roundness) croundness := (C.float)(roundness)
csegments := (C.int)(segments) csegments := (C.int)(segments)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectangleRounded(*crec, croundness, csegments, *ccolor) C.DrawRectangleRounded(*crec, croundness, csegments, *ccolor)
} }
// DrawRectangleRoundedLines - Draw rectangle with rounded edges outline // DrawRectangleRoundedLines - Draw rectangle with rounded edges outline
func DrawRectangleRoundedLines(rec Rectangle, roundness float32, segments, lineThick float32, color Color) { func DrawRectangleRoundedLines(rec Rectangle, roundness float32, segments, lineThick float32, col color.RGBA) {
crec := rec.cptr() crec := rec.cptr()
croundness := (C.float)(roundness) croundness := (C.float)(roundness)
csegments := (C.int)(segments) csegments := (C.int)(segments)
clineThick := (C.float)(lineThick) clineThick := (C.float)(lineThick)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawRectangleRoundedLines(*crec, croundness, csegments, clineThick, *ccolor) C.DrawRectangleRoundedLines(*crec, croundness, csegments, clineThick, *ccolor)
} }
// DrawTriangle - Draw a color-filled triangle // DrawTriangle - Draw a color-filled triangle
func DrawTriangle(v1, v2, v3 Vector2, color Color) { func DrawTriangle(v1, v2, v3 Vector2, col color.RGBA) {
cv1 := v1.cptr() cv1 := v1.cptr()
cv2 := v2.cptr() cv2 := v2.cptr()
cv3 := v3.cptr() cv3 := v3.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawTriangle(*cv1, *cv2, *cv3, *ccolor) C.DrawTriangle(*cv1, *cv2, *cv3, *ccolor)
} }
// DrawTriangleLines - Draw triangle outline // DrawTriangleLines - Draw triangle outline
func DrawTriangleLines(v1, v2, v3 Vector2, color Color) { func DrawTriangleLines(v1, v2, v3 Vector2, col color.RGBA) {
cv1 := v1.cptr() cv1 := v1.cptr()
cv2 := v2.cptr() cv2 := v2.cptr()
cv3 := v3.cptr() cv3 := v3.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawTriangleLines(*cv1, *cv2, *cv3, *ccolor) C.DrawTriangleLines(*cv1, *cv2, *cv3, *ccolor)
} }
// DrawTriangleFan - Draw a triangle fan defined by points // DrawTriangleFan - Draw a triangle fan defined by points
func DrawTriangleFan(points []Vector2, color Color) { func DrawTriangleFan(points []Vector2, col color.RGBA) {
cpoints := (*C.Vector2)(unsafe.Pointer(&points[0])) cpoints := (*C.Vector2)(unsafe.Pointer(&points[0]))
cpointsCount := (C.int)(int32(len(points))) cpointsCount := (C.int)(int32(len(points)))
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawTriangleFan(cpoints, cpointsCount, *ccolor) C.DrawTriangleFan(cpoints, cpointsCount, *ccolor)
} }
// DrawTriangleStrip - Draw a triangle strip defined by points // DrawTriangleStrip - Draw a triangle strip defined by points
func DrawTriangleStrip(points []Vector2, color Color) { func DrawTriangleStrip(points []Vector2, col color.RGBA) {
cpoints := (*C.Vector2)(unsafe.Pointer(&points[0])) cpoints := (*C.Vector2)(unsafe.Pointer(&points[0]))
cpointsCount := (C.int)(int32(len(points))) cpointsCount := (C.int)(int32(len(points)))
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawTriangleStrip(cpoints, cpointsCount, *ccolor) C.DrawTriangleStrip(cpoints, cpointsCount, *ccolor)
} }
// DrawPoly - Draw a regular polygon (Vector version) // DrawPoly - Draw a regular polygon (Vector version)
func DrawPoly(center Vector2, sides int32, radius, rotation float32, color Color) { func DrawPoly(center Vector2, sides int32, radius, rotation float32, col color.RGBA) {
ccenter := center.cptr() ccenter := center.cptr()
csides := (C.int)(sides) csides := (C.int)(sides)
cradius := (C.float)(radius) cradius := (C.float)(radius)
crotation := (C.float)(rotation) crotation := (C.float)(rotation)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawPoly(*ccenter, csides, cradius, crotation, *ccolor) C.DrawPoly(*ccenter, csides, cradius, crotation, *ccolor)
} }
// DrawPolyLines - Draw a polygon outline of n sides // DrawPolyLines - Draw a polygon outline of n sides
func DrawPolyLines(center Vector2, sides int32, radius, rotation float32, color Color) { func DrawPolyLines(center Vector2, sides int32, radius, rotation float32, col color.RGBA) {
ccenter := center.cptr() ccenter := center.cptr()
csides := (C.int)(sides) csides := (C.int)(sides)
cradius := (C.float)(radius) cradius := (C.float)(radius)
crotation := (C.float)(rotation) crotation := (C.float)(rotation)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawPolyLines(*ccenter, csides, cradius, crotation, *ccolor) C.DrawPolyLines(*ccenter, csides, cradius, crotation, *ccolor)
} }

View file

@ -5,7 +5,10 @@ package rl
#include <stdlib.h> #include <stdlib.h>
*/ */
import "C" import "C"
import "unsafe" import (
"image/color"
"unsafe"
)
// cptr returns C pointer // cptr returns C pointer
func (c *GlyphInfo) cptr() *C.GlyphInfo { func (c *GlyphInfo) cptr() *C.GlyphInfo {
@ -46,9 +49,9 @@ func LoadFontEx(fileName string, fontSize int32, fontChars *int32, charsCount in
} }
// LoadFontFromImage - Loads an Image font file (XNA style) // LoadFontFromImage - Loads an Image font file (XNA style)
func LoadFontFromImage(image Image, key Color, firstChar int32) Font { func LoadFontFromImage(image Image, key color.RGBA, firstChar int32) Font {
cimage := image.cptr() cimage := image.cptr()
ckey := key.cptr() ckey := colorCptr(key)
cfirstChar := (C.int)(firstChar) cfirstChar := (C.int)(firstChar)
ret := C.LoadFontFromImage(*cimage, *ckey, cfirstChar) ret := C.LoadFontFromImage(*cimage, *ckey, cfirstChar)
v := newFontFromPointer(unsafe.Pointer(&ret)) v := newFontFromPointer(unsafe.Pointer(&ret))
@ -89,25 +92,25 @@ func UnloadFont(font Font) {
} }
// DrawText - Draw text (using default font) // DrawText - Draw text (using default font)
func DrawText(text string, posX int32, posY int32, fontSize int32, color Color) { func DrawText(text string, posX int32, posY int32, 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)
cposY := (C.int)(posY) cposY := (C.int)(posY)
cfontSize := (C.int)(fontSize) cfontSize := (C.int)(fontSize)
ccolor := color.cptr() ccolor := colorCptr(col)
C.DrawText(ctext, cposX, cposY, cfontSize, *ccolor) C.DrawText(ctext, cposX, cposY, cfontSize, *ccolor)
} }
// DrawTextEx - Draw text using Font and additional parameters // DrawTextEx - Draw text using Font and additional parameters
func DrawTextEx(font Font, text string, position Vector2, fontSize float32, spacing float32, tint Color) { func DrawTextEx(font Font, text string, position Vector2, fontSize float32, spacing float32, tint color.RGBA) {
cfont := font.cptr() cfont := font.cptr()
ctext := C.CString(text) ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext)) defer C.free(unsafe.Pointer(ctext))
cposition := position.cptr() cposition := position.cptr()
cfontSize := (C.float)(fontSize) cfontSize := (C.float)(fontSize)
cspacing := (C.float)(spacing) cspacing := (C.float)(spacing)
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawTextEx(*cfont, ctext, *cposition, cfontSize, cspacing, *ctint) C.DrawTextEx(*cfont, ctext, *cposition, cfontSize, cspacing, *ctint)
} }

View file

@ -8,6 +8,7 @@ import "C"
import ( import (
"image" "image"
"image/color"
"unsafe" "unsafe"
) )
@ -128,10 +129,10 @@ func UnloadRenderTexture(target RenderTexture2D) {
} }
// LoadImageColors - Get pixel data from image as a Color slice // LoadImageColors - Get pixel data from image as a Color slice
func LoadImageColors(img *Image) []Color { func LoadImageColors(img *Image) []color.RGBA {
cimg := img.cptr() cimg := img.cptr()
ret := C.LoadImageColors(*cimg) ret := C.LoadImageColors(*cimg)
return (*[1 << 24]Color)(unsafe.Pointer(ret))[0 : img.Width*img.Height] return (*[1 << 24]color.RGBA)(unsafe.Pointer(ret))[0 : img.Width*img.Height]
} }
// LoadImageFromTexture - Get pixel data from GPU texture and return an Image // LoadImageFromTexture - Get pixel data from GPU texture and return an Image
@ -143,14 +144,14 @@ func LoadImageFromTexture(texture Texture2D) *Image {
} }
// UpdateTexture - Update GPU texture with new data // UpdateTexture - Update GPU texture with new data
func UpdateTexture(texture Texture2D, pixels []Color) { func UpdateTexture(texture Texture2D, pixels []color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
cpixels := unsafe.Pointer(&pixels[0]) cpixels := unsafe.Pointer(&pixels[0])
C.UpdateTexture(*ctexture, cpixels) C.UpdateTexture(*ctexture, cpixels)
} }
// UpdateTextureRec - Update GPU texture rectangle with new data // UpdateTextureRec - Update GPU texture rectangle with new data
func UpdateTextureRec(texture Texture2D, rec Rectangle, pixels []Color) { func UpdateTextureRec(texture Texture2D, rec Rectangle, pixels []color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
cpixels := unsafe.Pointer(&pixels[0]) cpixels := unsafe.Pointer(&pixels[0])
crec := rec.cptr() crec := rec.cptr()
@ -175,24 +176,24 @@ func ImageCopy(image *Image) *Image {
} }
// ImageText - Create an image from text (default font) // ImageText - Create an image from text (default font)
func ImageText(text string, fontSize int32, color Color) *Image { func ImageText(text string, fontSize int32, col color.RGBA) *Image {
ctext := C.CString(text) ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext)) defer C.free(unsafe.Pointer(ctext))
cfontSize := (C.int)(fontSize) cfontSize := (C.int)(fontSize)
ccolor := color.cptr() ccolor := colorCptr(col)
ret := C.ImageText(ctext, cfontSize, *ccolor) ret := C.ImageText(ctext, cfontSize, *ccolor)
v := newImageFromPointer(unsafe.Pointer(&ret)) v := newImageFromPointer(unsafe.Pointer(&ret))
return v return v
} }
// ImageTextEx - Create an image from text (custom sprite font) // ImageTextEx - Create an image from text (custom sprite font)
func ImageTextEx(font Font, text string, fontSize, spacing float32, tint Color) *Image { func ImageTextEx(font Font, text string, fontSize, spacing float32, tint color.RGBA) *Image {
cfont := font.cptr() cfont := font.cptr()
ctext := C.CString(text) ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext)) defer C.free(unsafe.Pointer(ctext))
cfontSize := (C.float)(fontSize) cfontSize := (C.float)(fontSize)
cspacing := (C.float)(spacing) cspacing := (C.float)(spacing)
ctint := tint.cptr() ctint := colorCptr(tint)
ret := C.ImageTextEx(*cfont, ctext, cfontSize, cspacing, *ctint) ret := C.ImageTextEx(*cfont, ctext, cfontSize, cspacing, *ctint)
v := newImageFromPointer(unsafe.Pointer(&ret)) v := newImageFromPointer(unsafe.Pointer(&ret))
return v return v
@ -206,9 +207,9 @@ func ImageFormat(image *Image, newFormat PixelFormat) {
} }
// ImageToPOT - Convert image to POT (power-of-two) // ImageToPOT - Convert image to POT (power-of-two)
func ImageToPOT(image *Image, fillColor Color) { func ImageToPOT(image *Image, fillColor color.RGBA) {
cimage := image.cptr() cimage := image.cptr()
cfillColor := fillColor.cptr() cfillColor := colorCptr(fillColor)
C.ImageToPOT(cimage, *cfillColor) C.ImageToPOT(cimage, *cfillColor)
} }
@ -227,9 +228,9 @@ func ImageAlphaCrop(image *Image, threshold float32) {
} }
// ImageAlphaClear - Apply alpha mask to image // ImageAlphaClear - Apply alpha mask to image
func ImageAlphaClear(image *Image, color Color, threshold float32) { func ImageAlphaClear(image *Image, col color.RGBA, threshold float32) {
cimage := image.cptr() cimage := image.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
cthreshold := (C.float)(threshold) cthreshold := (C.float)(threshold)
C.ImageAlphaClear(cimage, *ccolor, cthreshold) C.ImageAlphaClear(cimage, *ccolor, cthreshold)
} }
@ -264,13 +265,13 @@ func ImageResizeNN(image *Image, newWidth, newHeight int32) {
} }
// ImageResizeCanvas - Resize canvas and fill with color // ImageResizeCanvas - Resize canvas and fill with color
func ImageResizeCanvas(image *Image, newWidth, newHeight, offsetX, offsetY int32, color Color) { func ImageResizeCanvas(image *Image, newWidth, newHeight, offsetX, offsetY int32, col color.RGBA) {
cimage := image.cptr() cimage := image.cptr()
cnewWidth := (C.int)(newWidth) cnewWidth := (C.int)(newWidth)
cnewHeight := (C.int)(newHeight) cnewHeight := (C.int)(newHeight)
coffsetX := (C.int)(offsetX) coffsetX := (C.int)(offsetX)
coffsetY := (C.int)(offsetY) coffsetY := (C.int)(offsetY)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageResizeCanvas(cimage, cnewWidth, cnewHeight, coffsetX, coffsetY, *ccolor) C.ImageResizeCanvas(cimage, cnewWidth, cnewHeight, coffsetX, coffsetY, *ccolor)
} }
@ -315,9 +316,9 @@ func ImageRotateCCW(image *Image) {
} }
// ImageColorTint - Modify image color: tint // ImageColorTint - Modify image color: tint
func ImageColorTint(image *Image, color Color) { func ImageColorTint(image *Image, col color.RGBA) {
cimage := image.cptr() cimage := image.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageColorTint(cimage, *ccolor) C.ImageColorTint(cimage, *ccolor)
} }
@ -348,15 +349,15 @@ func ImageColorBrightness(image *Image, brightness int32) {
} }
// ImageColorReplace - Modify image color: replace color // ImageColorReplace - Modify image color: replace color
func ImageColorReplace(image *Image, color, replace Color) { func ImageColorReplace(image *Image, col, replace color.RGBA) {
cimage := image.cptr() cimage := image.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
creplace := replace.cptr() creplace := colorCptr(replace)
C.ImageColorReplace(cimage, *ccolor, *creplace) C.ImageColorReplace(cimage, *ccolor, *creplace)
} }
// GetImageColor - Get image pixel color at (x, y) position // GetImageColor - Get image pixel color at (x, y) position
func GetImageColor(image Image, x, y int32) Color { func GetImageColor(image Image, x, y int32) color.RGBA {
cimage := image.cptr() cimage := image.cptr()
cx := (C.int)(x) cx := (C.int)(x)
cy := (C.int)(y) cy := (C.int)(y)
@ -367,109 +368,109 @@ func GetImageColor(image Image, x, y int32) Color {
} }
// ImageClearBackground - Clear image background with given color // ImageClearBackground - Clear image background with given color
func ImageClearBackground(dst *Image, color Color) { func ImageClearBackground(dst *Image, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageClearBackground(cdst, *ccolor) C.ImageClearBackground(cdst, *ccolor)
} }
// ImageDraw - Draw a source image within a destination image // ImageDraw - Draw a source image within a destination image
func ImageDraw(dst, src *Image, srcRec, dstRec Rectangle, tint Color) { func ImageDraw(dst, src *Image, srcRec, dstRec Rectangle, tint color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
csrc := src.cptr() csrc := src.cptr()
csrcRec := srcRec.cptr() csrcRec := srcRec.cptr()
cdstRec := dstRec.cptr() cdstRec := dstRec.cptr()
ctint := tint.cptr() ctint := colorCptr(tint)
C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint) C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint)
} }
// ImageDrawCircle - Draw circle within an image // ImageDrawCircle - Draw circle within an image
func ImageDrawCircle(dst *Image, centerX, centerY, radius int32, color Color) { func ImageDrawCircle(dst *Image, centerX, centerY, radius int32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
ccenterX := (C.int)(centerX) ccenterX := (C.int)(centerX)
ccenterY := (C.int)(centerY) ccenterY := (C.int)(centerY)
cradius := (C.int)(radius) cradius := (C.int)(radius)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawCircle(cdst, ccenterX, ccenterY, cradius, *ccolor) C.ImageDrawCircle(cdst, ccenterX, ccenterY, cradius, *ccolor)
} }
// ImageDrawCircleV - Draw circle within an image // ImageDrawCircleV - Draw circle within an image
func ImageDrawCircleV(dst *Image, center Vector2, radius int32, color Color) { func ImageDrawCircleV(dst *Image, center Vector2, radius int32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
ccenter := center.cptr() ccenter := center.cptr()
cradius := (C.int)(radius) cradius := (C.int)(radius)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawCircleV(cdst, *ccenter, cradius, *ccolor) C.ImageDrawCircleV(cdst, *ccenter, cradius, *ccolor)
} }
// ImageDrawPixel - Draw pixel within an image // ImageDrawPixel - Draw pixel within an image
func ImageDrawPixel(dst *Image, posX, posY int32, color Color) { func ImageDrawPixel(dst *Image, posX, posY int32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawPixel(cdst, cposX, cposY, *ccolor) C.ImageDrawPixel(cdst, cposX, cposY, *ccolor)
} }
// ImageDrawPixelV - Draw pixel within an image (Vector version) // ImageDrawPixelV - Draw pixel within an image (Vector version)
func ImageDrawPixelV(dst *Image, position Vector2, color Color) { func ImageDrawPixelV(dst *Image, position Vector2, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
cposition := position.cptr() cposition := position.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawPixelV(cdst, *cposition, *ccolor) C.ImageDrawPixelV(cdst, *cposition, *ccolor)
} }
// ImageDrawRectangle - Draw rectangle within an image // ImageDrawRectangle - Draw rectangle within an image
func ImageDrawRectangle(dst *Image, x, y, width, height int32, color Color) { func ImageDrawRectangle(dst *Image, x, y, width, height int32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
cx := (C.int)(x) cx := (C.int)(x)
cy := (C.int)(y) cy := (C.int)(y)
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawRectangle(cdst, cx, cy, cwidth, cheight, *ccolor) C.ImageDrawRectangle(cdst, cx, cy, cwidth, cheight, *ccolor)
} }
// ImageDrawRectangleV - Draw rectangle within an image (Vector version) // ImageDrawRectangleV - Draw rectangle within an image (Vector version)
func ImageDrawRectangleV(dst *Image, position, size Vector2, color Color) { func ImageDrawRectangleV(dst *Image, position, size Vector2, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
cposition := position.cptr() cposition := position.cptr()
csize := size.cptr() csize := size.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawRectangleV(cdst, *cposition, *csize, *ccolor) C.ImageDrawRectangleV(cdst, *cposition, *csize, *ccolor)
} }
// ImageDrawRectangleLines - Draw rectangle lines within an image // ImageDrawRectangleLines - Draw rectangle lines within an image
func ImageDrawRectangleLines(dst *Image, rec Rectangle, thick int, color Color) { func ImageDrawRectangleLines(dst *Image, rec Rectangle, thick int, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
crec := rec.cptr() crec := rec.cptr()
cthick := (C.int)(thick) cthick := (C.int)(thick)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawRectangleLines(cdst, *crec, cthick, *ccolor) C.ImageDrawRectangleLines(cdst, *crec, cthick, *ccolor)
} }
// ImageDrawRectangleRec - Draw rectangle within an image // ImageDrawRectangleRec - Draw rectangle within an image
func ImageDrawRectangleRec(dst *Image, rec Rectangle, color Color) { func ImageDrawRectangleRec(dst *Image, rec Rectangle, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
crec := rec.cptr() crec := rec.cptr()
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawRectangleRec(cdst, *crec, *ccolor) C.ImageDrawRectangleRec(cdst, *crec, *ccolor)
} }
// ImageDrawText - Draw text (default font) within an image (destination) // ImageDrawText - Draw text (default font) within an image (destination)
func ImageDrawText(dst *Image, posX, posY int32, text string, fontSize int32, color Color) { func ImageDrawText(dst *Image, posX, posY int32, text string, fontSize int32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
posx := (C.int)(posX) posx := (C.int)(posX)
posy := (C.int)(posY) posy := (C.int)(posY)
ctext := C.CString(text) ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext)) defer C.free(unsafe.Pointer(ctext))
cfontSize := (C.int)(fontSize) cfontSize := (C.int)(fontSize)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawText(cdst, ctext, posx, posy, cfontSize, *ccolor) C.ImageDrawText(cdst, ctext, posx, posy, cfontSize, *ccolor)
} }
// ImageDrawTextEx - Draw text (custom sprite font) within an image (destination) // ImageDrawTextEx - Draw text (custom sprite font) within an image (destination)
func ImageDrawTextEx(dst *Image, position Vector2, font Font, text string, fontSize, spacing float32, color Color) { func ImageDrawTextEx(dst *Image, position Vector2, font Font, text string, fontSize, spacing float32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
cposition := position.cptr() cposition := position.cptr()
cfont := font.cptr() cfont := font.cptr()
@ -477,15 +478,15 @@ func ImageDrawTextEx(dst *Image, position Vector2, font Font, text string, fontS
defer C.free(unsafe.Pointer(ctext)) defer C.free(unsafe.Pointer(ctext))
cfontSize := (C.float)(fontSize) cfontSize := (C.float)(fontSize)
cspacing := (C.float)(spacing) cspacing := (C.float)(spacing)
ccolor := color.cptr() ccolor := colorCptr(col)
C.ImageDrawTextEx(cdst, *cfont, ctext, *cposition, cfontSize, cspacing, *ccolor) C.ImageDrawTextEx(cdst, *cfont, ctext, *cposition, cfontSize, cspacing, *ccolor)
} }
// GenImageColor - Generate image: plain color // GenImageColor - Generate image: plain color
func GenImageColor(width, height int, color Color) *Image { func GenImageColor(width, height int, col color.RGBA) *Image {
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
ccolor := color.cptr() ccolor := colorCptr(col)
ret := C.GenImageColor(cwidth, cheight, *ccolor) ret := C.GenImageColor(cwidth, cheight, *ccolor)
v := newImageFromPointer(unsafe.Pointer(&ret)) v := newImageFromPointer(unsafe.Pointer(&ret))
@ -493,11 +494,11 @@ func GenImageColor(width, height int, color Color) *Image {
} }
// GenImageGradientV - Generate image: vertical gradient // GenImageGradientV - Generate image: vertical gradient
func GenImageGradientV(width, height int, top, bottom Color) *Image { func GenImageGradientV(width, height int, top, bottom color.RGBA) *Image {
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
ctop := top.cptr() ctop := colorCptr(top)
cbottom := bottom.cptr() cbottom := colorCptr(bottom)
ret := C.GenImageGradientV(cwidth, cheight, *ctop, *cbottom) ret := C.GenImageGradientV(cwidth, cheight, *ctop, *cbottom)
v := newImageFromPointer(unsafe.Pointer(&ret)) v := newImageFromPointer(unsafe.Pointer(&ret))
@ -505,11 +506,11 @@ func GenImageGradientV(width, height int, top, bottom Color) *Image {
} }
// GenImageGradientH - Generate image: horizontal gradient // GenImageGradientH - Generate image: horizontal gradient
func GenImageGradientH(width, height int, left, right Color) *Image { func GenImageGradientH(width, height int, left, right color.RGBA) *Image {
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
cleft := left.cptr() cleft := colorCptr(left)
cright := right.cptr() cright := colorCptr(right)
ret := C.GenImageGradientH(cwidth, cheight, *cleft, *cright) ret := C.GenImageGradientH(cwidth, cheight, *cleft, *cright)
v := newImageFromPointer(unsafe.Pointer(&ret)) v := newImageFromPointer(unsafe.Pointer(&ret))
@ -517,12 +518,12 @@ func GenImageGradientH(width, height int, left, right Color) *Image {
} }
// GenImageGradientRadial - Generate image: radial gradient // GenImageGradientRadial - Generate image: radial gradient
func GenImageGradientRadial(width, height int, density float32, inner, outer Color) *Image { func GenImageGradientRadial(width, height int, density float32, inner, outer color.RGBA) *Image {
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
cdensity := (C.float)(density) cdensity := (C.float)(density)
cinner := inner.cptr() cinner := colorCptr(inner)
couter := outer.cptr() couter := colorCptr(outer)
ret := C.GenImageGradientRadial(cwidth, cheight, cdensity, *cinner, *couter) ret := C.GenImageGradientRadial(cwidth, cheight, cdensity, *cinner, *couter)
v := newImageFromPointer(unsafe.Pointer(&ret)) v := newImageFromPointer(unsafe.Pointer(&ret))
@ -530,13 +531,13 @@ func GenImageGradientRadial(width, height int, density float32, inner, outer Col
} }
// GenImageChecked - Generate image: checked // GenImageChecked - Generate image: checked
func GenImageChecked(width, height, checksX, checksY int, col1, col2 Color) *Image { func GenImageChecked(width, height, checksX, checksY int, col1, col2 color.RGBA) *Image {
cwidth := (C.int)(width) cwidth := (C.int)(width)
cheight := (C.int)(height) cheight := (C.int)(height)
cchecksX := (C.int)(checksX) cchecksX := (C.int)(checksX)
cchecksY := (C.int)(checksY) cchecksY := (C.int)(checksY)
ccol1 := col1.cptr() ccol1 := colorCptr(col1)
ccol2 := col2.cptr() ccol2 := colorCptr(col2)
ret := C.GenImageChecked(cwidth, cheight, cchecksX, cchecksY, *ccol1, *ccol2) ret := C.GenImageChecked(cwidth, cheight, cchecksX, cchecksY, *ccol1, *ccol2)
v := newImageFromPointer(unsafe.Pointer(&ret)) v := newImageFromPointer(unsafe.Pointer(&ret))
@ -586,48 +587,48 @@ func SetTextureWrap(texture Texture2D, wrapMode TextureWrapMode) {
} }
// DrawTexture - Draw a Texture2D // DrawTexture - Draw a Texture2D
func DrawTexture(texture Texture2D, posX int32, posY int32, tint Color) { func DrawTexture(texture Texture2D, posX int32, posY int32, tint color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
cposX := (C.int)(posX) cposX := (C.int)(posX)
cposY := (C.int)(posY) cposY := (C.int)(posY)
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawTexture(*ctexture, cposX, cposY, *ctint) C.DrawTexture(*ctexture, cposX, cposY, *ctint)
} }
// DrawTextureV - Draw a Texture2D with position defined as Vector2 // DrawTextureV - Draw a Texture2D with position defined as Vector2
func DrawTextureV(texture Texture2D, position Vector2, tint Color) { func DrawTextureV(texture Texture2D, position Vector2, tint color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
cposition := position.cptr() cposition := position.cptr()
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawTextureV(*ctexture, *cposition, *ctint) C.DrawTextureV(*ctexture, *cposition, *ctint)
} }
// DrawTextureEx - Draw a Texture2D with extended parameters // DrawTextureEx - Draw a Texture2D with extended parameters
func DrawTextureEx(texture Texture2D, position Vector2, rotation, scale float32, tint Color) { func DrawTextureEx(texture Texture2D, position Vector2, rotation, scale float32, tint color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
cposition := position.cptr() cposition := position.cptr()
crotation := (C.float)(rotation) crotation := (C.float)(rotation)
cscale := (C.float)(scale) cscale := (C.float)(scale)
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawTextureEx(*ctexture, *cposition, crotation, cscale, *ctint) C.DrawTextureEx(*ctexture, *cposition, crotation, cscale, *ctint)
} }
// DrawTextureRec - Draw a part of a texture defined by a rectangle // DrawTextureRec - Draw a part of a texture defined by a rectangle
func DrawTextureRec(texture Texture2D, sourceRec Rectangle, position Vector2, tint Color) { func DrawTextureRec(texture Texture2D, sourceRec Rectangle, position Vector2, tint color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
csourceRec := sourceRec.cptr() csourceRec := sourceRec.cptr()
cposition := position.cptr() cposition := position.cptr()
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawTextureRec(*ctexture, *csourceRec, *cposition, *ctint) C.DrawTextureRec(*ctexture, *csourceRec, *cposition, *ctint)
} }
// DrawTexturePro - Draw a part of a texture defined by a rectangle with 'pro' parameters // DrawTexturePro - Draw a part of a texture defined by a rectangle with 'pro' parameters
func DrawTexturePro(texture Texture2D, sourceRec, destRec Rectangle, origin Vector2, rotation float32, tint Color) { func DrawTexturePro(texture Texture2D, sourceRec, destRec Rectangle, origin Vector2, rotation float32, tint color.RGBA) {
ctexture := texture.cptr() ctexture := texture.cptr()
csourceRec := sourceRec.cptr() csourceRec := sourceRec.cptr()
cdestRec := destRec.cptr() cdestRec := destRec.cptr()
corigin := origin.cptr() corigin := origin.cptr()
crotation := (C.float)(rotation) crotation := (C.float)(rotation)
ctint := tint.cptr() ctint := colorCptr(tint)
C.DrawTexturePro(*ctexture, *csourceRec, *cdestRec, *corigin, crotation, *ctint) C.DrawTexturePro(*ctexture, *csourceRec, *cdestRec, *corigin, crotation, *ctint)
} }