Merge pull request #391 from JupiterRider/GuiLoadIcons

[raygui] LoadIcons-, DrawIcon-function and example added
This commit is contained in:
Milan Nikolic 2024-05-22 22:09:53 +02:00 committed by GitHub
commit b7c9eeec1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,3 @@
This example loads a custom .rgi-file and draws the 255th icon. You can use the [rGuiIcons](https://raylibtech.itch.io/rguiicons) tool to view or create icon files.
![Screenshot](./screenshot.png)

Binary file not shown.

View file

@ -0,0 +1,20 @@
package main
import (
"github.com/gen2brain/raylib-go/raygui"
rl "github.com/gen2brain/raylib-go/raylib"
)
func main() {
rl.InitWindow(800, 600, "raylib-go - icons example")
defer rl.CloseWindow()
raygui.LoadIcons("default_icons_with_255.rgi", false)
for !rl.WindowShouldClose() {
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
raygui.DrawIcon(raygui.ICON_255, 100, 100, 8, rl.Gray)
rl.EndDrawing()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

View file

@ -8,6 +8,7 @@ package raygui
import "C"
import (
"image/color"
"strings"
"unsafe"
@ -1381,3 +1382,15 @@ func GetFont() rl.Font {
ptr := unsafe.Pointer(&ret)
return *(*rl.Font)(ptr)
}
// LoadIcons - load raygui icons file (.rgi) into internal icons data
func LoadIcons(fileName string, loadIconsName bool) {
cfileName := C.CString(fileName)
defer C.free(unsafe.Pointer(cfileName))
C.GuiLoadIcons(cfileName, C.bool(loadIconsName))
}
// DrawIcon - draw icon using pixel size at specified position
func DrawIcon(iconId, posX, posY, pixelSize int32, col color.RGBA) {
C.GuiDrawIcon(C.int(iconId), C.int(posX), C.int(posY), C.int(pixelSize), *(*C.Color)(unsafe.Pointer(&col)))
}