Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buchanae/ink
Creative coding in Go
https://github.com/buchanae/ink
2d-graphics creative-coding generative-art golang opengl
Last synced: 3 months ago
JSON representation
Creative coding in Go
- Host: GitHub
- URL: https://github.com/buchanae/ink
- Owner: buchanae
- Created: 2019-12-12T06:03:05.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-17T16:54:30.000Z (almost 3 years ago)
- Last Synced: 2024-06-19T21:10:18.521Z (5 months ago)
- Topics: 2d-graphics, creative-coding, generative-art, golang, opengl
- Language: Go
- Homepage: https://buchanae.github.io/ink/
- Size: 15.2 MB
- Stars: 147
- Watchers: 5
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- go-awesome - ink - 2D graphics framework in Go (Open source library / Charts)
README
Ink is a framework for creative 2D graphics in [Go](https://golang.org), based on OpenGL. Visit [buchanae.github.io/ink](https://buchanae.github.io/ink/) for more.
### Example: a simple triangle
Install:
```
go get github.com/buchanae/ink
```(Building Ink is a little tricky, because it depends on GLFW. You might need to install these packages:
```
build-essential
xorg-dev
```Write `example.go`:
```go
package mainimport (
. "github.com/buchanae/ink/color"
. "github.com/buchanae/ink/dd"
"github.com/buchanae/ink/gfx"
)func Ink(doc gfx.Doc) {
t := Triangle{
XY{0.2, 0.2},
XY{0.8, 0.2},
XY{0.5, 0.8},
}
s := gfx.Fill{Shape: t}.Shader()
s.Set("a_color", []RGBA{
Red, Green, Blue,
})
s.Draw(doc)
}
```Run:
```
ink example.go
```Ink opens a window and renders your triangle:
![Triangle example](https://buchanae.github.io/ink/assets/snapshots/001_triangle.png)
There are more examples in the [sketches](./sketches) directory.
### Implementation Notes
- Ink is based on OpenGL only, although other backends are desired. There is an experimental WebGL branch.
- Ink is focused on 2D graphics, although 3D is desired some day.
- Most numbers are float32, because OpenGL APIs are mostly based on float32s.
- This is also why I haven't used the Go stdlib `image/color`. I admit this feels messy.
- Angles are in radians, unless otherwise noted.