Add new functions

This commit is contained in:
Milan Nikolic 2022-10-23 14:50:15 +02:00
parent ba0df12858
commit faa881fe83
No known key found for this signature in database
GPG key ID: 9229D0EAA3AA4E75
3 changed files with 83 additions and 11 deletions

View file

@ -318,9 +318,13 @@ const (
KeyVolumeDown = 25 KeyVolumeDown = 25
// Mouse Buttons // Mouse Buttons
MouseLeftButton = 0 MouseLeftButton = 0
MouseRightButton = 1 MouseRightButton = 1
MouseMiddleButton = 2 MouseMiddleButton = 2
MouseSideButton = 3
MouseExtraButton = 4
MouseForwardButton = 5
MouseBackButton = 6
// Touch points registered // Touch points registered
MaxTouchPoints = 2 MaxTouchPoints = 2
@ -930,12 +934,14 @@ type BlendMode int32
// Color blending modes (pre-defined) // Color blending modes (pre-defined)
const ( const (
BlendAlpha BlendMode = iota // Blend textures considering alpha (default) BlendAlpha BlendMode = iota // Blend textures considering alpha (default)
BlendAdditive // Blend textures adding colors BlendAdditive // Blend textures adding colors
BlendMultiplied // Blend textures multiplying colors BlendMultiplied // Blend textures multiplying colors
BlendAddColors // Blend textures adding colors (alternative) BlendAddColors // Blend textures adding colors (alternative)
BlendSubtractColors // Blend textures subtracting colors (alternative) BlendSubtractColors // Blend textures subtracting colors (alternative)
BlendCustom // Blend textures using custom src/dst factors (use SetBlendModeCustom()) BlendAlphaPremultiply // Blend premultiplied textures considering alpha
BlendCustom // Blend textures using custom src/dst factors
BlendCustomSeparate // Blend textures using custom rgb/alpha separate src/dst factors
) )
// Shader type (generic shader) // Shader type (generic shader)

View file

@ -158,6 +158,28 @@ func DrawCylinderWires(position Vector3, radiusTop float32, radiusBottom float32
C.DrawCylinderWires(*cposition, cradiusTop, cradiusBottom, cheight, cslices, *ccolor) C.DrawCylinderWires(*cposition, cradiusTop, cradiusBottom, cheight, cslices, *ccolor)
} }
// DrawCapsule - Draw a capsule with the center of its sphere caps at startPos and endPos
func DrawCapsule(startPos, endPos Vector3, radius float32, slices, rings int32, col color.RGBA) {
cstartPos := startPos.cptr()
cendPos := startPos.cptr()
cradius := (C.float)(radius)
cslices := (C.int)(slices)
crings := (C.int)(slices)
ccolor := colorCptr(col)
C.DrawCapsule(*cstartPos, *cendPos, cradius, cslices, crings, *ccolor)
}
// DrawCapsuleWires - Draw capsule wireframe with the center of its sphere caps at startPos and endPos
func DrawCapsuleWires(startPos, endPos Vector3, radius float32, slices, rings int32, col color.RGBA) {
cstartPos := startPos.cptr()
cendPos := startPos.cptr()
cradius := (C.float)(radius)
cslices := (C.int)(slices)
crings := (C.int)(slices)
ccolor := colorCptr(col)
C.DrawCapsuleWires(*cstartPos, *cendPos, cradius, cslices, crings, *ccolor)
}
// DrawPlane - Draw a plane XZ // DrawPlane - Draw a plane XZ
func DrawPlane(centerPos Vector3, size Vector2, col color.RGBA) { func DrawPlane(centerPos Vector3, size Vector2, col color.RGBA) {
ccenterPos := centerPos.cptr() ccenterPos := centerPos.cptr()

View file

@ -384,7 +384,7 @@ func ImageDraw(dst, src *Image, srcRec, dstRec Rectangle, tint color.RGBA) {
C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint) C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint)
} }
// ImageDrawCircle - Draw circle within an image // ImageDrawCircle - Draw a filled circle within an image
func ImageDrawCircle(dst *Image, centerX, centerY, radius int32, col color.RGBA) { 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)
@ -394,7 +394,7 @@ func ImageDrawCircle(dst *Image, centerX, centerY, radius int32, col color.RGBA)
C.ImageDrawCircle(cdst, ccenterX, ccenterY, cradius, *ccolor) C.ImageDrawCircle(cdst, ccenterX, ccenterY, cradius, *ccolor)
} }
// ImageDrawCircleV - Draw circle within an image // ImageDrawCircleV - Draw a filled circle within an image (Vector version)
func ImageDrawCircleV(dst *Image, center Vector2, radius int32, col color.RGBA) { func ImageDrawCircleV(dst *Image, center Vector2, radius int32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
ccenter := center.cptr() ccenter := center.cptr()
@ -403,6 +403,25 @@ func ImageDrawCircleV(dst *Image, center Vector2, radius int32, col color.RGBA)
C.ImageDrawCircleV(cdst, *ccenter, cradius, *ccolor) C.ImageDrawCircleV(cdst, *ccenter, cradius, *ccolor)
} }
// ImageDrawCircleLines - Draw circle outline within an image
func ImageDrawCircleLines(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 := colorCptr(col)
C.ImageDrawCircleLines(cdst, ccenterX, ccenterY, cradius, *ccolor)
}
// ImageDrawCircleLinesV - Draw circle outline within an image (Vector version)
func ImageDrawCircleLinesV(dst *Image, center Vector2, radius int32, col color.RGBA) {
cdst := dst.cptr()
ccenter := center.cptr()
cradius := (C.int)(radius)
ccolor := colorCptr(col)
C.ImageDrawCircleLinesV(cdst, *ccenter, cradius, *ccolor)
}
// ImageDrawPixel - Draw pixel within an image // ImageDrawPixel - Draw pixel within an image
func ImageDrawPixel(dst *Image, posX, posY int32, col color.RGBA) { func ImageDrawPixel(dst *Image, posX, posY int32, col color.RGBA) {
cdst := dst.cptr() cdst := dst.cptr()
@ -555,6 +574,19 @@ func GenImageWhiteNoise(width, height int, factor float32) *Image {
return v return v
} }
// GenImagePerlinNoise - Generate image: perlin noise
func GenImagePerlinNoise(width, height, offsetX, offsetY int, scale float32) *Image {
cwidth := (C.int)(width)
cheight := (C.int)(height)
coffsetX := (C.int)(offsetX)
coffsetY := (C.int)(offsetY)
cscale := (C.float)(scale)
ret := C.GenImagePerlinNoise(cwidth, cheight, coffsetX, coffsetY, cscale)
v := newImageFromPointer(unsafe.Pointer(&ret))
return v
}
// GenImageCellular - Generate image: cellular algorithm. Bigger tileSize means bigger cells // GenImageCellular - Generate image: cellular algorithm. Bigger tileSize means bigger cells
func GenImageCellular(width, height, tileSize int) *Image { func GenImageCellular(width, height, tileSize int) *Image {
cwidth := (C.int)(width) cwidth := (C.int)(width)
@ -566,6 +598,18 @@ func GenImageCellular(width, height, tileSize int) *Image {
return v return v
} }
// GenImageText - Generate image: grayscale image from text data
func GenImageText(width, height int, text string) *Image {
cwidth := (C.int)(width)
cheight := (C.int)(height)
ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext))
ret := C.GenImageText(cwidth, cheight, ctext)
v := newImageFromPointer(unsafe.Pointer(&ret))
return v
}
// GenTextureMipmaps - Generate GPU mipmaps for a texture // GenTextureMipmaps - Generate GPU mipmaps for a texture
func GenTextureMipmaps(texture *Texture2D) { func GenTextureMipmaps(texture *Texture2D) {
ctexture := texture.cptr() ctexture := texture.cptr()