Example #1
0
    def _evaluate(self):
        color_names = self.get_raw('colors')
        colors, error_colors = cechomesh.color_list_with_errors(color_names)
        if error_colors:
            raise Exception(
                '\nCan\'t understand %s: %s.' %
                (plural(len(error_colors), 'color'), ', '.join(error_colors)))

        steps = self.get('steps')
        total_steps = self.get('total_steps')
        max_steps = light_count(Settings.get)

        if not total_steps:
            if steps:
                total_steps = steps
                steps = None
            else:
                total_steps = None
                max_steps = len(colors)

        return cechomesh.color_spread(colors,
                                      self.get('model'),
                                      max_steps=max_steps,
                                      steps=steps,
                                      total_steps=total_steps,
                                      transform=self.get('transform'))
Example #2
0
    def _evaluate(self):
        colors = self.get_raw('colors')
        has_lists, has_scalars = False, False
        for c in colors:
            is_list = isinstance(c, list)
            has_lists = has_lists or is_list
            has_scalars = has_scalars or not is_list

        if has_scalars:
            if has_lists:
                raise Exception('Can\'t mix lists and scalars in pattern.List')
            colors = [colors]
        max_column = max(len(c) for c in colors)
        columns = self.get('columns') or max_column
        if not max_column:
            # Empty list.
            return cechomesh.ColorList(columns=columns)

        ce = (cechomesh.color_list_with_errors(c) for c in colors)
        color_lists, errors = zip(*ce)
        errors = list(itertools.chain(*errors))
        if errors:
            raise Exception('\nCan\'t understand %s: %s.' %
                            (plural(len(errors), 'color'), ', '.join(errors)))
        result = cechomesh.ColorList(columns=columns)
        for i, cl in enumerate(color_lists):
            cl.size = columns
            result.extend(cl)
        return result
Example #3
0
    def _evaluate(self):
        color_names = self.get_raw('colors')
        colors, error_colors = cechomesh.color_list_with_errors(color_names)
        if error_colors:
            raise Exception('\nCan\'t understand %s: %s.' % (
                plural(len(error_colors), 'color'), ', '.join(error_colors)))

        steps = self.get('steps')
        total_steps = self.get('total_steps')
        max_steps = light_count(Settings.get)

        if not total_steps:
            if steps:
                total_steps = steps
                steps = None
            else:
                total_steps = None
                max_steps = len(colors)

        return cechomesh.color_spread(
          colors,
          self.get('model'),
          max_steps=max_steps,
          steps=steps,
          total_steps=total_steps,
          transform=self.get('transform'))
Example #4
0
    def _evaluate(self):
        colors = self.get_raw("colors")
        has_lists, has_scalars = False, False
        for c in colors:
            is_list = isinstance(c, list)
            has_lists = has_lists or is_list
            has_scalars = has_scalars or not is_list

        if has_scalars:
            if has_lists:
                raise Exception("Can't mix lists and scalars in pattern.List")
            colors = [colors]
        max_column = max(len(c) for c in colors)
        columns = self.get("columns") or max_column
        if not max_column:
            # Empty list.
            return cechomesh.ColorList(columns=columns)

        ce = (cechomesh.color_list_with_errors(c) for c in colors)
        color_lists, errors = zip(*ce)
        errors = list(itertools.chain(*errors))
        if errors:
            raise Exception("\nCan't understand %s: %s." % (plural(len(errors), "color"), ", ".join(errors)))
        result = cechomesh.ColorList(columns=columns)
        for i, cl in enumerate(color_lists):
            cl.size = columns
            result.extend(cl)
        return result