func (d *GrainLine) Render() { d.Clear("fff") d.Scale(1.0, -1.0) d.Translate(0.0, -d.Dim.Y) pos := vec.New(100.0, 100.0) v := vec.New(Cos(PI/6.0), Sin(PI/6.0)) for y := 101.0; y < 110.0; y++ { c := hex_color.HexColor("0f0") d.SetStrokeColor(c) a := vec.New(pos.Pts()) for s := 1.0; s < 100.0; s++ { c.WithAlpha((101.0 - s) / 100.0) d.SetStrokeColor(c) d.BeginPath() d.MoveTo(a.Pts()) a = v.Scale(s, s).Add(*pos) d.LineTo(a.Pts()) d.Stroke() } pos = vec.New(pos.X, y) } }
func (g *Tiles) Draw() *pix.Canvas { g.Clear("fff") colors := ReadColors() pos := vec.New(1, 1) dim := vec.New(g.TileWidth, g.TileHeight) p := pos d := dim k := 0 size := len(colors) gap := 1.0 maxW := g.Dim.X maxH := g.Dim.Y for j := 0.0; (p.Y + d.Y + gap) <= maxH; j++ { for i := 0.0; (p.X + d.X + gap) <= maxW; i++ { c := colors[k%size] g.SetFillColor(c) g.SetStrokeColor(c) g.tile(p, d) k++ p = p.TranslateX(d.X + 1) } k += 2 p = p.Translate(-p.X+1, d.Y+1) } return g.Canvas }
func NewFade() *Fade { return &Fade{ Canvas: pix.NewCanvas(&pix.Canvas{ Dim: vec.New(600.0, 400.0), Pos: vec.New(0.0, 0.0), Name: "Fade", FileName: ".files/wip/fade.png", }), } }
func (g *Diamonds) Render() { g.Clear("fff") center := g.Center() g.Translate(float64(center.X), float64(center.Y)) h := vec.New(50.0, 0.0) v := vec.New(0.0, 15.0) step := 34 g.render(g.GraphicContext, h, v, g.steps(step)) }
func NewTiles() *Tiles { return &Tiles{ Canvas: pix.NewCanvas(&pix.Canvas{ Dim: vec.New(661.0, 441.0), Pos: vec.New(0.0, 0.0), Name: "Tiles", FileName: ".files/wip/tiles.png", }), TileWidth: 10, TileHeight: 10, } }
func (g *StarPattern) Draw() *pix.Canvas { g.Clear("fff") pos := vec.Zero() dim := vec.New(70.0, 70.0) ct := dim.Scale(0.5, 0.5) hct := ct.Scale(0.5, 0.5) for pos.Y < g.Dim.Y { for pos.X < g.Dim.X { p1 := pos.Translate(ct.X, 0.0) p2 := pos.Add(*ct) g.Star(p1, hct) g.LineTo(p2.Pts()) g.LineTo(p1.Pts()) g.SetFillColor(hex_color.Black) g.Fill() pos = pos.Translate(dim.X, 0.0) } pos = vec.Zero().Translate(0.0, pos.Y+dim.Y) } return g.Canvas }
func Basic(name, file string) *Canvas { return NewCanvas(&Canvas{ Dim: vec.New(600.0, 400.0), Pos: vec.Zero(), Name: name, FileName: file, }) }
func (g *RandDots) Draw() *pix.Canvas { g.Clear("ffffff") color := HexColor("f00") g.SetFillColor(color) g.SetStrokeColor(color) r := 3200 //int(g.Dim.Area() * 0.05) w := vec.New(10.0, 10.0) for i := 0; i < r; i++ { x := RandFloat(0, g.Dim.X) y := RandFloat(0, g.Dim.Y) pos := vec.New(x, y) color.WithAlpha(RandFloat(0.0, 1.0)) g.SetFillColor(color) g.FillRect(pos, w) } return g.Canvas }
func (g *Fade) Draw() *pix.Canvas { g.Clear("fff") mg := 10.0 maxH := g.Dim.Y - mg maxW := g.Dim.X - mg pos := vec.New(mg, mg) rng := int(maxW - mg) p := pos g.SetStrokeColor(HexColor("900")) for y := 0; y < int(maxH-mg); y++ { w := float64(rand.Intn(rng)) + mg g.BeginPath() g.MoveTo(p.X, p.Y) g.LineTo(w, p.Y) g.Stroke() p = p.TranslateY(1) } return g.Canvas }