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


Golang PixMap.Size方法代码示例

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


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

示例1: 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

示例2: drawFrequonsFourier

// drawFrequonsFourier draws the frequency-domain representation of Frequons.
func drawFrequonsFourier(pm nimble.PixMap) {
	c := universe.Zoo
	h := harmonicStorage[:len(c)]

	var ampScale float32
	if autoGain.Value {
		// Compute L1 norm of amplitudes
		norm := float32(0)
		for i := range c {
			norm += math32.Abs(c[i].Amplitude)
		}
		ampScale = 1 / norm
	} else {
		ampScale = 1 / float32(len(c))
	}
	fracX, fracY := universe.BoxFraction()
	fracX *= zoomCompression
	fracY *= zoomCompression
	sizeX, sizeY := pm.Size()

	// Set up harmonics
	// (cx,cy) is center of fourier view
	cx, cy := 0.5*float32(sizeX)*fracX, 0.5*float32(sizeY)*fracY
	α, β := -0.5*cx, -0.5*cy
	ωScale := 200. / float32(sizeX*sizeY)
	for i := range h {
		ωx := (c[i].Sx - cx) * ωScale
		ωy := (c[i].Sy - cy) * ωScale
		h[i].Ωx = ωx
		h[i].Ωy = ωy
		h[i].Phase = α*ωx + β*ωy + phaseRoll
		// Scale amplitude so that DFT values fit within domain of color lookup table.
		h[i].Amplitude = c[i].Amplitude * ampScale
	}

	marginX := int32(math32.Round(0.5 * float32(sizeX) * (1 - fracX)))
	marginY := int32(math32.Round(0.5 * float32(sizeY) * (1 - fracY)))
	fourier.Draw(pm.Intersect(nimble.Rect{
		Left:   marginX,
		Right:  sizeX - marginX,
		Top:    marginY,
		Bottom: sizeY - marginY,
	}), h, universe.Scheme())
	if marginX != 0 || marginY != 0 {
		pm.DrawRect(nimble.Rect{Left: 0, Right: sizeX, Top: 0, Bottom: marginY}, nimble.Black)
		pm.DrawRect(nimble.Rect{Left: 0, Right: sizeX, Top: sizeY - marginY, Bottom: sizeY}, nimble.Black)
		pm.DrawRect(nimble.Rect{Left: 0, Right: marginX, Top: marginY, Bottom: sizeY - marginY}, nimble.Black)
		pm.DrawRect(nimble.Rect{Left: sizeX - marginX, Right: sizeX, Top: marginY, Bottom: sizeY - marginY}, nimble.Black)
	}
}
开发者ID:ArchRobison,项目名称:FrequonInvaders,代码行数:51,代码来源:drawFrequons.go

示例3: Draw

// Draw draws the given sprite at (x0,y0) on dst with the given color.
func Draw(dst nimble.PixMap, x0, y0 int32, src Sprite, color nimble.Pixel) {
	w, h := dst.Size()
	for _, s := range src.rows {
		y := y0 + int32(s.y)
		if uint32(y) < uint32(h) {
			d := dst.Row(y)
			for _, xoffset := range s.x {
				x := x0 + int32(xoffset)
				if uint32(x) < uint32(w) {
					d[x] = color
				}
			}
		}
	}
}
开发者ID:ArchRobison,项目名称:FrequonInvaders,代码行数:16,代码来源:sprite.go

示例4: Draw

// Draw draws a Fourier transform on the given PixMap.
// Transform values must lie on the unit circle in the complex plane.
func Draw(pm nimble.PixMap, harmonics []Harmonic, cm colorMap) {
	setColoring(cm)
	n := len(harmonics)
	// m = n rounded up to even
	m := n + n&1
	u := uStorage[:m]
	v := vStorage[:m]
	w := wStorage[:m]
	for i, h := range harmonics {
		for k := 0; k < vlen; k++ {
			d := h.Amplitude * clutRadius
			c := euler(h.Phase + float32(k+vlen)*h.Ωx)
			w[i].re[k] = d * real(c)
			w[i].im[k] = d * imag(c)
		}
		u[i].u1 = euler(vlen * h.Ωx)
		u[i].u3 = euler(pixelsPerFoot * h.Ωx)
		v[i] = euler(h.Ωy)
	}
	if n < m {
		// Zero the extra element.
		w[n] = cvec{}
		u[n] = u13{}
		v[n] = 0
	}
	width, height := pm.Size()
	p := width / pixelsPerFoot // Number of whole feet
	q := p * pixelsPerFoot     // Number of pixels in whole feet
	r := width - q             // Number of pixels in partial foot
	feet := feetStorage[:(width+pixelsPerFoot-1)/pixelsPerFoot]
	for y := int32(0); y < height; y++ {
		for i := 0; i < n; i += 2 {
			accumulateToFeet(
				(*[2]cvec)(unsafe.Pointer(&w[i])),
				(*[2]u13)(unsafe.Pointer(&u[i])), feet)
		}
		rotate(w, v)
		feetToPixel(feet[:p], &clut, pm.Row(y))
		if r != 0 {
			feetToPixel(feet[p:p+1], &clut, tmpStorage[:])
			copy(pm.Row(y)[q:q+r], tmpStorage[:r])
		}
	}
}
开发者ID:ArchRobison,项目名称:FrequonInvaders,代码行数:46,代码来源:Draw_fast.go

示例5: draw

func draw(pm nimble.PixMap, text [][]byte) {
	if teletypeFont == nil {
		panic("teletype font missing")
	}
	width, height := pm.Size()

	// Clear area
	pm.Fill(nimble.Black)

	// Write lines of text
	for m := range text {
		x := int32(textLeftMargin)
		for j := range text[m] {
			if x >= width {
				break
			}
			kLimit := width - x
			if kLimit > charWidth {
				kLimit = charWidth
			}
			c := text[m][j]
			for i, mask := range teletypeFont[c] {
				y := int32(textTopMargin + m*textLineHeight + i)
				if y >= height {
					break
				}
				pixelRow := pm.Row(y)[x : x+kLimit]
				colorIndex := 0
				for k := range pixelRow {
					if mask&(1<<uint(k)) != 0 {
						pixelRow[k] = teletypeColor[colorIndex]
						colorIndex++
					} else {
						colorIndex = 0
					}
				}
			}
			x += charWidth
		}
	}
}
开发者ID:ArchRobison,项目名称:FrequonInvaders,代码行数:41,代码来源:draw.go


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