Use color.RGBA, fixes 144
This commit is contained in:
parent
ca8ab655a8
commit
29ba3cc508
6 changed files with 241 additions and 231 deletions
|
@ -8,6 +8,7 @@ import "C"
|
|||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
|
@ -128,10 +129,10 @@ func UnloadRenderTexture(target RenderTexture2D) {
|
|||
}
|
||||
|
||||
// LoadImageColors - Get pixel data from image as a Color slice
|
||||
func LoadImageColors(img *Image) []Color {
|
||||
func LoadImageColors(img *Image) []color.RGBA {
|
||||
cimg := img.cptr()
|
||||
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
|
||||
|
@ -143,14 +144,14 @@ func LoadImageFromTexture(texture Texture2D) *Image {
|
|||
}
|
||||
|
||||
// UpdateTexture - Update GPU texture with new data
|
||||
func UpdateTexture(texture Texture2D, pixels []Color) {
|
||||
func UpdateTexture(texture Texture2D, pixels []color.RGBA) {
|
||||
ctexture := texture.cptr()
|
||||
cpixels := unsafe.Pointer(&pixels[0])
|
||||
C.UpdateTexture(*ctexture, cpixels)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cpixels := unsafe.Pointer(&pixels[0])
|
||||
crec := rec.cptr()
|
||||
|
@ -175,24 +176,24 @@ func ImageCopy(image *Image) *Image {
|
|||
}
|
||||
|
||||
// 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)
|
||||
defer C.free(unsafe.Pointer(ctext))
|
||||
cfontSize := (C.int)(fontSize)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
ret := C.ImageText(ctext, cfontSize, *ccolor)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// 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()
|
||||
ctext := C.CString(text)
|
||||
defer C.free(unsafe.Pointer(ctext))
|
||||
cfontSize := (C.float)(fontSize)
|
||||
cspacing := (C.float)(spacing)
|
||||
ctint := tint.cptr()
|
||||
ctint := colorCptr(tint)
|
||||
ret := C.ImageTextEx(*cfont, ctext, cfontSize, cspacing, *ctint)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
|
@ -206,9 +207,9 @@ func ImageFormat(image *Image, newFormat PixelFormat) {
|
|||
}
|
||||
|
||||
// ImageToPOT - Convert image to POT (power-of-two)
|
||||
func ImageToPOT(image *Image, fillColor Color) {
|
||||
func ImageToPOT(image *Image, fillColor color.RGBA) {
|
||||
cimage := image.cptr()
|
||||
cfillColor := fillColor.cptr()
|
||||
cfillColor := colorCptr(fillColor)
|
||||
C.ImageToPOT(cimage, *cfillColor)
|
||||
}
|
||||
|
||||
|
@ -227,9 +228,9 @@ func ImageAlphaCrop(image *Image, threshold float32) {
|
|||
}
|
||||
|
||||
// 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()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
cthreshold := (C.float)(threshold)
|
||||
C.ImageAlphaClear(cimage, *ccolor, cthreshold)
|
||||
}
|
||||
|
@ -264,13 +265,13 @@ func ImageResizeNN(image *Image, newWidth, newHeight int32) {
|
|||
}
|
||||
|
||||
// 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()
|
||||
cnewWidth := (C.int)(newWidth)
|
||||
cnewHeight := (C.int)(newHeight)
|
||||
coffsetX := (C.int)(offsetX)
|
||||
coffsetY := (C.int)(offsetY)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageResizeCanvas(cimage, cnewWidth, cnewHeight, coffsetX, coffsetY, *ccolor)
|
||||
}
|
||||
|
||||
|
@ -315,9 +316,9 @@ func ImageRotateCCW(image *Image) {
|
|||
}
|
||||
|
||||
// ImageColorTint - Modify image color: tint
|
||||
func ImageColorTint(image *Image, color Color) {
|
||||
func ImageColorTint(image *Image, col color.RGBA) {
|
||||
cimage := image.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageColorTint(cimage, *ccolor)
|
||||
}
|
||||
|
||||
|
@ -348,15 +349,15 @@ func ImageColorBrightness(image *Image, brightness int32) {
|
|||
}
|
||||
|
||||
// ImageColorReplace - Modify image color: replace color
|
||||
func ImageColorReplace(image *Image, color, replace Color) {
|
||||
func ImageColorReplace(image *Image, col, replace color.RGBA) {
|
||||
cimage := image.cptr()
|
||||
ccolor := color.cptr()
|
||||
creplace := replace.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
creplace := colorCptr(replace)
|
||||
C.ImageColorReplace(cimage, *ccolor, *creplace)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cx := (C.int)(x)
|
||||
cy := (C.int)(y)
|
||||
|
@ -367,109 +368,109 @@ func GetImageColor(image Image, x, y int32) Color {
|
|||
}
|
||||
|
||||
// ImageClearBackground - Clear image background with given color
|
||||
func ImageClearBackground(dst *Image, color Color) {
|
||||
func ImageClearBackground(dst *Image, col color.RGBA) {
|
||||
cdst := dst.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageClearBackground(cdst, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
csrc := src.cptr()
|
||||
csrcRec := srcRec.cptr()
|
||||
cdstRec := dstRec.cptr()
|
||||
ctint := tint.cptr()
|
||||
ctint := colorCptr(tint)
|
||||
C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint)
|
||||
}
|
||||
|
||||
// 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()
|
||||
ccenterX := (C.int)(centerX)
|
||||
ccenterY := (C.int)(centerY)
|
||||
cradius := (C.int)(radius)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawCircle(cdst, ccenterX, ccenterY, cradius, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
ccenter := center.cptr()
|
||||
cradius := (C.int)(radius)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawCircleV(cdst, *ccenter, cradius, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cposX := (C.int)(posX)
|
||||
cposY := (C.int)(posY)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawPixel(cdst, cposX, cposY, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cposition := position.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawPixelV(cdst, *cposition, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cx := (C.int)(x)
|
||||
cy := (C.int)(y)
|
||||
cwidth := (C.int)(width)
|
||||
cheight := (C.int)(height)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawRectangle(cdst, cx, cy, cwidth, cheight, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cposition := position.cptr()
|
||||
csize := size.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawRectangleV(cdst, *cposition, *csize, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
crec := rec.cptr()
|
||||
cthick := (C.int)(thick)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawRectangleLines(cdst, *crec, cthick, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
crec := rec.cptr()
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawRectangleRec(cdst, *crec, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
posx := (C.int)(posX)
|
||||
posy := (C.int)(posY)
|
||||
ctext := C.CString(text)
|
||||
defer C.free(unsafe.Pointer(ctext))
|
||||
cfontSize := (C.int)(fontSize)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawText(cdst, ctext, posx, posy, cfontSize, *ccolor)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cposition := position.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))
|
||||
cfontSize := (C.float)(fontSize)
|
||||
cspacing := (C.float)(spacing)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
C.ImageDrawTextEx(cdst, *cfont, ctext, *cposition, cfontSize, cspacing, *ccolor)
|
||||
}
|
||||
|
||||
// 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)
|
||||
cheight := (C.int)(height)
|
||||
ccolor := color.cptr()
|
||||
ccolor := colorCptr(col)
|
||||
|
||||
ret := C.GenImageColor(cwidth, cheight, *ccolor)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
|
@ -493,11 +494,11 @@ func GenImageColor(width, height int, color Color) *Image {
|
|||
}
|
||||
|
||||
// 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)
|
||||
cheight := (C.int)(height)
|
||||
ctop := top.cptr()
|
||||
cbottom := bottom.cptr()
|
||||
ctop := colorCptr(top)
|
||||
cbottom := colorCptr(bottom)
|
||||
|
||||
ret := C.GenImageGradientV(cwidth, cheight, *ctop, *cbottom)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
|
@ -505,11 +506,11 @@ func GenImageGradientV(width, height int, top, bottom Color) *Image {
|
|||
}
|
||||
|
||||
// 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)
|
||||
cheight := (C.int)(height)
|
||||
cleft := left.cptr()
|
||||
cright := right.cptr()
|
||||
cleft := colorCptr(left)
|
||||
cright := colorCptr(right)
|
||||
|
||||
ret := C.GenImageGradientH(cwidth, cheight, *cleft, *cright)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
|
@ -517,12 +518,12 @@ func GenImageGradientH(width, height int, left, right Color) *Image {
|
|||
}
|
||||
|
||||
// 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)
|
||||
cheight := (C.int)(height)
|
||||
cdensity := (C.float)(density)
|
||||
cinner := inner.cptr()
|
||||
couter := outer.cptr()
|
||||
cinner := colorCptr(inner)
|
||||
couter := colorCptr(outer)
|
||||
|
||||
ret := C.GenImageGradientRadial(cwidth, cheight, cdensity, *cinner, *couter)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
|
@ -530,13 +531,13 @@ func GenImageGradientRadial(width, height int, density float32, inner, outer Col
|
|||
}
|
||||
|
||||
// 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)
|
||||
cheight := (C.int)(height)
|
||||
cchecksX := (C.int)(checksX)
|
||||
cchecksY := (C.int)(checksY)
|
||||
ccol1 := col1.cptr()
|
||||
ccol2 := col2.cptr()
|
||||
ccol1 := colorCptr(col1)
|
||||
ccol2 := colorCptr(col2)
|
||||
|
||||
ret := C.GenImageChecked(cwidth, cheight, cchecksX, cchecksY, *ccol1, *ccol2)
|
||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||
|
@ -586,48 +587,48 @@ func SetTextureWrap(texture Texture2D, wrapMode TextureWrapMode) {
|
|||
}
|
||||
|
||||
// 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()
|
||||
cposX := (C.int)(posX)
|
||||
cposY := (C.int)(posY)
|
||||
ctint := tint.cptr()
|
||||
ctint := colorCptr(tint)
|
||||
C.DrawTexture(*ctexture, cposX, cposY, *ctint)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cposition := position.cptr()
|
||||
ctint := tint.cptr()
|
||||
ctint := colorCptr(tint)
|
||||
C.DrawTextureV(*ctexture, *cposition, *ctint)
|
||||
}
|
||||
|
||||
// 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()
|
||||
cposition := position.cptr()
|
||||
crotation := (C.float)(rotation)
|
||||
cscale := (C.float)(scale)
|
||||
ctint := tint.cptr()
|
||||
ctint := colorCptr(tint)
|
||||
C.DrawTextureEx(*ctexture, *cposition, crotation, cscale, *ctint)
|
||||
}
|
||||
|
||||
// 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()
|
||||
csourceRec := sourceRec.cptr()
|
||||
cposition := position.cptr()
|
||||
ctint := tint.cptr()
|
||||
ctint := colorCptr(tint)
|
||||
C.DrawTextureRec(*ctexture, *csourceRec, *cposition, *ctint)
|
||||
}
|
||||
|
||||
// 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()
|
||||
csourceRec := sourceRec.cptr()
|
||||
cdestRec := destRec.cptr()
|
||||
corigin := origin.cptr()
|
||||
crotation := (C.float)(rotation)
|
||||
ctint := tint.cptr()
|
||||
ctint := colorCptr(tint)
|
||||
C.DrawTexturePro(*ctexture, *csourceRec, *cdestRec, *corigin, crotation, *ctint)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue