-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathboxbox_midi.go
67 lines (53 loc) · 1.12 KB
/
boxbox_midi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"time"
"github.com/buchanae/ink/app/client"
"github.com/buchanae/ink/color"
. "github.com/buchanae/ink/dd"
"github.com/buchanae/ink/gfx"
"github.com/buchanae/ink/rand"
)
const (
GridSize = 20
Boxes = 7
LineWidth = 0.0015
SkipCellChance = 0.05
SkipBoxChance = 0.20
Shrink = 0.0050
Angle = 0.2
)
func Ink(idoc gfx.Doc) {
doc := idoc.(*client.Doc)
for {
doc.Clear()
gfx.Clear(doc, color.White)
rand.SeedNow()
grid := Grid{Rows: GridSize, Cols: GridSize}
p := rand.Palette()
for _, cell := range grid.Cells() {
rect := cell.Rect
if rand.Bool(SkipCellChance) {
continue
}
for i := 0; i < Boxes; i++ {
if rand.Bool(SkipBoxChance) {
continue
}
r := rect.Shrink(float32(i+1) * Shrink)
q := r.Quad()
m := q.Stroke(StrokeOpt{
Width: LineWidth,
})
s := gfx.NewShader(m.Fill())
s.Set("a_color", rand.Color(p))
s.Set("a_pivot", r.Center())
s.Draw(doc)
if cell.Row > 5 {
s.Set("a_rot", rand.Range(-Angle, Angle))
}
}
}
client.Send(doc)
time.Sleep(1 * time.Second)
}
}