-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblock.go
More file actions
52 lines (44 loc) · 774 Bytes
/
block.go
File metadata and controls
52 lines (44 loc) · 774 Bytes
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
package main
import "github.com/forestgiant/eff"
type block struct {
eff.Point
color eff.Color
size int
offsetPoint eff.Point
}
func (b *block) draw(c eff.Canvas) {
s := b.size
if s == 0 {
s = squareSize
}
borderColor := eff.Color{
R: 255,
G: 255,
B: 255,
A: 255,
}
x := b.X * s
y := b.Y*s + scoreboardHeight
spacing := s / 10
borderRect := eff.Rect{
X: x,
Y: y,
W: s,
H: s,
}
fillRect := eff.Rect{
X: x + spacing,
Y: y + spacing,
W: s - (spacing * 2),
H: s - (spacing * 2),
}
c.DrawRect(borderRect, borderColor)
c.FillRect(fillRect, b.color)
}
func (b *block) drawWithPoint(p eff.Point, c eff.Canvas) {
bPrime := block{}
bPrime.X = b.X + p.X
bPrime.Y = b.Y + p.Y
bPrime.color = b.color
bPrime.draw(c)
}