From fb6a095aa0c97157e9f5485e22256385caaa3073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Tue, 20 Jun 2023 09:04:29 +0200 Subject: [PATCH] Update janein for rendering efficiency --- cmd/gen/janein/runner.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cmd/gen/janein/runner.go b/cmd/gen/janein/runner.go index f3a65a3..750faef 100644 --- a/cmd/gen/janein/runner.go +++ b/cmd/gen/janein/runner.go @@ -56,29 +56,24 @@ func (r *runner) run(ctx context.Context, cmd *cobra.Command, args []string) err canvas.Start(width, height) canvas.Desc(project.PatternDesc()) + canvas.Rect(0, 0, width, height, "fill:"+c1) + // Polygon. + xp1 := []int{0, 0, 60, 60, 40, 40} + yp1 := []int{0, 20, 20, -20, -20, 0} + canvas.Def(func() { canvas.Gid("unit", func() { - canvas.Rect(0, 0, 60, 20) + canvas.Polygon(xp1, yp1) }) }) - for x := -60; x < width+80; x += 80 { + for x := -40; x < width+80; x += 80 { xpositioncounter := 0 for y := -40; y < height+20; y += 20 { - if xpositioncounter%4 == 0 { - canvas.Rect(x, y, 80, 20, "fill: "+c2) - canvas.Use(x, y, "#unit", "fill:"+c1) - } if xpositioncounter%4 == 1 { - canvas.Rect(x+20, y, 80, 20, "fill: "+c1) canvas.Use(x+20, y, "#unit", "fill:"+c2) } - if xpositioncounter%4 == 2 { - canvas.Rect(x+40, y, 80, 20, "fill: "+c2) - canvas.Use(x+40, y, "#unit", "fill:"+c1) - } if xpositioncounter%4 == 3 { - canvas.Rect(x+60, y, 80, 20, "fill: "+c1) canvas.Use(x+60, y, "#unit", "fill:"+c2) } xpositioncounter++