update some comments
This commit is contained in:
parent
5a25388d84
commit
0700f6c11b
|
@ -3,7 +3,6 @@ package pixelflut
|
|||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
|
@ -66,7 +65,7 @@ func commandsFromImage(img *image.NRGBA, order RenderOrder, offset image.Point)
|
|||
x, y = y, x
|
||||
}
|
||||
|
||||
c := img.At(x, y).(color.NRGBA)
|
||||
c := img.NRGBAAt(x, y)
|
||||
if c.A == 0 {
|
||||
continue
|
||||
}
|
||||
|
@ -79,7 +78,7 @@ func commandsFromImage(img *image.NRGBA, order RenderOrder, offset image.Point)
|
|||
cmd = fmt.Sprintf("PX %d %d %.2x%.2x%.2x\n",
|
||||
x+offset.X, y+offset.Y, c.R, c.G, c.B)
|
||||
}
|
||||
cmds[numCmds] = []byte(cmd)
|
||||
cmds[numCmds] = []byte(cmd) // @speed: conversion to []byte costs an extra allocation..
|
||||
numCmds++
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ type FlutTaskOpts struct {
|
|||
MaxConns int
|
||||
Offset image.Point
|
||||
Paused bool
|
||||
RGBSplit bool
|
||||
RGBSplit bool // @cleanup: replace with `FX: []Effect`
|
||||
RandOffset bool
|
||||
RenderOrder RenderOrder
|
||||
}
|
||||
|
@ -74,10 +74,7 @@ const (
|
|||
Shuffle = 0b100
|
||||
)
|
||||
|
||||
// Flut asynchronously sends the given image to pixelflut server at `address`
|
||||
// using `conns` connections. Pixels are sent column wise, unless `shuffle`
|
||||
// is set. Stops when stop is closed.
|
||||
// @cleanup: use FlutTask{} as arg
|
||||
// Flut asynchronously executes the given FlutTask, until `stop` is closed.
|
||||
func Flut(t FlutTask, stop chan bool, wg *sync.WaitGroup) {
|
||||
if !t.IsFlutable() {
|
||||
return // @robustness: actually return an error here?
|
||||
|
|
|
@ -92,8 +92,8 @@ func initPerfReporter() *Performance {
|
|||
return r
|
||||
}
|
||||
|
||||
// bombAddress writes the given message via plain TCP to the given address,
|
||||
// as fast as possible, until stop is closed. retries with exponential backoff on network errors.
|
||||
// bombAddress opens a TCP connection to `address`, and writes `message` repeatedly, until `stop` is closed.
|
||||
// It retries with exponential backoff on network errors.
|
||||
func bombAddress(message []byte, address string, maxOffsetX, maxOffsetY int, stop chan bool, wg *sync.WaitGroup) {
|
||||
wg.Add(1)
|
||||
defer wg.Done()
|
||||
|
@ -125,6 +125,8 @@ func bombAddress(message []byte, address string, maxOffsetX, maxOffsetY int, sto
|
|||
}
|
||||
}
|
||||
|
||||
// bombConn writes the given message to the given connection in a tight loop, until `stop` is closed.
|
||||
// Does no transformation on the given message, so make sure packet splitting / nagle works.
|
||||
func bombConn(message []byte, maxOffsetX, maxOffsetY int, conn net.Conn, stop chan bool) error {
|
||||
PerformanceReporter.connsReporter <- 1
|
||||
defer func() { PerformanceReporter.connsReporter <- -1 }()
|
||||
|
|
|
@ -17,14 +17,12 @@ func pt(p fixed.Point26_6) image.Point {
|
|||
}
|
||||
|
||||
func RenderText(text string, scale int, texture, bgTex image.Image) *image.NRGBA {
|
||||
// @incomplete: draw with texture via Drawer.Src
|
||||
face := basicfont.Face7x13
|
||||
stringBounds, _ := font.BoundString(face, text)
|
||||
|
||||
b := image.Rectangle{pt(stringBounds.Min), pt(stringBounds.Max)}
|
||||
img := image.NewNRGBA(b)
|
||||
|
||||
// fill with black bg
|
||||
if bgTex != nil {
|
||||
draw.Draw(img, b, bgTex, image.Point{}, draw.Src)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue