From 9ff744e60e6bb2885de7d1c50d8357f0e96fc2e1 Mon Sep 17 00:00:00 2001 From: Yongwei Xing Date: Wed, 3 Mar 2021 13:09:59 +0800 Subject: [PATCH] remove wave --- example/example.go | 18 ------------------ wave.go | 42 ------------------------------------------ 2 files changed, 60 deletions(-) delete mode 100644 example/example.go delete mode 100644 wave.go diff --git a/example/example.go b/example/example.go deleted file mode 100644 index 48f971d..0000000 --- a/example/example.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "generativeart" - "math" -) - -func formula1(x, y float64) (float64, float64) { - return 0.18*x*x - math.Sin(y*y), - 0.059*y*y*y - math.Cos(x*x) -} - -func main() { - c := generativeart.NewCanva(1600, 1600, 2, 2) - c.FillBackground() - c.Draw(generativeart.NewWave(formula1)) - c.ToPNG("g1.png") -} diff --git a/wave.go b/wave.go deleted file mode 100644 index 6889963..0000000 --- a/wave.go +++ /dev/null @@ -1,42 +0,0 @@ -package generativeart - -import ( - "math" - - "github.com/fogleman/gg" -) - -type Formula func(x, y float64) (float64, float64) - -type wave struct { - fn Formula -} - -// NewWave returns a wave generator. -func NewWave(fn Formula) *wave { - return &wave{fn: fn} -} - -// Generative draws the image. -func (w *wave) Generative(c *canva) { - ctex := gg.NewContextForRGBA(c.img) - for x := -math.Pi; x <= math.Pi; x += 0.01 { - for y := -math.Pi; y <= math.Pi; y += 0.01 { - xi, yi := w.fn(x, y) - var i, j int - if c.opts.isPolarCoodinate { - i, j = ConvertCartesianToPolarPixel(xi, yi, c.xaixs, c.yaixs, c.height, c.width) - } else { - i, j = ConvertCartesianToPixel(xi, yi, c.xaixs, c.yaixs, c.height, c.width) - } - - if i < 0 || i > c.width-1 || j < 0 || j > c.height-1 { - continue - } - - ctex.DrawCircle(float64(i), float64(j), c.opts.radius) - ctex.SetColor(c.opts.foreground) - ctex.Fill() - } - } -}