def _generateCycle(self, preview):
        nbColors = NB_KEYS // self.cycleLength
        nbColors_last = NB_KEYS % self.cycleLength

        self._avaiableKeys = NORMALIZED.copy()

        for self._effectPos in range(self.cycleLength):

            if self._effectPos == 0: self._pick = self._backgroundColor.copy()
            else: self._updateShade()

            if self._effectPos == self.cycleLength: nbColors = nbColors_last

            self._pickRandom(nbColors)
            self._transitionList.append(self._realCopy(self._pick))

        self._updateFirstFrame()

        if not preview:
            for k in range(len(self._transitionList)):
                self.effects.append({
                    "color":
                    Color().rand().toHex(),
                    "curve":
                    self.curveType,
                    "index":
                    self._index + k,
                    "length":
                    self.effectLength,
                    "state":
                    self._unserialize(self._transitionList[k])
                })
        else:
            for k in range(len(self._transitionList)):
                self.effects.append(self._transitionList[k])
 def _setupGenerator(self):
     self.Generator.name = str(self._config["eName"].get())
     self.Generator.file = str(self._config["eOutput"].get())
     self.Generator.effectLength = int(self._config["sLength"].get())
     self.Generator.curveType = int(self._config["sType"].get())
     self.Generator.cycleLength = int(self._config["sCycle"].get())
     self.Generator.cycleCount = int(self._config["sCount"].get())
     self.Generator.effect = int(self._config["sEffect"].get())
     colmax = Color(self._color)
     colmed = Color(self._shadow)
     colmin = Color(self._default)
     self.Generator.colorFull = colmax.coef(1.0, 0.68, 0.63)
     self.Generator.colorHalf = colmed.coef(1.0, 0.68, 0.63)
     self.Generator.colorDefault = colmin.coef(1.0, 0.68, 0.63)
def generate(args, preview=False):
    generator = BaseGenerator()

    for i in range(0, len(args), 2):
        arg = args[i]
        param = args[i + 1]

        if arg == "-name" or arg == "-n":
            generator.name = str(param)
        elif arg == "-output" or arg == "-o":
            generator.file = str(param)

        elif arg == "-length" or arg == "-l":
            generator.effectLength = int(param)
        elif arg == "-type" or arg == "-t":
            generator.curveType = int(param)
        elif arg == "-cycle" or arg == "-c":
            generator.cycleLength = int(param)
        elif arg == "-count" or arg == "-k":
            generator.cycleCount = int(param)

        elif arg == "-effect" or arg == "-e":
            generator.effect = int(param)

        elif arg == "-color" or arg == "-q":
            generator.colorFull = Color(str(param))
        elif arg == "-shadow" or arg == "-s":
            generator.colorHalf = Color(str(param))
        elif arg == "-default" or arg == "-d":
            generator.colorDefault = Color(str(param))

        elif arg == "-help" or arg == "-h" or arg == "/?":
            _printHelp()
            quit()
        else:
            print("unreconized argument: %s" % arg)
            quit()

    generator.generate(preview)
 def pickerMono(self, _):
     for r in self._avaiableKeys:
         pos = self._effectPos % self.cycleLength
         self._pick[r] = Color().fromColor(self._customContainer[pos])
 def pickerWaves(self, _):
     for r in self._avaiableKeys:
         pos = (wavesFromMatPos(r) - self._effectPos) % self.cycleLength
         self._pick[r] = Color().fromColor(self._customContainer[pos])
 def backgroundRasta(self, key):
     colorMult = self.colorDefault.grayScale()
     rainbowColor = getRastaFromMatPos(key)
     self._backgroundColor[key] = Color().fromColor(rainbowColor)
     self._backgroundColor[key].mult(colorMult)
     self._backgroundColor[key].type = COLOR.DEFAULT
 def pickerRasta(self, _):
     r = randint(0, len(self._avaiableKeys) - 1)
     comb = self._avaiableKeys.pop(r)
     rainbowColor = getRastaFromMatPos(comb)
     self._pick[comb] = Color().fromColor(rainbowColor)
     self._pick[comb].type = COLOR.FULL
 def _realCopy(dictionary):
     new = {}
     for k, v in dictionary.items():
         new[k] = Color(v.toHex())
         new[k].type = v.type
     return new
 def backgroundStandard(self, key):
     self._backgroundColor[key] = Color().fromColor(self.colorDefault)
     self._backgroundColor[key].type = COLOR.DEFAULT
 def pickerDefault(self, _):
     r = randint(0, len(self._avaiableKeys) - 1)
     comb = self._avaiableKeys.pop(r)
     self._pick[comb] = Color().fromColor(self.colorFull)
     self._pick[comb].type = COLOR.FULL
from random import randint
from Logitech.logitech import NORMALIZED, NB_KEYS
from Logitech.logitechUtilities import unnormalize

from AsemcoUtilities.Colors import Color, COLOR

from sys import argv

# ---DEFAULTS--- #
NAME = "Python generated effects"
FNAME = "pythonGeneratedEffects"
ELENGTH = 3
CUTYPE = 0
CYLENGTH = 10
CYCOUNT = 4
CFULL = Color("#ff0000")
CHALF = Color("#970000")
CDEFAULT = Color("#303030")
EFFECT = 0


# ---GENERATOR--- #
class BaseGenerator:
    def __init__(self,
                 n=NAME,
                 f=FNAME,
                 el=ELENGTH,
                 ct=CUTYPE,
                 cl=CYLENGTH,
                 cc=CYCOUNT,
                 cf=CFULL,
def _generateMatrice(nbHues, shade, steps):
    _steps = flatSteps(nbHues, shade)
    _nbCol = len(steps)
    _matrice = [Color(steps[s % _nbCol]) for s in _steps]
    return _matrice
def getRainbowMatrice(nbHues):
    hues = linearSteps(360, nbHues)
    _matrice = [Color(hue, 1, 1, True) for hue in hues]
    return _matrice