generativeart/example/example_domainwrap.go

30 lines
605 B
Go
Raw Normal View History

2021-03-30 02:49:33 +00:00
package main
import (
"github.com/jdxyw/generativeart"
"github.com/jdxyw/generativeart/arts"
"github.com/jdxyw/generativeart/common"
"image/color"
"math/rand"
"time"
)
func cmap(r, m1, m2 float64) color.RGBA {
rgb := color.RGBA{
uint8(common.Constrain(m1*255*r, 0, 255)),
uint8(common.Constrain(r*200, 0, 255)),
uint8(common.Constrain(m2*255*r, 70, 255)),
255,
}
return rgb
}
func main() {
rand.Seed(time.Now().Unix())
c := generativeart.NewCanva(500, 500)
c.SetBackground(common.Black)
c.FillBackground()
c.Draw(arts.NewDomainWrap(0.01, 4, 8, cmap))
c.ToPNG("domainwarp.png")
}