• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang draw.Context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中exp/draw.Context的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Context类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: flushFunc

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()
	}
}
开发者ID:zenoss,项目名称:rog-go,代码行数:10,代码来源:mandel.go


示例2: 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})
	}
}
开发者ID:lougxing,项目名称:golang-china,代码行数:20,代码来源:spacewar.go


示例3: Play

func Play(pp []Piece, ctxt draw.Context) {
	display = ctxt
	screen = ctxt.Screen()
	screenr = draw.Rect(0, 0, screen.Width(), screen.Height())
	pieces = pp
	N = len(pieces[0].d)
	initPieces()
	rand.Seed(int32(time.Nanoseconds() % (1e9 - 1)))
	whitemask = draw.White.SetAlpha(0x7F)
	tsleep = 50
	timerc = time.Tick(int64(tsleep/2) * 1e6)
	suspc = make(chan bool)
	mousec = make(chan draw.Mouse)
	resizec = ctxt.ResizeChan()
	kbdc = make(chan int)
	go quitter(ctxt.QuitChan())
	go suspproc()
	points = 0
	redraw(false)
	play()
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:21,代码来源:xs.go


示例4: draw

func (inpMazeCell *SMazeCell) draw(inContext draw.Context, inSquareSize int)
{
    vl_screen := inContext.Screen();

    upXLeft, upYLeft := 100, 100;
    squareSize := inSquareSize;

    fullCell := draw.Rect(upXLeft, upYLeft, squareSize + upXLeft, squareSize + upYLeft);
    draw.Draw(vl_screen, fullCell, draw.Black, nil, draw.ZP);

    // inset set the color of the inside
    draw.Draw(vl_screen, fullCell.Inset(1), draw.White, nil, draw.ZP);

    //hide a wall with a rectangle... POOR SOLUTION !!
    if inpMazeCell.northOpen
    {
        // up wall
        hiderup := draw.Rect(upXLeft, upYLeft,
                             upXLeft + squareSize, upYLeft + 1);
        draw.Draw(vl_screen, hiderup, draw.White, nil, draw.ZP);
    }
    else
    {
        // do not hide
    }

    if inpMazeCell.westOpen
    {
        // right wall
        hiderright := draw.Rect(upXLeft + squareSize - 1, upYLeft,
                                upXLeft + squareSize, upYLeft + squareSize);
        draw.Draw(vl_screen, hiderright, draw.White, nil, draw.ZP);
    }
    else
    {
        // do not hide
    }

    if inpMazeCell.southOpen
    {
        // down wall
        hiderdown := draw.Rect(upXLeft, upYLeft + squareSize - 1,
                              upXLeft + squareSize, upYLeft + squareSize);
        draw.Draw(vl_screen, hiderdown, draw.White, nil, draw.ZP);
    }
    else
    {
        // do not hide
    }

    if inpMazeCell.eastOpen
    {
        // left wall
        hiderleft := draw.Rect(upXLeft, upYLeft,
                               upXLeft + 1, upYLeft + squareSize);
        draw.Draw(vl_screen, hiderleft, draw.White, nil, draw.ZP);
    }
    else
    {
        // do not hide
    }
}
开发者ID:belkiss,项目名称:GoMaze,代码行数:62,代码来源:main.go


示例5: 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;
        }
    }
}
开发者ID:belkiss,项目名称:GoMaze,代码行数:38,代码来源:main.go



注:本文中的exp/draw.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang draw.Image类代码示例发布时间:2022-05-24
下一篇:
Golang draw.Pt函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap