本文整理汇总了Golang中github.com/ArchRobison/Gophetica/nimble.PixMap.Height方法的典型用法代码示例。如果您正苦于以下问题:Golang PixMap.Height方法的具体用法?Golang PixMap.Height怎么用?Golang PixMap.Height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ArchRobison/Gophetica/nimble.PixMap
的用法示例。
在下文中一共展示了PixMap.Height方法的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)
}
}
}
}
示例2: Draw
// Generic version of Draw
func Draw(pm nimble.PixMap, harmonics []Harmonic, cm colorMap) {
setColoring(cm)
n := len(harmonics)
w := make([]complex64, n)
u := make([]complex64, n)
v := make([]complex64, n)
z := make([]complex64, n)
for i, h := range harmonics {
w[i] = complex(h.Amplitude*clutRadius, 0) * euler(h.Phase)
u[i] = euler(h.Ωx)
v[i] = euler(h.Ωy)
}
for y := int32(0); y < pm.Height(); y++ {
for i := 0; i < n; i++ {
z[i] = w[i]
w[i] *= v[i] // Rotate w by v
}
row := pm.Row(y)
for x := range row {
const offset float32 = clutCenter + 0.5
s := complex(offset, offset)
for i := 0; i < n; i++ {
s += z[i]
z[i] *= u[i]
}
row[x] = clut[int(imag(s))][int(real(s))]
}
}
}
示例3: 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)
}
}