Merge pull request #391 from JupiterRider/GuiLoadIcons
[raygui] LoadIcons-, DrawIcon-function and example added
This commit is contained in:
commit
b7c9eeec1b
5 changed files with 36 additions and 0 deletions
3
examples/gui/icons/README.md
Normal file
3
examples/gui/icons/README.md
Normal 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.
|
||||||
|
|
||||||
|

|
BIN
examples/gui/icons/default_icons_with_255.rgi
Normal file
BIN
examples/gui/icons/default_icons_with_255.rgi
Normal file
Binary file not shown.
20
examples/gui/icons/main.go
Normal file
20
examples/gui/icons/main.go
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
BIN
examples/gui/icons/screenshot.png
Normal file
BIN
examples/gui/icons/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8 KiB |
|
@ -8,6 +8,7 @@ package raygui
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"image/color"
|
||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -1381,3 +1382,15 @@ func GetFont() rl.Font {
|
||||||
ptr := unsafe.Pointer(&ret)
|
ptr := unsafe.Pointer(&ret)
|
||||||
return *(*rl.Font)(ptr)
|
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)))
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue