This commit is contained in:
brindosch 2017-05-01 13:39:21 +02:00
parent 06084e5588
commit 827294b88c
6 changed files with 49 additions and 28 deletions

View File

@ -16,6 +16,11 @@
},
"minItems": 3,
"maxItems": 3,
"options": {
"dependencies": {
"random-color": false
}
},
"propertyOrder" : 1
},
"rotation-time": {
@ -34,34 +39,30 @@
"propertyOrder" : 3
},
"brightness": {
"type": "number",
"type": "integer",
"title":"edt_eff_brightness",
"default": 100,
"minimum" : 1,
"minimum" : 0,
"maximum" : 100,
"step" : 10,
"append" : "edt_append_percent",
"propertyOrder" : 4
},
"saturation": {
"type": "number",
"type": "integer",
"title":"edt_eff_saturation",
"default": 100,
"minimum" : 1,
"minimum" : 0,
"maximum" : 100,
"step" : 10,
"append" : "edt_append_percent",
"propertyOrder" : 5
},
"reverse": {
"type": "boolean",
"title":"edt_eff_reversedirection",
"default": false,
"propertyOrder" : 6
},
"random-color": {
"type": "boolean",
"title":"edt_eff_colorrandom",
"default": false,
"propertyOrder" : 7
"propertyOrder" : 6
}
},
"additionalProperties": false

View File

@ -1,14 +0,0 @@
{
"name" : "Sparks Color",
"script" : "sparks.py",
"args" :
{
"rotation-time" : 3.0,
"sleep-time" : 0.05,
"brightness" : 1.0,
"saturation" : 1.0,
"reverse" : false,
"color" : [255,255,255],
"random-color" : true
}
}

View File

@ -7,7 +7,6 @@
"sleep-time" : 0.05,
"brightness" : 100,
"saturation" : 100,
"reverse" : false,
"color" : [255,255,255],
"random-color" : false
}

View File

@ -5,7 +5,6 @@ rotationTime = float(hyperion.args.get('rotation-time', 3.0))
sleepTime = float(hyperion.args.get('sleep-time', 0.05))
brightness = float(hyperion.args.get('brightness', 100))/100.0
saturation = float(hyperion.args.get('saturation', 100))/100.0
reverse = bool(hyperion.args.get('reverse', False))
color = list(hyperion.args.get('color', (255,255,255)))
randomColor = bool(hyperion.args.get('random-color', False))
@ -24,7 +23,7 @@ while not hyperion.abort():
if random.random() < 0.005:
if randomColor:
rgb = colorsys.hsv_to_rgb(random.random(), 1, 1)
rgb = colorsys.hsv_to_rgb(random.random(), saturation, brightness)
for n in range(3):
color[n] = int(rgb[n]*255)

View File

@ -30,6 +30,7 @@ PyMethodDef Effect::effectMethods[] = {
{"imageRadialGradient" , Effect::wrapImageRadialGradient , METH_VARARGS, ""},
{"imageSolidFill" , Effect::wrapImageSolidFill , METH_VARARGS, ""},
{"imageDrawLine" , Effect::wrapImageDrawLine , METH_VARARGS, ""},
{"imageDrawPoint" , Effect::wrapImageDrawPoint , METH_VARARGS, ""},
{"imageDrawRect" , Effect::wrapImageDrawRect , METH_VARARGS, ""},
{"imageSetPixel" , Effect::wrapImageSetPixel , METH_VARARGS, "set pixel color of image"},
{"imageGetPixel" , Effect::wrapImageGetPixel , METH_VARARGS, "get pixel color of image"},
@ -682,6 +683,40 @@ PyObject* Effect::wrapImageDrawLine(PyObject *self, PyObject *args)
return nullptr;
}
PyObject* Effect::wrapImageDrawPoint(PyObject *self, PyObject *args)
{
Effect * effect = getEffect();
int argCount = PyTuple_Size(args);
int r, g, b, x, y;
int a = 255;
int thick = 1;
bool argsOK = false;
if ( argCount == 7 && PyArg_ParseTuple(args, "iiiiiii", &x, &y, &thick, &r, &g, &b, &a) )
{
argsOK = true;
}
if ( argCount == 6 && PyArg_ParseTuple(args, "iiiiii", &x, &y, &thick, &r, &g, &b) )
{
argsOK = true;
}
if (argsOK)
{
QPainter * painter = effect->_painter;
QPen oldPen = painter->pen();
QPen newPen(QColor(r,g,b,a));
newPen.setWidth(thick);
painter->setPen(newPen);
painter->drawPoint(x, y);
painter->setPen(oldPen);
return Py_BuildValue("");
}
return nullptr;
}
PyObject* Effect::wrapImageDrawRect(PyObject *self, PyObject *args)
{

View File

@ -62,6 +62,7 @@ private:
static PyObject* wrapImageRadialGradient (PyObject *self, PyObject *args);
static PyObject* wrapImageSolidFill (PyObject *self, PyObject *args);
static PyObject* wrapImageDrawLine (PyObject *self, PyObject *args);
static PyObject* wrapImageDrawPoint (PyObject *self, PyObject *args);
static PyObject* wrapImageDrawRect (PyObject *self, PyObject *args);
static PyObject* wrapImageSetPixel (PyObject *self, PyObject *args);
static PyObject* wrapImageGetPixel (PyObject *self, PyObject *args);