Last active
April 1, 2024 07:59
-
-
Save eihigh/e9f238ea652408fb71b43c0895c6083d to your computer and use it in GitHub Desktop.
Experimental 2D Graphics API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "g2d" | |
func main() { | |
buf := g2d.Upload(g2d.Uniform(g2d.Transparent, g2d.Vec2{64, 64})) | |
tex := g2d.Upload(someImg) | |
buf.Draw(tex, g2d.Shifts(16, 16).Rotate(g2d.Tau/9)) | |
d := g2d.Drawer{Dst: buf, Sampler: g2d.Linear, Frag: g2d.BlendAdd} | |
d.Draw(tex, g2d.Circle, g2d.Scales(40, 40)) | |
p := g2d.Path().LineTo(pos).QuadTo(pos2) | |
buf.Draw(g2d.Brush, p.Stroke(g2d.StrokeStyle), g2d.Colorize(cyan)) | |
pixels := make(g2d.Pixels, 0, 64*64) | |
pixels = buf.Download(pixels) | |
png.Encode(f, pixels) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment