Use color.RGBA, fixes 144
This commit is contained in:
parent
ca8ab655a8
commit
29ba3cc508
6 changed files with 241 additions and 231 deletions
|
@ -5,315 +5,318 @@ package rl
|
|||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
import (
|
||||
"image/color"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// DrawPixel - Draw a pixel
|
||||
func DrawPixel(posX, posY int32, color Color) {
|
||||
func DrawPixel(posX, posY int32, col color.RGBA) {
|
||||
cposX := (C.int)(posX)
|
||||
cposY := (C.int)(posY)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawPixel(cposX, cposY, *ccolor)
|
||||
}
|
||||
|
||||
// DrawPixelV - Draw a pixel (Vector version)
|
||||
func DrawPixelV(position Vector2, color Color) {
|
||||
func DrawPixelV(position Vector2, col color.RGBA) {
|
||||
cposition := position.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawPixelV(*cposition, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
cstartPosY := (C.int)(startPosY)
|
||||
cendPosX := (C.int)(endPosX)
|
||||
cendPosY := (C.int)(endPosY)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawLine(cstartPosX, cstartPosY, cendPosX, cendPosY, *ccolor)
|
||||
}
|
||||
|
||||
// DrawLineV - Draw a line (Vector version)
|
||||
func DrawLineV(startPos, endPos Vector2, color Color) {
|
||||
func DrawLineV(startPos, endPos Vector2, col color.RGBA) {
|
||||
cstartPos := startPos.cptr()
|
||||
cendPos := endPos.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawLineV(*cstartPos, *cendPos, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cendPos := endPos.cptr()
|
||||
cthick := (C.float)(thick)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawLineEx(*cstartPos, *cendPos, cthick, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cendPos := endPos.cptr()
|
||||
cthick := (C.float)(thick)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawLineBezier(*cstartPos, *cendPos, cthick, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
ccenterY := (C.int)(centerY)
|
||||
cradius := (C.float)(radius)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawCircle(ccenterX, ccenterY, cradius, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cradius := (C.float)(radius)
|
||||
cstartAngle := (C.float)(startAngle)
|
||||
cendAngle := (C.float)(endAngle)
|
||||
csegments := (C.int)(segments)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawCircleSector(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cradius := (C.float)(radius)
|
||||
cstartAngle := (C.float)(startAngle)
|
||||
cendAngle := (C.float)(endAngle)
|
||||
csegments := (C.int)(segments)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawCircleSectorLines(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
ccenterY := (C.int)(centerY)
|
||||
cradius := (C.float)(radius)
|
||||
ccolor1 := color1.cptr()
|
||||
ccolor2 := color2.cptr()
|
||||
ccolor1 := colorCptr(col1)
|
||||
ccolor2 := colorCptr(col2)
|
||||
C.DrawCircleGradient(ccenterX, ccenterY, cradius, *ccolor1, *ccolor2)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cradius := (C.float)(radius)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawCircleV(*ccenter, cradius, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
ccenterY := (C.int)(centerY)
|
||||
cradius := (C.float)(radius)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawCircleLines(ccenterX, ccenterY, cradius, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
ccenterY := (C.int)(centerY)
|
||||
cradiusH := (C.float)(radiusH)
|
||||
cradiusV := (C.float)(radiusV)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawEllipse(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
ccenterY := (C.int)(centerY)
|
||||
cradiusH := (C.float)(radiusH)
|
||||
cradiusV := (C.float)(radiusV)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawEllipseLines(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cinnerRadius := (C.float)(innerRadius)
|
||||
couterRadius := (C.float)(outerRadius)
|
||||
cstartAngle := (C.float)(startAngle)
|
||||
cendAngle := (C.float)(endAngle)
|
||||
csegments := (C.int)(segments)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRing(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cinnerRadius := (C.float)(innerRadius)
|
||||
couterRadius := (C.float)(outerRadius)
|
||||
cstartAngle := (C.float)(startAngle)
|
||||
cendAngle := (C.float)(endAngle)
|
||||
csegments := (C.int)(segments)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRingLines(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
cposY := (C.int)(posY)
|
||||
cwidth := (C.int)(width)
|
||||
cheight := (C.int)(height)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectangle(cposX, cposY, cwidth, cheight, *ccolor)
|
||||
}
|
||||
|
||||
// DrawRectangleRec - Draw a color-filled rectangle
|
||||
func DrawRectangleRec(rec Rectangle, color Color) {
|
||||
func DrawRectangleRec(rec Rectangle, col color.RGBA) {
|
||||
crec := rec.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectangleRec(*crec, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
corigin := origin.cptr()
|
||||
crotation := (C.float)(rotation)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectanglePro(*crec, *corigin, crotation, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
cposY := (C.int)(posY)
|
||||
cwidth := (C.int)(width)
|
||||
cheight := (C.int)(height)
|
||||
ccolor1 := color1.cptr()
|
||||
ccolor2 := color2.cptr()
|
||||
ccolor1 := colorCptr(col1)
|
||||
ccolor2 := colorCptr(col2)
|
||||
C.DrawRectangleGradientV(cposX, cposY, cwidth, cheight, *ccolor1, *ccolor2)
|
||||
}
|
||||
|
||||
// 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)
|
||||
cposY := (C.int)(posY)
|
||||
cwidth := (C.int)(width)
|
||||
cheight := (C.int)(height)
|
||||
ccolor1 := color1.cptr()
|
||||
ccolor2 := color2.cptr()
|
||||
ccolor1 := colorCptr(col1)
|
||||
ccolor2 := colorCptr(col2)
|
||||
C.DrawRectangleGradientH(cposX, cposY, cwidth, cheight, *ccolor1, *ccolor2)
|
||||
}
|
||||
|
||||
// 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()
|
||||
ccolor1 := color1.cptr()
|
||||
ccolor2 := color2.cptr()
|
||||
ccolor3 := color3.cptr()
|
||||
ccolor4 := color4.cptr()
|
||||
ccolor1 := colorCptr(col1)
|
||||
ccolor2 := colorCptr(col2)
|
||||
ccolor3 := colorCptr(col3)
|
||||
ccolor4 := colorCptr(col4)
|
||||
C.DrawRectangleGradientEx(*crec, *ccolor1, *ccolor2, *ccolor3, *ccolor4)
|
||||
}
|
||||
|
||||
// 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()
|
||||
csize := size.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectangleV(*cposition, *csize, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
cposY := (C.int)(posY)
|
||||
cwidth := (C.int)(width)
|
||||
cheight := (C.int)(height)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectangleLines(cposX, cposY, cwidth, cheight, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
clineThick := (C.float)(lineThick)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectangleLinesEx(*crec, clineThick, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
croundness := (C.float)(roundness)
|
||||
csegments := (C.int)(segments)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectangleRounded(*crec, croundness, csegments, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
croundness := (C.float)(roundness)
|
||||
csegments := (C.int)(segments)
|
||||
clineThick := (C.float)(lineThick)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawRectangleRoundedLines(*crec, croundness, csegments, clineThick, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cv2 := v2.cptr()
|
||||
cv3 := v3.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawTriangle(*cv1, *cv2, *cv3, *ccolor)
|
||||
}
|
||||
|
||||
// DrawTriangleLines - Draw triangle outline
|
||||
func DrawTriangleLines(v1, v2, v3 Vector2, color Color) {
|
||||
func DrawTriangleLines(v1, v2, v3 Vector2, col color.RGBA) {
|
||||
cv1 := v1.cptr()
|
||||
cv2 := v2.cptr()
|
||||
cv3 := v3.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawTriangleLines(*cv1, *cv2, *cv3, *ccolor)
|
||||
}
|
||||
|
||||
// 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]))
|
||||
cpointsCount := (C.int)(int32(len(points)))
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawTriangleFan(cpoints, cpointsCount, *ccolor)
|
||||
}
|
||||
|
||||
// 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]))
|
||||
cpointsCount := (C.int)(int32(len(points)))
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawTriangleStrip(cpoints, cpointsCount, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
csides := (C.int)(sides)
|
||||
cradius := (C.float)(radius)
|
||||
crotation := (C.float)(rotation)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawPoly(*ccenter, csides, cradius, crotation, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
csides := (C.int)(sides)
|
||||
cradius := (C.float)(radius)
|
||||
crotation := (C.float)(rotation)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.DrawPolyLines(*ccenter, csides, cradius, crotation, *ccolor)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue