Пример #1
0
func flushFunc(ctxt draw.Context) func(r draw.Rectangle) {
	if fctxt, ok := ctxt.(RectFlusherContext); ok {
		return func(r draw.Rectangle) {
			fctxt.FlushImageRect(r)
		}
	}
	return func(_ draw.Rectangle) {
		ctxt.FlushImage()
	}
}
Пример #2
0
func app(inContext draw.Context)
{
    vl_screen := inContext.Screen();

    screenr := draw.Rect(0, 0, vl_screen.Width(), vl_screen.Height());
    draw.Draw(vl_screen, screenr, draw.White, nil, draw.ZP);

    squareSize := 30;

    var cell *SMazeCell = new(SMazeCell);
    cell.draw(inContext, squareSize);

    inContext.FlushImage();

    fmt.Printf("Press the any key to exit.\n");
    for
    {
        select
        {
            case r := <- inContext.KeyboardChan():
                switch r
                {
                    case 'q', 'Q', 0x04, 0x7F, 32 :
                        fmt.Printf("Exiting because of keyboard event %d\n", r);
                        os.Exit(0);
                    default :
                        fmt.Printf("Exiting because of keyboard event %d\n", r);
                }
            case <- inContext.MouseChan():
                // No-op.
            case <- inContext.ResizeChan():
                // No-op.
            case <- inContext.QuitChan():
                fmt.Printf("Exiting because of QuitChan\n");
                return;
        }
    }
}