Example #1
0
def testColorGradient1dRadial():
    generators.generate("tuttle.colorgradient",
                        format="1K-Super35-full-ap",
                        type="1dRadial",
                        color0=[0, 0, 0, 0.5],
                        point1=[0.25, 0.5],
                        color1=[1, 1, 1, 1])
Example #2
0
def testColorGradient1dLinearVertical():
    generators.generate("tuttle.colorgradient",
                        format="1K-Super35-full-ap",
                        type="1dLinear",
                        color0=[0, 0, 0, 0.5],
                        point1=[0, 1],
                        color1=[1, 1, 1, 1])
Example #3
0
def main():
    with Display() as d:
        generators.generate(
            d,
            marquee("ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",
                    [Colour.red(), Colour.green(),
                     Colour.blue()]))
Example #4
0
def testColorGradient2d():
    generators.generate("tuttle.colorgradient",
                        format="1K-Super35-full-ap",
                        type="2d",
                        nbPoints=4,
                        point1=[0.25, 0.65],
                        point2=[0.75, 0.25],
                        point3=[0.75, 0.75],
                        color1=[0.41, 0.47, 0.60, 1.0],
                        color2=[0.64, 0.24, 0.14, 1.0],
                        color3=[1, 1, 1, 1])
Example #5
0
def testColorRampHighDynamic():
    generators.generate("tuttle.ramp",
                        format="1K-Super35-full-ap",
                        color=True,
                        start=[-3.0, -3.0, -3.0, 1.0],
                        end=[3.0, 3.0, 3.0, 1.0])
    generators.generateEXR("tuttle.ramp",
                           format="1K-Super35-full-ap",
                           color=True,
                           start=[-3.0, -3.0, -3.0, 1.0],
                           end=[3.0, 3.0, 3.0, 1.0])
Example #6
0
def write_bindings_to_disk(module_name, bindings, api_classes, env,
                           output_dir):
    """
    Write the bindings to disk, return Nothing
    Input:
    - module_name - string
    - list of bindings to generate
    - api_classes
    - environment to get templates from
    - output_dir where to write to
    """
    for binding in bindings:
        generators.generate(module_name, binding, api_classes, env, output_dir)
Example #7
0
	def generate(self, num_nodes, num_edges, weight_range=(1, 1)):
		"""
		Add nodes and random edges to the graph.
		
		@type  num_nodes: number
		@param num_nodes: Number of nodes.
		
		@type  num_edges: number
		@param num_edges: Number of edges.

		@type  weight_range: tuple
		@param weight_range: tuple of two integers as lower and upper limits on randomly generated
		weights (uniform distribution).
		"""
		generators.generate(self, num_nodes, num_edges, weight_range)
Example #8
0
def explore_generator(generator, **kwargs):
    arr = generate(generator, **kwargs)
    intervals = get_intervals(arr)
    # build_chart(intervals)
    expected_value_ = expected_value(arr)

    print('Expected value: ', expected_value_)
    print('Dispersion: ', dispersion(arr, expected_value_))
    print('chi2: ',
          get_chi_squared(intervals, expected_amount[generator], **kwargs))
Example #9
0
def testRainbowColorWheel():
	generators.generate( "tuttle.colorwheel", format="1K-Super35-full-ap", type="rainbow" )
Example #10
0
def testRamp():
	generators.generate( "tuttle.ramp", format="1K-Super35-full-ap" )
Example #11
0
def testColorRamp():
	generators.generate( "tuttle.ramp", format="1K-Super35-full-ap", color=True )
Example #12
0
def testColorGradient1dRadial():
	generators.generate( "tuttle.colorgradient", format="1K-Super35-full-ap", type="1dRadial", color0=[0,0,0,0.5], point1=[0.25,0.5], color1=[1,1,1,1] )
Example #13
0
 def GButton_483_command(self):
     self.GLabel_544["text"] = generate()
Example #14
0
def testCheckerboardMultiboxes():
    generators.generate("tuttle.checkerboard",
                        format="1K-Super35-full-ap",
                        boxes=[50, 20])
Example #15
0
def testColorWheelBlack():
    generators.generate("tuttle.colorwheel",
                        format="1K-Super35-full-ap",
                        type="black")
Example #16
0
def testCheckerboard2Colors():
	generators.generate( "tuttle.checkerboard", format="1K-Super35-full-ap", boxes=[10, 5], color1=[0.41, 0.47, 0.60, 1.0], color2=[0.64, 0.24, 0.14, 1.0] )
Example #17
0
def testRampVertical():
    generators.generate("tuttle.ramp",
                        format="1K-Super35-full-ap",
                        direction="vertical")
Example #18
0
    for slice_index in range(SIZE):
      pos = ([(low + i, low) for i in range(length)]
           + [(high, low + i) for i in range(length)]
           + [(high - i, high) for i in range(length)]
           + [(low, high - i) for i in range(length)])
      if length == 0:
        pos = [(low, low)]
      real_slice_index = slice_index if (layer % 2) == 0 else SIZE - 1 - slice_index
      for i in range(len(pos)):
        cube.set(convert_face_coordinates(Direction.FRONT, pos[i], real_slice_index), colours[i])
      colours = colours[len(pos):]
  return cube

def line_to_cube(line_generator, cube_transform = control_order):
  for val in line_generator:
    if type(val) is bool:
      yield val
    else:
      yield cube_transform(val)


if __name__ == "__main__":
  with Display() as d:
    generators.generate(d, generators.transform(line_to_cube(generators.sequence([
        line.scroll_in(line.rainbow()),
        generators.repeat(line.cycle(line.rainbow()), 2),
        line.scroll_out(line.rainbow()),
      ]), spiral), functools.partial(rotate.rotate, Direction.LEFT, 1)))


Example #19
0
def testCheckerboard():
	generators.generate( "tuttle.checkerboard", format="1K-Super35-full-ap" )
Example #20
0
hues = [Colour.RED_HUE, Colour.GREEN_HUE, Colour.BLUE_HUE]


def faces():
  hue = random.choice(hues)
  direction = random.choice([d for d in Direction])
  while True:
    new_direction = random.choice([d for d in Direction if d != direction])
    new_hue = random.choice([h for h in hues if h != hue])
    if new_direction.value == -direction.value:
      gen = straight(new_direction, hue, new_hue)
    else:
      gen = generate_corner(direction, new_direction, hue, new_hue)
    for val in gen:
      if type(val) is bool:
        break
      yield val
    direction = new_direction
    hue = new_hue
    c = Cube()
    c.fill_layer(direction, 0, hue_to_colour(hue))
    yield c
    yield c
    yield True

if __name__ == "__main__":
  with Display() as d:
    generators.generate(d, faces(), delay=0.05)

Example #21
0
    def compute_updates(self, lid, private, msg):
        """Determine what needs to be sent to the archiver.

        :param lid: The list id
        :param private: Whether privately archived email or not (bool)
        :param msg: The message object

        :return None if the message could not be parsed, otherwise a four-tuple consisting of:
                the digested email as a dict, its attachments, its metadata fields and any
                in-reply-to data found.
        """

        ojson = None
        if not lid:
            lid = normalize_lid(msg.get('list-id'))
        if self.cropout:
            crops = self.cropout.split(" ")
            # Regex replace?
            if len(crops) == 2:
                lid = re.sub(crops[0], crops[1], lid)
            # Standard crop out?
            else:
                lid = lid.replace(self.cropout, "")

        defaultEmptyString = lambda value: value and str(value) or ""
        msg_metadata = dict([(k, defaultEmptyString(msg.get(k)))
                             for k in self.keys])
        mid = hashlib.sha224(
            str("%s-%s" % (lid, msg_metadata['archived-at'])).encode(
                'utf-8')).hexdigest() + "@" + (lid if lid else "none")
        for key in ['to', 'from', 'subject', 'message-id']:
            try:
                hval = ""
                if msg_metadata.get(key):
                    for t in email.header.decode_header(msg_metadata[key]):
                        if t[1] == None or t[1].find("8bit") != -1:
                            hval += t[0].decode('utf-8') if type(
                                t[0]) is bytes else t[0]
                        else:
                            hval += t[0].decode(t[1], errors='ignore')
                    msg_metadata[key] = hval
            except Exception as err:
                print("Could not decode headers, ignoring..: %s" % err)
        mdate = None
        try:
            mdate = email.utils.parsedate_tz(msg_metadata.get('date'))
        except:
            pass
        if not mdate and msg_metadata.get('archived-at'):
            mdate = email.utils.parsedate_tz(msg_metadata.get('archived-at'))
        elif not mdate:
            print("Date (%s) seems totally wrong, setting to _now_ instead." %
                  mdate)
            mdate = time.gmtime()  # Get a standard 9-tuple
            mdate = mdate + (0, )  # Fake a TZ (10th element)

        # mdate calculations are all done, prepare the index entry
        epoch = email.utils.mktime_tz(mdate)
        mdatestring = time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(epoch))
        body = self.msgbody(msg)
        saved_body = None  # for format=flowed
        try:
            if 'content-type' in msg_metadata and msg_metadata[
                    'content-type'].find("flowed") != -1:
                saved_body = body  # so we can redo it properly later
                # N.B. the convertToWrapped call usually fails, because body is a generally a string here
                # However sometimes body is bytes at this point in which case it works
                body = formatflowed.convertToWrapped(body,
                                                     character_set="utf-8")
                # DO NOT FIX IT -- otherwise generated MIDs will change
                # The code now applies the formatting properly later
            if isinstance(body, str):
                body = body.encode('utf-8')
        except Exception:
            try:
                body = body.decode(chardet.detect(body)['encoding'])
            except Exception:
                try:
                    body = body.decode('latin-1')
                except:
                    try:
                        if isinstance(body, str):
                            body = body.encode('utf-8')
                    except:
                        body = None

        attachments, contents = self.msgfiles(msg)
        irt = ""
        if body is not None or attachments:
            pmid = mid
            try:
                mid = generators.generate(self.generator, msg, body, lid,
                                          attachments)
            except Exception as err:
                if logger:
                    # N.B. use .get just in case there is no message-id
                    logger.info(
                        "Could not generate MID using %s: %s. MSGID: %s",
                        self.generator, err,
                        msg_metadata.get('message-id', '?').strip())
                mid = pmid

            if 'in-reply-to' in msg_metadata:
                try:
                    try:
                        irt = "".join(msg_metadata['in-reply-to'])
                    except:
                        irt = msg_metadata.get('in-reply-to').__str__()
                except:
                    irt = ""

            if not self.skipff and 'content-type' in msg_metadata and msg_metadata[
                    'content-type'].find("flowed") != -1:
                if isinstance(saved_body, str):
                    saved_body = saved_body.encode('utf-8', 'replace')
                try:
                    # Allow wrapping to be done on the client display by unwrapping
                    # to a single long line.
                    # The value 2000 should be more than enough for most email paragraphs.
                    # body = formatflowed.convertToWrapped(to_crlf(saved_body), width=2000, wrap_fixed=False, character_set="utf-8")
                    # formatflowed requires CRLF line endings, but generates LF endings...
                    # TEMP: disable conversion until can work out how to fix tests
                    body = formatflowed.convertToWrapped(saved_body,
                                                         width=2000,
                                                         wrap_fixed=False,
                                                         character_set="utf-8")
                except:
                    pass  # Don't try to recover

            ojson = {
                'from_raw':
                msg_metadata['from'],
                'from':
                msg_metadata['from'],
                'to':
                msg_metadata['to'],
                'subject':
                msg_metadata['subject'],
                'message-id':
                msg_metadata['message-id'],
                'mid':
                mid,
                'cc':
                msg_metadata.get('cc'),
                'epoch':
                epoch,
                'list':
                lid,
                'list_raw':
                lid,
                'date':
                mdatestring,
                'private':
                private,
                'references':
                msg_metadata['references'],
                'in-reply-to':
                irt,
                'body':
                body.decode('utf-8', 'replace')
                if type(body) is bytes else body,
                'attachments':
                attachments
            }

        return ojson, contents, msg_metadata, irt
Example #22
0
def testRainbowColorWheel():
    generators.generate("tuttle.colorwheel",
                        format="1K-Super35-full-ap",
                        type="rainbow")
Example #23
0
def testConstantColor1():
    generators.generate("tuttle.constant",
                        format="1K-Super35-full-ap",
                        color=[0.64, 0.24, 0.14, 0.75])
Example #24
0
def testColorCube4():
	generators.generate( "tuttle.colorcube", format="1K-Super35-full-ap", cubes="4" )
Example #25
0
def testColorWheelBlack():
	generators.generate( "tuttle.colorwheel", format="1K-Super35-full-ap", type="black" )
Example #26
0
def testColorbars100percent():
	generators.generate( "tuttle.colorbars", format="1K-Super35-full-ap", levels="100%" )
Example #27
0
def testCheckerboard2Colors():
    generators.generate("tuttle.checkerboard",
                        format="1K-Super35-full-ap",
                        boxes=[10, 5],
                        color1=[0.41, 0.47, 0.60, 1.0],
                        color2=[0.64, 0.24, 0.14, 1.0])
Example #28
0
def testColorWheel():
    generators.generate("tuttle.colorwheel", format="1K-Super35-full-ap")
Example #29
0
def testCheckerboardMultiboxes():
	generators.generate( "tuttle.checkerboard", format="1K-Super35-full-ap", boxes=[50, 20] )
Example #30
0
def main():
  with Display() as d:
    generators.generate(d, generators.slow(extend()))
Example #31
0
def testRamp():
    generators.generate("tuttle.ramp", format="1K-Super35-full-ap")
Example #32
0
from display import *
import generators


def single_frame(colours):
    while True:
        yield colours
        yield True


if __name__ == "__main__":
    with Display() as d:
        generators.generate(d,
                            generators.sequence([
                                single_frame([Colour.red()]),
                                single_frame([Colour.green()]),
                                single_frame([Colour.blue()])
                            ]),
                            delay=0.5)
Example #33
0
def testColorRamp():
    generators.generate("tuttle.ramp", format="1K-Super35-full-ap", color=True)
Example #34
0
    return generators.sequence([
        scroll_in(cube, direction),
        single_frame(cube),
        scroll_out(cube, direction)
    ])


def combine_cubes(cube_a, cube_b):
    c = cube_a.copy()
    for x in range(cube_a.size):
        for y in range(cube_a.size):
            for z in range(cube_a.size):
                p = Pos(x, y, z)
                if c.get(p) == Colour.BLACK:
                    c.set(p, cube_b.get(p))
    return c


if __name__ == "__main__":
    with Display() as d:
        generators.generate(d,
                            generators.sequence([
                                scroll_past(Cube(SIZE, Colour.red()),
                                            Direction.UP),
                                scroll_past(Cube(SIZE, Colour.green()),
                                            Direction.RIGHT),
                                scroll_past(Cube(SIZE, Colour.blue()),
                                            Direction.FRONT),
                            ]),
                            delay=0.5)
Example #35
0
def testColorbars():
	generators.generate( "tuttle.colorbars", format="1K-Super35-full-ap" )
Example #36
0
                  [Colour.red(), Colour.green(),
                   Colour.blue()]),
        generators.fast(
            line_maps.line_to_cube(
                generators.sequence([
                    line.scroll_in(line.rainbow()),
                    line.scroll_out(line.rainbow()),
                ]))),
        text.text("subtle", [
            Colour((Colour.brightness // 8, 0, 0)),
            Colour((0, Colour.brightness // 8, 0)),
            Colour((0, 0, Colour.brightness // 8))
        ]),
        generators.repeat(corners.corners(), 10),
        generators.frame_limit(spiral.spiral(), 100),
        generators.repeat(extend.extend(), 3),
        generators.frame_limit(generators.slow(layers.layers(), frames=4),
                               100),
        generators.frame_limit(wave.wave(), 100),
        generators.frame_limit(snakes.snakes(), 300),
        generators.frame_limit(matrix.matrix(), 300),
        generators.frame_limit(rope.rope(), 300),
        generators.repeat(fireworks.fireworks(), 10),
        generators.repeat(pins.pins(), 5),
    ])


if __name__ == "__main__":
    with Display() as d:
        generators.generate(d, cube_visuals())
Example #37
0
def testColorGradient1dLinearVertical():
	generators.generate( "tuttle.colorgradient", format="1K-Super35-full-ap", type="1dLinear", color0=[0,0,0,0.5], point1=[0,1], color1=[1,1,1,1] )
Example #38
0
def main():
    with Display() as d:
        generators.generate(d, corners(), delay=0.1)
Example #39
0
def testColorGradient2d():
	generators.generate( "tuttle.colorgradient", format="1K-Super35-full-ap", type="2d", nbPoints=4, point1=[0.25, 0.65], point2=[0.75, 0.25], point3=[0.75,0.75], color1=[0.41, 0.47, 0.60, 1.0], color2=[0.64, 0.24, 0.14, 1.0], color3=[1,1,1,1] )
Example #40
0
def scroll_pixel(colour):
  cs = [colour] + [Colour.BLACK for i in range(LEDS - 1)]
  return generators.sequence([single_frame(cs), scroll_out(cs)])

if __name__ == "__main__":
  with Display() as d:
    # For testing the LEDs:
    #generators.generate(d, generators.sequence([
    #  scroll_pixel(Colour.red()),
    #  scroll_pixel(Colour.green()),
    #  scroll_pixel(Colour.blue()),
    #]))
    generators.generate(d, generators.shuffle([
      mirror(reverse(binary_count(LEDS // 2))),
      knight_rider(10),
      scroll_past([Colour.red() for i in range(LEDS)]),
      scroll_past([Colour.green() for i in range(LEDS)]),
      scroll_past([Colour.blue() for i in range(LEDS)]),
      scroll_past([Colour.cyan() for i in range(LEDS)], dir=-1),
      scroll_past([Colour.magenta() for i in range(LEDS)], dir=-1),
      scroll_past([Colour.yellow() for i in range(LEDS)], dir=-1),
      generators.sequence([
        scroll_in(rainbow()),
        generators.repeat(cycle(rainbow()), 5),
        generators.repeat(cycle(rainbow(), dir=-1), 5),
        scroll_out(rainbow(), dir=-1),
      ]),
    ]))

Example #41
0
        for y in range(SIZE):
            for z in range(SIZE):
                hue = ((atan2(((SIZE - 1) / 2) - z,
                              ((SIZE - 1) / 2) - x) + hue_offset) / 2 / pi) % 1
                sat = 1 - (min([x, z, SIZE - 1 - x, SIZE - 1 - z]) /
                           ((SIZE - 1) // 2))
                val = (20 / 255) * (y + 0.25) / SIZE
                cube.set(
                    Pos(x, y, z),
                    Colour.from_floats(colorsys.hsv_to_rgb(hue, sat, val)))
    return cube


def rotate_colour_cube(speed):
    while True:
        for i in range(0, 360, 10):
            yield make_colour_cube(hue_offset=i * pi / 180)
        yield True


def scroll_diagonal_rainbow():
    while True:
        for i in range(6):
            yield diagonal_rainbow(offset=i)
        yield True


if __name__ == "__main__":
    with Display() as d:
        generators.generate(d, scroll_diagonal_rainbow(), delay=0.25)
Example #42
0
def testConstant():
	generators.generate( "tuttle.constant", format="1K-Super35-full-ap" )
Example #43
0
def testRampVertical():
	generators.generate( "tuttle.ramp", format="1K-Super35-full-ap", direction="vertical" )
Example #44
0
def testConstantColor1():
	generators.generate( "tuttle.constant", format="1K-Super35-full-ap", color=[0.64, 0.24, 0.14, 0.75] )
Example #45
0
def testColorRampHighDynamic():
	generators.generate( "tuttle.ramp", format="1K-Super35-full-ap", color=True, start=[-3.0, -3.0, -3.0, 1.0], end=[3.0, 3.0, 3.0, 1.0] )
	generators.generateEXR( "tuttle.ramp", format="1K-Super35-full-ap", color=True, start=[-3.0, -3.0, -3.0, 1.0], end=[3.0, 3.0, 3.0, 1.0] )
Example #46
0
def testConstantcolor2():
	generators.generate( "tuttle.constant", format="1K-Super35-full-ap", color=[0.41, 0.47, 0.60, 1.0] )
Example #47
0
def testConstant():
    generators.generate("tuttle.constant", format="1K-Super35-full-ap")
Example #48
0
def testCheckerboard():
    generators.generate("tuttle.checkerboard", format="1K-Super35-full-ap")
Example #49
0
def testConstantcolor2():
    generators.generate("tuttle.constant",
                        format="1K-Super35-full-ap",
                        color=[0.41, 0.47, 0.60, 1.0])
Example #50
0
def testColorWheel():
	generators.generate( "tuttle.colorwheel", format="1K-Super35-full-ap" )