refactorings + basis of script editor.

This commit is contained in:
2023-09-26 22:43:27 +02:00
parent 2188d489ea
commit 13da56009e
30 changed files with 52989 additions and 521 deletions
-29
View File
@@ -1,29 +0,0 @@
package main
import (
lucifer3 "git.aiterp.net/lucifer3/server"
"git.aiterp.net/lucifer3/server/services"
"git.aiterp.net/lucifer3/server/services/effectenforcer"
"git.aiterp.net/lucifer3/server/services/hue"
"git.aiterp.net/lucifer3/server/services/mill"
"git.aiterp.net/lucifer3/server/services/nanoleaf"
"git.aiterp.net/lucifer3/server/services/tradfri"
"time"
)
func main() {
bus := lucifer3.EventBus{}
resolver := services.NewResolver()
sceneMap := services.NewSceneMap(resolver)
bus.JoinPrivileged(resolver)
bus.JoinPrivileged(sceneMap)
bus.Join(effectenforcer.NewService(resolver, sceneMap))
bus.Join(nanoleaf.NewService())
bus.Join(hue.NewService())
bus.Join(tradfri.NewService())
bus.Join(mill.NewService())
time.Sleep(time.Hour)
}
+47
View File
@@ -0,0 +1,47 @@
package main
import (
"git.aiterp.net/lucifer3/server/internal/color"
"image"
color2 "image/color"
"image/png"
"math"
"os"
)
func main() {
img := image.NewRGBA(image.Rect(0, 0, 1000, 1000))
for y := 0; y < 1000; y += 1 {
for x := 0; x < 1000; x += 1 {
vecX := float64(x-500) / 500.0
vecY := float64(y-500) / 500.0
dist := math.Sqrt(vecX*vecX + vecY*vecY)
angle := math.Mod((math.Atan2(vecY/dist, vecX/dist)*(180/math.Pi))+360+90, 360)
if dist >= 0.9 && dist < 1 && angle > 2.5 && angle < 357.5 {
k := 1000 + int(11000*((angle-2.5)/355))
c := color.Color{K: &k}
rgb, _ := c.ToRGB()
img.Set(x, y, color2.RGBA{
R: uint8(rgb.RGB.Red * 255.0),
G: uint8(rgb.RGB.Green * 255.0),
B: uint8(rgb.RGB.Blue * 255.0),
A: 255,
})
} else if dist < 0.85 {
rgb := (color.HueSat{Hue: math.Mod(angle+180, 360), Sat: dist / 0.85}).ToRGB()
img.Set(x, y, color2.RGBA{
R: uint8(rgb.Red * 255.0),
G: uint8(rgb.Green * 255.0),
B: uint8(rgb.Blue * 255.0),
A: 255,
})
} else {
img.Set(x, y, color2.RGBA{R: 0, G: 0, B: 0, A: 0})
}
}
}
_ = png.Encode(os.Stdout, img)
}
+32
View File
@@ -0,0 +1,32 @@
package main
import (
"git.aiterp.net/lucifer3/server/internal/color"
"image"
color2 "image/color"
"image/png"
"log"
"os"
)
func main() {
img := image.NewRGBA(image.Rect(0, 0, 500, 500))
for y := 0; y < 500; y += 1 {
for x := 0; x < 500; x += 1 {
rgb := (color.XY{X: float64(x) / 499, Y: float64(y) / 499}).ToRGB()
if y == 300 {
log.Println(rgb.Red, rgb.Green, rgb.Blue)
}
img.Set(x, y, color2.RGBA{
R: uint8(rgb.Red * 255.0),
G: uint8(rgb.Green * 255.0),
B: uint8(rgb.Blue * 255.0),
A: 255,
})
}
}
_ = png.Encode(os.Stdout, img)
}