/
ninepatchFrame.go
46 lines (39 loc) · 1.1 KB
/
ninepatchFrame.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
package framework
import "github.com/lexisother/frenyard"
// A NinePatchFrameLayer provides the visuals for a given layer of a NinePatchFrame.
type NinePatchFrameLayer struct {
Pass FramePass
NinePatch
Scale float64
ColourMod uint32
Mode frenyard.DrawMode
}
// A NinePatchFrame uses a set of NinePatches as a container.
type NinePatchFrame struct {
Layers []NinePatchFrameLayer
Padding frenyard.Area2i
Clipping bool
}
// FyFDraw implements Frame.FyFDraw
func (npcf NinePatchFrame) FyFDraw(r frenyard.Renderer, size frenyard.Vec2i, pass FramePass) {
for _, layer := range npcf.Layers {
if layer.Pass != pass {
continue
}
layer.Draw(r, frenyard.Area2iOfSize(size), layer.Scale, frenyard.DrawRectCommand{
Colour: layer.ColourMod,
Mode: layer.Mode,
})
}
}
// FyFTick implements Frame.FyFTick
func (npcf NinePatchFrame) FyFTick(delta float64) {
}
// FyFPadding implements Frame.FyFPadding
func (npcf NinePatchFrame) FyFPadding() frenyard.Area2i {
return npcf.Padding
}
// FyFClipping implements Frame.FyFClipping
func (npcf NinePatchFrame) FyFClipping() bool {
return npcf.Clipping
}