Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Created February 14, 2019 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterhellberg/069f6fb11684fb0d5bc75c12aab4705c to your computer and use it in GitHub Desktop.
Save peterhellberg/069f6fb11684fb0d5bc75c12aab4705c to your computer and use it in GitHub Desktop.
Simplex noise blocks using gfx.
package main
import "github.com/peterhellberg/gfx"
func main() {
var (
blocks gfx.Blocks
origin = gfx.V3(640, -1280*2, 9)
sn = gfx.NewSimplexNoise(17)
dst = gfx.NewImage(1280, 1280)
)
gfx.EachImageVec(dst, gfx.V(3, -3), func(u gfx.Vec) {
n := gfx.MathAbs(sn.Noise2D(u.X/50, u.Y/50))
p := gfx.V3(u.X, u.Y, 0)
s := gfx.V3(1, 1, n*10)
blocks.AddNewBlock(p, s, gfx.BlockColorBlue)
})
blocks.Sort()
blocks.DrawWireframes(dst, origin)
gfx.SavePNG("gfx-simplex-blocks.png", dst)
}
@peterhellberg
Copy link
Author

gfx-simplex-blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment