generativeart/example/example_domainwrap.go

30 lines
621 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{
2021-03-30 09:10:04 +00:00
R: uint8(common.Constrain(m1*200*r, 0, 255)),
G: uint8(common.Constrain(r*200, 0, 255)),
B: uint8(common.Constrain(m2*255*r, 70, 255)),
A: 255,
2021-03-30 02:49:33 +00:00
}
return rgb
}
func main() {
rand.Seed(time.Now().Unix())
c := generativeart.NewCanva(500, 500)
c.SetBackground(common.Black)
c.FillBackground()
2021-04-07 09:22:53 +00:00
c.Draw(arts.NewDomainWrap(0.01, 4, 4, 20, cmap))
2021-03-30 02:49:33 +00:00
c.ToPNG("domainwarp.png")
}