moarpatterns #1
|
@ -112,3 +112,46 @@ func PlasmaPanel(w int, h int, speed uint16) [][]RGBcolor {
|
||||||
}
|
}
|
||||||
return grid
|
return grid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func singleColorPlasmaFromFloatVal(val float64, baseColor RGBcolor) (byte, byte, byte) {
|
||||||
|
var r byte
|
||||||
|
var g byte
|
||||||
|
var b byte
|
||||||
|
val = positiveModF(val)
|
||||||
|
r = baseColor[0] * val
|
||||||
|
g = baseColor[1] * val
|
||||||
|
b = baseColor[2] * val
|
||||||
|
return r, g, b
|
||||||
|
}
|
||||||
|
|
||||||
|
func PlasmaPanelSingleColor(w int, h int, speed uint16, baseColor RGBcolor) [][]RGBcolor {
|
||||||
|
grid := make([][]RGBcolor, w)
|
||||||
|
for i := 0; i < w; i++ {
|
||||||
|
grid[i] = make([]RGBcolor, h)
|
||||||
|
}
|
||||||
|
|
||||||
|
palletteOffset -= 0.05 / 1.0
|
||||||
|
if palletteOffset < 0 {
|
||||||
|
palletteOffset += 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
offset := 0.5 // center offset
|
||||||
|
scaleW := math.Pi * 2.0 / float64(w)
|
||||||
|
scaleH := math.Pi * 2.0 / float64(h)
|
||||||
|
|
||||||
|
for y := 0; y < h; y++ {
|
||||||
|
for x := 0; x < w; x++ {
|
||||||
|
u := math.Cos((float64(x) + offset) * scaleW)
|
||||||
|
v := math.Cos((float64(y) + offset) * scaleH)
|
||||||
|
j := math.Cos(offset * scaleW) // 2D - No Z
|
||||||
|
e := (u + v + j + 3.0) / 6.0
|
||||||
|
r, g, b := singleColorPlasmaFromFloatVal(palletteOffset+e, baseColor)
|
||||||
|
var rgb [3]byte
|
||||||
|
rgb[0] = r
|
||||||
|
rgb[1] = g
|
||||||
|
rgb[2] = b
|
||||||
|
grid[x][y] = rgb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return grid
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,17 @@ func PatternHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
e.Speed = 40
|
e.Speed = 40
|
||||||
}
|
}
|
||||||
|
if vars["color"] != "" {
|
||||||
|
var c queue.RGBcolor
|
||||||
|
for cn, cv := range colornames.Map {
|
||||||
|
if cn == strings.ToLower(vars["name"]) {
|
||||||
|
c[0] = cv.R
|
||||||
|
c[1] = cv.G
|
||||||
|
c[2] = cv.B
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.SeedColour = c
|
||||||
|
}
|
||||||
if vars["override"] == "true" {
|
if vars["override"] == "true" {
|
||||||
overrideFlag <- e
|
overrideFlag <- e
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,9 +170,13 @@ func HandleHTTP(queueChannel chan queue.QueueItem, Port int, overrideChannel cha
|
||||||
r.HandleFunc("/pattern/{pattern}/", PatternHandler)
|
r.HandleFunc("/pattern/{pattern}/", PatternHandler)
|
||||||
r.HandleFunc("/pattern/{pattern}/{duration}", PatternHandler)
|
r.HandleFunc("/pattern/{pattern}/{duration}", PatternHandler)
|
||||||
r.HandleFunc("/pattern/{pattern}/{duration}/{speed}", PatternHandler)
|
r.HandleFunc("/pattern/{pattern}/{duration}/{speed}", PatternHandler)
|
||||||
r.HandleFunc("/colour/{name}", ColourHandler)
|
r.HandleFunc("/colorpattern/{color}/{pattern}/override={override}", PatternHandler)
|
||||||
r.HandleFunc("/colour/{name}/override={override}", ColourHandler)
|
r.HandleFunc("/colorpattern/{color}/{pattern}/", PatternHandler)
|
||||||
r.HandleFunc("/colour/{name}/{duration}", ColourHandler)
|
r.HandleFunc("/colorpattern/{color}/{pattern}/{duration}", PatternHandler)
|
||||||
|
r.HandleFunc("/colorpattern/{color}/{pattern}/{duration}/{speed}", PatternHandler)
|
||||||
|
r.HandleFunc("/bloop/{name}", ColourHandler)
|
||||||
|
r.HandleFunc("/bloop/{name}/override={override}", ColourHandler)
|
||||||
|
r.HandleFunc("/bloop/{name}/{duration}", ColourHandler)
|
||||||
r.HandleFunc("/color/{name}", ColourHandler)
|
r.HandleFunc("/color/{name}", ColourHandler)
|
||||||
r.HandleFunc("/color/{name}/override={override}", ColourHandler)
|
r.HandleFunc("/color/{name}/override={override}", ColourHandler)
|
||||||
r.HandleFunc("/color/{name}/{duration}", ColourHandler)
|
r.HandleFunc("/color/{name}/{duration}", ColourHandler)
|
||||||
|
|
Loading…
Reference in New Issue