https://github.com/dfirebaugh/hlg
a high level graphics api using wgpu
https://github.com/dfirebaugh/hlg
Last synced: about 1 year ago
JSON representation
a high level graphics api using wgpu
- Host: GitHub
- URL: https://github.com/dfirebaugh/hlg
- Owner: dfirebaugh
- License: mit
- Created: 2023-09-18T01:04:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-10T14:49:01.000Z (over 1 year ago)
- Last Synced: 2025-03-25T21:14:36.323Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 2.13 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hlg (High Level Graphics)
This project is a WIP. The goal is to make a high level graphics api for golang.
[](https://pkg.go.dev/github.com/dfirebaugh/hlg)
Documentation: https://dfirebaugh.github.io/hlg/
### Examples
check the `./examples` dir for some basic examples
#### Triangle
```golang
package main
import (
"github.com/dfirebaugh/hlg"
"golang.org/x/image/colornames"
)
var triangle hlg.Shape
// update operation need to happen less frequently than render operations
func update() {
}
func render() {
hlg.Clear(colornames.Skyblue)
triangle.Render()
}
func main() {
hlg.SetWindowSize(720, 480)
hlg.SetScreenSize(240, 160)
triangle = hlg.Triangle(0, 160, 120, 0, 240, 160, colornames.Orangered)
hlg.Run(update, render)
}
```

#### Colored Triangle
```golang
package main
import (
"github.com/dfirebaugh/hlg"
"golang.org/x/image/colornames"
)
var triangle hlg.Shape
const (
screenWidth = 240
screenHeight = 160
)
// update operations happen less frequently than render operations
func update() {
}
func render() {
hlg.Clear(colornames.Skyblue)
triangle.Render()
}
func main() {
hlg.SetWindowSize(screenWidth, screenHeight)
hlg.SetTitle("color triangle")
triangle = hlg.PolygonFromVertices(0, 0, 0, []hlg.Vertex{
{
Position: [3]float32{0, screenHeight, 0},
Color: colornames.Red,
},
{
Position: [3]float32{screenWidth / 2, 0, 0},
Color: colornames.Green,
},
{
Position: [3]float32{screenWidth, screenHeight, 0},
Color: colornames.Blue,
},
})
hlg.Run(update, render)
}
```
