本文整理汇总了Golang中exp/draw.Context.KeyboardChan方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.KeyboardChan方法的具体用法?Golang Context.KeyboardChan怎么用?Golang Context.KeyboardChan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exp/draw.Context
的用法示例。
在下文中一共展示了Context.KeyboardChan方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Init
func (m *SpacewarPDP1) Init(ctxt draw.Context) {
m.ctxt = ctxt
m.kc = ctxt.KeyboardChan()
m.screen = ctxt.Screen()
m.dx = m.screen.Width()
m.dy = m.screen.Height()
m.colorModel = m.screen.ColorModel()
m.pix = make([][]uint8, m.dy)
for i := range m.pix {
m.pix[i] = make([]uint8, m.dx)
}
m.cmap = make([]image.Color, 256)
for i := range m.cmap {
var r, g, b uint8
r = uint8(min(0, 255))
g = uint8(min(i*2, 255))
b = uint8(min(0, 255))
m.cmap[i] = m.colorModel.Convert(image.RGBAColor{r, g, b, 0xff})
}
}
示例2: app
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;
}
}
}