-
Notifications
You must be signed in to change notification settings - Fork 13
/
app.go
47 lines (37 loc) · 940 Bytes
/
app.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
package main
import (
"context"
"fmt"
"github.com/djthorpe/gopi/v3"
)
////////////////////////////////////////////////////////////////////////////////
// TYPES
type app struct {
gopi.Unit
gopi.Logger
gopi.SurfaceManager
}
////////////////////////////////////////////////////////////////////////////////
// LIFECYCLE
func (this *app) New(cfg gopi.Config) error {
this.Require(this.Logger, this.SurfaceManager)
// Return success
return nil
}
func (this *app) Run(ctx context.Context) error {
if err := this.SurfaceManager.Do(func(ctx gopi.GraphicsContext) error {
if surface, err := this.SurfaceManager.CreateSurface(ctx, gopi.SURFACE_FLAG_OPENVG, 1.0, 100, gopi.Point{500, 500}, gopi.Size{100, 100}); err != nil {
return err
} else {
this.Print(surface)
}
return nil
}); err != nil {
return err
}
// Wait for interrupt
fmt.Println("Press CTRL+C to end")
<-ctx.Done()
// Return success
return nil
}