Created
March 1, 2020 19:06
-
-
Save peterhellberg/ce85e6af3b57ab08de69c57119c258bf to your computer and use it in GitHub Desktop.
Cubic Bezier Curve using gfx
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 "github.com/peterhellberg/gfx" | |
var ( | |
p = gfx.PaletteAmmo8 | |
dst = gfx.NewImage(256, 256, p[1]) | |
p0 = gfx.V(16, 192) | |
p1 = gfx.V(32, 8) | |
p2 = gfx.V(192, 244) | |
p3 = gfx.V(240, 128) | |
inc = 0.0009 | |
) | |
func main() { | |
gfx.DrawLineBresenham(dst, p0, p1, p[0]) | |
gfx.DrawLineBresenham(dst, p2, p3, p[0]) | |
gfx.DrawCicleFast(dst, p0, 4, p[0]) | |
gfx.DrawCicleFast(dst, p1, 4, p[0]) | |
gfx.DrawCicleFast(dst, p2, 4, p[0]) | |
gfx.DrawCicleFast(dst, p3, 4, p[0]) | |
for i, v := range gfx.CubicBezierCurve(p0, p1, p2, p3, inc) { | |
gfx.SetVec(dst, v, p.At(float64(i)*inc)) | |
} | |
gfx.SavePNG("/tmp/bezier.png", gfx.NewScaledImage(dst, 2)) | |
} |
Author
peterhellberg
commented
Mar 1, 2020
Ammo8 | Arne16 | Ink | PICO8 |
---|---|---|---|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment