GitHub - buchanae/ink: Creative coding in Go
source link: https://github.com/buchanae/ink
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
readme.md
Ink is a framework for creative 2D graphics in Go, based on OpenGL. Visit 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 build-essential, xorg-dev, libgflw3-dev, etc).
Write example.go
:
package main import ( "github.com/buchanae/ink/app" . "github.com/buchanae/ink/color" . "github.com/buchanae/ink/dd" . "github.com/buchanae/ink/gfx" ) func Ink(doc *Doc) { t := Triangle{ XY{0.2, 0.2}, XY{0.8, 0.2}, XY{0.5, 0.8}, } s := NewShader(t) s.Set("a_color", []RGBA{ Red, Green, Blue, }) s.Draw(doc) }
Run:
ink example.go
Ink opens a window and renders your triangle:
There are more examples in the sketches directory.
Status
This is a young project. It's tested only on MacOS 10.14.
Implementation Notes
Currently, Ink is based on OpenGL only, although other backends are desired. Ink is also focused primarily on 2D graphics so far, because everything is simpler in two dimensions, although I'd like to extend it to 3D some day.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK