当前位置: 首页>>代码示例>>Golang>>正文


Golang PixMap.Copy方法代码示例

本文整理汇总了Golang中github.com/ArchRobison/Gophetica/nimble.PixMap.Copy方法的典型用法代码示例。如果您正苦于以下问题:Golang PixMap.Copy方法的具体用法?Golang PixMap.Copy怎么用?Golang PixMap.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/ArchRobison/Gophetica/nimble.PixMap的用法示例。


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

示例1: Draw

// Draw the "fall" view onto the given PixMap.
func Draw(pm nimble.PixMap, invaders []Invader) {
	if pm.Width() != background.Width() || pm.Height() != background.Height() {
		panic("fall.Draw: pm and background differ in size")
	}

	drawDot := false
	time := nimble.Now()
	if time-lastDotTime >= dotTimeInterval {
		lastDotTime = time
		drawDot = true
	}

	pm.Copy(0, 0, &background)
	xScale := float32(pm.Width() - tickHalfWidth)   // Avoid clipping tic on right side
	yScale := float32(pm.Height() - tickHalfHeight) // Avoid clippling tic on bottom
	xOffset := float32(0)
	yOffset := float32(0)
	for _, inv := range invaders {
		x := int32(inv.Amplitude*xScale + xOffset)
		y := int32(inv.Progress*yScale + yOffset)
		r := nimble.Rect{
			Left:   x - tickHalfWidth,
			Top:    y - tickHalfHeight,
			Right:  x + tickHalfWidth,
			Bottom: y + tickHalfHeight,
		}
		pm.DrawRect(r, inv.Color)
		background.DrawRect(r, nimble.Black)
		if drawDot {
			if doty := r.Top - 1; background.Contains(x, doty) {
				background.SetPixel(x, doty, inv.Color)
			}
		}
	}
}
开发者ID:ArchRobison,项目名称:FrequonInvaders,代码行数:36,代码来源:fall.go

示例2: Draw

// Draw draws the score (as binary lights) on the given PixMap.
func Draw(pm nimble.PixMap, scoreValue int) {
	if pm.Height() != lightHeight {
		panic(fmt.Sprintf("score.Draw: pm.Height()=%v lightHeight=%v\n", pm.Height(), lightHeight))
	}
	for k := range lightColor {
		s := state(scoreValue >> uint(nLight-k-1) & 1)
		src := nimble.MakePixMap(lightWidth, lightHeight, getLight(k, s), lightWidth)
		pm.Copy(lightWidth*int32(k), 0, &src)
	}
}
开发者ID:ArchRobison,项目名称:FrequonInvaders,代码行数:11,代码来源:score.go

示例3: Draw

func Draw(pm nimble.PixMap, cm colorMap, running bool) {
	setColoring(cm)
	width, height := pm.Size()
	if width != xSize || height != ySize {
		panic(fmt.Sprintf("radar.Draw: (width,height)=(%v,%v) (xSize,ySize)=(%v,%v)\n",
			width, height, xSize, ySize))
	}
	src := nimble.MakePixMap(width, height, getFrame(frameCounter), width)
	pm.Copy(0, 0, &src)
	if running {
		frameCounter = (frameCounter + 1) % (int32(len(frameStorage)) / frameSize)
	}
}
开发者ID:ArchRobison,项目名称:FrequonInvaders,代码行数:13,代码来源:radar.go


注:本文中的github.com/ArchRobison/Gophetica/nimble.PixMap.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。