Sort functions
This commit is contained in:
parent
9e0799a313
commit
4d870bd6d1
1 changed files with 114 additions and 114 deletions
|
@ -164,11 +164,36 @@ func ExportImage(image Image, name string) {
|
||||||
C.ExportImage(*cimage, cname)
|
C.ExportImage(*cimage, cname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageToPOT - Convert image to POT (power-of-two)
|
// ImageCopy - Create an image duplicate (useful for transformations)
|
||||||
func ImageToPOT(image *Image, fillColor Color) {
|
func ImageCopy(image *Image) *Image {
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
cfillColor := fillColor.cptr()
|
ret := C.ImageCopy(*cimage)
|
||||||
C.ImageToPOT(cimage, *cfillColor)
|
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageText - Create an image from text (default font)
|
||||||
|
func ImageText(text string, fontSize int32, color Color) *Image {
|
||||||
|
ctext := C.CString(text)
|
||||||
|
defer C.free(unsafe.Pointer(ctext))
|
||||||
|
cfontSize := (C.int)(fontSize)
|
||||||
|
ccolor := color.cptr()
|
||||||
|
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 {
|
||||||
|
cfont := font.cptr()
|
||||||
|
ctext := C.CString(text)
|
||||||
|
defer C.free(unsafe.Pointer(ctext))
|
||||||
|
cfontSize := (C.float)(fontSize)
|
||||||
|
cspacing := (C.float)(spacing)
|
||||||
|
ctint := tint.cptr()
|
||||||
|
ret := C.ImageTextEx(*cfont, ctext, cfontSize, cspacing, *ctint)
|
||||||
|
v := newImageFromPointer(unsafe.Pointer(&ret))
|
||||||
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageFormat - Convert image data to desired format
|
// ImageFormat - Convert image data to desired format
|
||||||
|
@ -178,11 +203,25 @@ func ImageFormat(image *Image, newFormat PixelFormat) {
|
||||||
C.ImageFormat(cimage, cnewFormat)
|
C.ImageFormat(cimage, cnewFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageAlphaMask - Apply alpha mask to image
|
// ImageToPOT - Convert image to POT (power-of-two)
|
||||||
func ImageAlphaMask(image, alphaMask *Image) {
|
func ImageToPOT(image *Image, fillColor Color) {
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
calphaMask := alphaMask.cptr()
|
cfillColor := fillColor.cptr()
|
||||||
C.ImageAlphaMask(cimage, *calphaMask)
|
C.ImageToPOT(cimage, *cfillColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageCrop - Crop an image to a defined rectangle
|
||||||
|
func ImageCrop(image *Image, crop Rectangle) {
|
||||||
|
cimage := image.cptr()
|
||||||
|
ccrop := crop.cptr()
|
||||||
|
C.ImageCrop(cimage, *ccrop)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageAlphaCrop - Crop image depending on alpha value
|
||||||
|
func ImageAlphaCrop(image *Image, threshold float32) {
|
||||||
|
cimage := image.cptr()
|
||||||
|
cthreshold := (C.float)(threshold)
|
||||||
|
C.ImageAlphaCrop(cimage, cthreshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageAlphaClear - Apply alpha mask to image
|
// ImageAlphaClear - Apply alpha mask to image
|
||||||
|
@ -193,11 +232,11 @@ func ImageAlphaClear(image *Image, color Color, threshold float32) {
|
||||||
C.ImageAlphaClear(cimage, *ccolor, cthreshold)
|
C.ImageAlphaClear(cimage, *ccolor, cthreshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageAlphaCrop - Crop image depending on alpha value
|
// ImageAlphaMask - Apply alpha mask to image
|
||||||
func ImageAlphaCrop(image *Image, threshold float32) {
|
func ImageAlphaMask(image, alphaMask *Image) {
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
cthreshold := (C.float)(threshold)
|
calphaMask := alphaMask.cptr()
|
||||||
C.ImageAlphaCrop(cimage, cthreshold)
|
C.ImageAlphaMask(cimage, *calphaMask)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageAlphaPremultiply - Premultiply alpha channel
|
// ImageAlphaPremultiply - Premultiply alpha channel
|
||||||
|
@ -206,31 +245,6 @@ func ImageAlphaPremultiply(image *Image) {
|
||||||
C.ImageAlphaPremultiply(cimage)
|
C.ImageAlphaPremultiply(cimage)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageDither - Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
|
|
||||||
func ImageDither(image *Image, rBpp, gBpp, bBpp, aBpp int32) {
|
|
||||||
cimage := image.cptr()
|
|
||||||
crBpp := (C.int)(rBpp)
|
|
||||||
cgBpp := (C.int)(gBpp)
|
|
||||||
cbBpp := (C.int)(bBpp)
|
|
||||||
caBpp := (C.int)(aBpp)
|
|
||||||
C.ImageDither(cimage, crBpp, cgBpp, cbBpp, caBpp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageCopy - Create an image duplicate (useful for transformations)
|
|
||||||
func ImageCopy(image *Image) *Image {
|
|
||||||
cimage := image.cptr()
|
|
||||||
ret := C.ImageCopy(*cimage)
|
|
||||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageCrop - Crop an image to a defined rectangle
|
|
||||||
func ImageCrop(image *Image, crop Rectangle) {
|
|
||||||
cimage := image.cptr()
|
|
||||||
ccrop := crop.cptr()
|
|
||||||
C.ImageCrop(cimage, *ccrop)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageResize - Resize an image (bilinear filtering)
|
// ImageResize - Resize an image (bilinear filtering)
|
||||||
func ImageResize(image *Image, newWidth, newHeight int32) {
|
func ImageResize(image *Image, newWidth, newHeight int32) {
|
||||||
cimage := image.cptr()
|
cimage := image.cptr()
|
||||||
|
@ -264,83 +278,14 @@ func ImageMipmaps(image *Image) {
|
||||||
C.ImageMipmaps(cimage)
|
C.ImageMipmaps(cimage)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageText - Create an image from text (default font)
|
// ImageDither - Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
|
||||||
func ImageText(text string, fontSize int32, color Color) *Image {
|
func ImageDither(image *Image, rBpp, gBpp, bBpp, aBpp int32) {
|
||||||
ctext := C.CString(text)
|
cimage := image.cptr()
|
||||||
defer C.free(unsafe.Pointer(ctext))
|
crBpp := (C.int)(rBpp)
|
||||||
cfontSize := (C.int)(fontSize)
|
cgBpp := (C.int)(gBpp)
|
||||||
ccolor := color.cptr()
|
cbBpp := (C.int)(bBpp)
|
||||||
ret := C.ImageText(ctext, cfontSize, *ccolor)
|
caBpp := (C.int)(aBpp)
|
||||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
C.ImageDither(cimage, crBpp, cgBpp, cbBpp, caBpp)
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageTextEx - Create an image from text (custom sprite font)
|
|
||||||
func ImageTextEx(font Font, text string, fontSize, spacing float32, tint Color) *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()
|
|
||||||
ret := C.ImageTextEx(*cfont, ctext, cfontSize, cspacing, *ctint)
|
|
||||||
v := newImageFromPointer(unsafe.Pointer(&ret))
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageDraw - Draw a source image within a destination image
|
|
||||||
func ImageDraw(dst, src *Image, srcRec, dstRec Rectangle, tint Color) {
|
|
||||||
cdst := dst.cptr()
|
|
||||||
csrc := src.cptr()
|
|
||||||
csrcRec := srcRec.cptr()
|
|
||||||
cdstRec := dstRec.cptr()
|
|
||||||
ctint := tint.cptr()
|
|
||||||
C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageDrawRectangle - Draw rectangle within an image
|
|
||||||
func ImageDrawRectangle(dst *Image, x, y, width, height int32, color Color) {
|
|
||||||
cdst := dst.cptr()
|
|
||||||
cx := (C.int)(x)
|
|
||||||
cy := (C.int)(y)
|
|
||||||
cwidth := (C.int)(width)
|
|
||||||
cheight := (C.int)(height)
|
|
||||||
ccolor := color.cptr()
|
|
||||||
C.ImageDrawRectangle(cdst, cx, cy, cwidth, cheight, *ccolor)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageDrawRectangleLines - Draw rectangle lines within an image
|
|
||||||
func ImageDrawRectangleLines(dst *Image, rec Rectangle, thick int, color Color) {
|
|
||||||
cdst := dst.cptr()
|
|
||||||
crec := rec.cptr()
|
|
||||||
cthick := (C.int)(thick)
|
|
||||||
ccolor := color.cptr()
|
|
||||||
C.ImageDrawRectangleLines(cdst, *crec, cthick, *ccolor)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageDrawText - Draw text (default font) within an image (destination)
|
|
||||||
func ImageDrawText(dst *Image, posX, posY int32, text string, fontSize int32, color Color) {
|
|
||||||
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()
|
|
||||||
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) {
|
|
||||||
cdst := dst.cptr()
|
|
||||||
cposition := position.cptr()
|
|
||||||
cfont := font.cptr()
|
|
||||||
ctext := C.CString(text)
|
|
||||||
defer C.free(unsafe.Pointer(ctext))
|
|
||||||
cfontSize := (C.float)(fontSize)
|
|
||||||
cspacing := (C.float)(spacing)
|
|
||||||
ccolor := color.cptr()
|
|
||||||
C.ImageDrawTextEx(cdst, *cfont, ctext, *cposition, cfontSize, cspacing, *ccolor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageFlipVertical - Flip image vertically
|
// ImageFlipVertical - Flip image vertically
|
||||||
|
@ -408,6 +353,61 @@ func ImageColorReplace(image *Image, color, replace Color) {
|
||||||
C.ImageColorReplace(cimage, *ccolor, *creplace)
|
C.ImageColorReplace(cimage, *ccolor, *creplace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageDraw - Draw a source image within a destination image
|
||||||
|
func ImageDraw(dst, src *Image, srcRec, dstRec Rectangle, tint Color) {
|
||||||
|
cdst := dst.cptr()
|
||||||
|
csrc := src.cptr()
|
||||||
|
csrcRec := srcRec.cptr()
|
||||||
|
cdstRec := dstRec.cptr()
|
||||||
|
ctint := tint.cptr()
|
||||||
|
C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageDrawRectangle - Draw rectangle within an image
|
||||||
|
func ImageDrawRectangle(dst *Image, x, y, width, height int32, color Color) {
|
||||||
|
cdst := dst.cptr()
|
||||||
|
cx := (C.int)(x)
|
||||||
|
cy := (C.int)(y)
|
||||||
|
cwidth := (C.int)(width)
|
||||||
|
cheight := (C.int)(height)
|
||||||
|
ccolor := color.cptr()
|
||||||
|
C.ImageDrawRectangle(cdst, cx, cy, cwidth, cheight, *ccolor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageDrawRectangleLines - Draw rectangle lines within an image
|
||||||
|
func ImageDrawRectangleLines(dst *Image, rec Rectangle, thick int, color Color) {
|
||||||
|
cdst := dst.cptr()
|
||||||
|
crec := rec.cptr()
|
||||||
|
cthick := (C.int)(thick)
|
||||||
|
ccolor := color.cptr()
|
||||||
|
C.ImageDrawRectangleLines(cdst, *crec, cthick, *ccolor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageDrawText - Draw text (default font) within an image (destination)
|
||||||
|
func ImageDrawText(dst *Image, posX, posY int32, text string, fontSize int32, color Color) {
|
||||||
|
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()
|
||||||
|
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) {
|
||||||
|
cdst := dst.cptr()
|
||||||
|
cposition := position.cptr()
|
||||||
|
cfont := font.cptr()
|
||||||
|
ctext := C.CString(text)
|
||||||
|
defer C.free(unsafe.Pointer(ctext))
|
||||||
|
cfontSize := (C.float)(fontSize)
|
||||||
|
cspacing := (C.float)(spacing)
|
||||||
|
ccolor := color.cptr()
|
||||||
|
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, color Color) *Image {
|
||||||
cwidth := (C.int)(width)
|
cwidth := (C.int)(width)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue