本文整理汇总了Golang中github.com/ArchRobison/Gophetica/nimble.PixMap.Row方法的典型用法代码示例。如果您正苦于以下问题:Golang PixMap.Row方法的具体用法?Golang PixMap.Row怎么用?Golang PixMap.Row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ArchRobison/Gophetica/nimble.PixMap
的用法示例。
在下文中一共展示了PixMap.Row方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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))]
}
}
}
示例2: 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
}
}
}
}
}
示例3: 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])
}
}
}
示例4: 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
}
}
}