mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
new effect plasma (#792)
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
8
effects/plasma.json
Normal file
8
effects/plasma.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name" : "Plasma",
|
||||
"script" : "plasma.py",
|
||||
"args" :
|
||||
{
|
||||
"sleepTime" : 0.20
|
||||
}
|
||||
}
|
35
effects/plasma.py
Normal file
35
effects/plasma.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import hyperion, time, colorsys, math
|
||||
|
||||
hyperion.imageMinSize(64, 64)
|
||||
width = hyperion.imageWidth()
|
||||
height = hyperion.imageHeight()
|
||||
sleepTime = float(hyperion.args.get('sleepTime', 0.2))
|
||||
|
||||
def mapto(x, in_min, in_max, out_min, out_max):
|
||||
return float((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)
|
||||
|
||||
pal = []
|
||||
for h in range(256):
|
||||
r, g, b = colorsys.hsv_to_rgb(mapto(h, 0.0, 255.0, 0.0, 1.0), 1.0, 1.0)
|
||||
pal.append( bytearray( (int(r*255), int(g*255), int(b*255)) ) )
|
||||
|
||||
plasma = [[]]
|
||||
for x in range(width):
|
||||
plasma.append([])
|
||||
for y in range(height):
|
||||
color = int(128.0 + (128.0 * math.sin(x / 16.0)) + \
|
||||
128.0 + (128.0 * math.sin(y / 8.0)) + \
|
||||
128.0 + (128.0 * math.sin((x+y)) / 16.0) + \
|
||||
128.0 + (128.0 * math.sin(math.sqrt(x**2.0 + y**2.0) / 8.0))) / 4
|
||||
plasma[x].append(color)
|
||||
|
||||
while not hyperion.abort():
|
||||
ledData = bytearray()
|
||||
mod = time.clock() * 100
|
||||
for x in range(height):
|
||||
for y in range(width):
|
||||
ledData += pal[int((plasma[y][x] + mod) % 256)]
|
||||
|
||||
hyperion.setImage(width,height,ledData)
|
||||
time.sleep(sleepTime)
|
||||
|
18
effects/schema/plasma.schema.json
Normal file
18
effects/schema/plasma.schema.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"type":"object",
|
||||
"script" : "plasma.py",
|
||||
"title": "edt_eff_plasma_header",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"sleepTime": {
|
||||
"type": "number",
|
||||
"title":"edt_eff_sleeptime",
|
||||
"default": 0.20,
|
||||
"minimum" : 0.01,
|
||||
"step": 0.01,
|
||||
"append" : "edt_append_s",
|
||||
"propertyOrder" : 1
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
Reference in New Issue
Block a user