update some comments

This commit is contained in:
Norwin Roosen 2021-01-02 15:51:13 +01:00
parent 5a25388d84
commit 0700f6c11b
No known key found for this signature in database
GPG Key ID: 24BC059DE24C43A3
4 changed files with 8 additions and 12 deletions

View File

@ -3,7 +3,6 @@ package pixelflut
import ( import (
"fmt" "fmt"
"image" "image"
"image/color"
"math/rand" "math/rand"
) )
@ -66,7 +65,7 @@ func commandsFromImage(img *image.NRGBA, order RenderOrder, offset image.Point)
x, y = y, x x, y = y, x
} }
c := img.At(x, y).(color.NRGBA) c := img.NRGBAAt(x, y)
if c.A == 0 { if c.A == 0 {
continue 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", cmd = fmt.Sprintf("PX %d %d %.2x%.2x%.2x\n",
x+offset.X, y+offset.Y, c.R, c.G, c.B) 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++ numCmds++
} }
} }

View File

@ -22,7 +22,7 @@ type FlutTaskOpts struct {
MaxConns int MaxConns int
Offset image.Point Offset image.Point
Paused bool Paused bool
RGBSplit bool RGBSplit bool // @cleanup: replace with `FX: []Effect`
RandOffset bool RandOffset bool
RenderOrder RenderOrder RenderOrder RenderOrder
} }
@ -74,10 +74,7 @@ const (
Shuffle = 0b100 Shuffle = 0b100
) )
// Flut asynchronously sends the given image to pixelflut server at `address` // Flut asynchronously executes the given FlutTask, until `stop` is closed.
// using `conns` connections. Pixels are sent column wise, unless `shuffle`
// is set. Stops when stop is closed.
// @cleanup: use FlutTask{} as arg
func Flut(t FlutTask, stop chan bool, wg *sync.WaitGroup) { func Flut(t FlutTask, stop chan bool, wg *sync.WaitGroup) {
if !t.IsFlutable() { if !t.IsFlutable() {
return // @robustness: actually return an error here? return // @robustness: actually return an error here?

View File

@ -92,8 +92,8 @@ func initPerfReporter() *Performance {
return r return r
} }
// bombAddress writes the given message via plain TCP to the given address, // bombAddress opens a TCP connection to `address`, and writes `message` repeatedly, until `stop` is closed.
// as fast as possible, until stop is closed. retries with exponential backoff on network errors. // It retries with exponential backoff on network errors.
func bombAddress(message []byte, address string, maxOffsetX, maxOffsetY int, stop chan bool, wg *sync.WaitGroup) { func bombAddress(message []byte, address string, maxOffsetX, maxOffsetY int, stop chan bool, wg *sync.WaitGroup) {
wg.Add(1) wg.Add(1)
defer wg.Done() 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 { func bombConn(message []byte, maxOffsetX, maxOffsetY int, conn net.Conn, stop chan bool) error {
PerformanceReporter.connsReporter <- 1 PerformanceReporter.connsReporter <- 1
defer func() { PerformanceReporter.connsReporter <- -1 }() defer func() { PerformanceReporter.connsReporter <- -1 }()

View File

@ -17,14 +17,12 @@ func pt(p fixed.Point26_6) image.Point {
} }
func RenderText(text string, scale int, texture, bgTex image.Image) *image.NRGBA { func RenderText(text string, scale int, texture, bgTex image.Image) *image.NRGBA {
// @incomplete: draw with texture via Drawer.Src
face := basicfont.Face7x13 face := basicfont.Face7x13
stringBounds, _ := font.BoundString(face, text) stringBounds, _ := font.BoundString(face, text)
b := image.Rectangle{pt(stringBounds.Min), pt(stringBounds.Max)} b := image.Rectangle{pt(stringBounds.Min), pt(stringBounds.Max)}
img := image.NewNRGBA(b) img := image.NewNRGBA(b)
// fill with black bg
if bgTex != nil { if bgTex != nil {
draw.Draw(img, b, bgTex, image.Point{}, draw.Src) draw.Draw(img, b, bgTex, image.Point{}, draw.Src)
} }