Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Last active March 14, 2019 14:57
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/7268cd6622e7723907923a77370d1c9a to your computer and use it in GitHub Desktop.
Save peterhellberg/7268cd6622e7723907923a77370d1c9a to your computer and use it in GitHub Desktop.
The Lendo L repeated with signed distance functions using gfx.
package main
import "github.com/peterhellberg/gfx"
func main() {
dst := gfx.NewImage(2560, 1440, PaletteLendo.Color(0))
gfx.EachImageVec(dst, gfx.ZV, func(u gfx.Vec) {
sd := gfx.SignedDistance{gfx.IM.Moved(gfx.V(50, -10)).Project(u)}
d := sd.OpRepeat(gfx.V(320, 360), lendoL)
switch {
case d < 8 && d > 0:
gfx.SetVec(dst, u, PaletteLendo.Color(1))
case d < -2:
gfx.SetVec(dst, u, PaletteLendo.Color(11))
case d < 0:
gfx.SetVec(dst, u, PaletteLendo.Color(10))
}
})
gfx.SavePNG("gfx-lendo.png", dst)
}
func lendoL(sd gfx.SignedDistance) float64 {
return sd.OpUnion(
sd.Rectangle(gfx.V(34, 150)),
sd.OpTx(gfx.IM.Moved(gfx.V(52, 118)), func(sd gfx.SignedDistance) float64 {
return sd.Rectangle(gfx.V(86, 32))
}),
)
}
var PaletteLendo = gfx.Palette{
{0x2A, 0xC7, 0x68, 0xFF}, // green
{0x26, 0xB3, 0x5D, 0xFF}, // dark green
{0xFE, 0xD9, 0x00, 0xFF}, // yellow
{0xFE, 0xAE, 0x00, 0xFF}, // orange
{0xF2, 0x25, 0x6C, 0xFF}, // pink
{0xDC, 0x1A, 0x3C, 0xFF}, // red
{0x00, 0x7A, 0xFF, 0xFF}, // blue
{0x19, 0x76, 0xD2, 0xFF}, // dark blue
{0x27, 0x30, 0x40, 0xFF}, // dark space
{0xDB, 0xF2, 0xF9, 0xFF}, // light blue
{0xF7, 0xF9, 0xFF, 0xFF}, // light gray
{0xFF, 0xFF, 0xFF, 0xFF}, // white
}
@peterhellberg
Copy link
Author

peterhellberg commented Mar 14, 2019

gfx-lendo

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