Exemplo n.º 1
0
    def __init__(self, colors):
        frames.Frame.__init__(self, colors)

        textfile = open("sets.txt", "r")  # later use sqlite db
        setArray = textfile.read().split('\n')
        textfile.close()
        sets = []

        titleHeight = 60

        table = shapes.Table((0, titleHeight+1), (frames.WIDTH - 1, frames.HEIGHT - 1), \
                              "black", 255, 0, 3, 10)

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, titleHeight), "red", 0,
                                0)
        title = shapes.Text('Liegestuetz', titleRect.getCenter(), "red", \
                            titleHeight // 3 * 2, 255)

        for i in range(0, len(setArray) - 1):
            sets.append(shapes.Text(setArray[i], (0,0), "black", \
                                    (frames.HEIGHT - titleHeight) // 15, 0))
            table.addShape(sets[i])

        table.addBackground("black", 255, 0)

        table.invertCells(range(0, 6))
        table.swapCells([5])

        # add shapes to training frame
        self.addShape(titleRect)
        self.addShape(title)
        self.addShape(table)
Exemplo n.º 2
0
    def __init__(self, colors):
        frames.Frame.__init__(self, colors)

        frameBackground = shapes.Rect((0, 0), (399, 299), "black", 0, 0)
        whiteEllipse = shapes.Ellipse((-200, -300), (600, 200), 30, 150,
                                      "black", 255, 255)
        name = shapes.Text("E-VI", (200, 75), "black", 35, 0)
        mainText = shapes.Text("E-Ink Visualizer of Information", (200, 120),
                               "black", 18, 0)
        usage = shapes.Text("Usage:      swipe left/right", (200, 230),
                            "black", 16, 255)
        usage2 = shapes.Text("            swipe   up/down", (200, 256),
                             "black", 16, 255)
        circle = shapes.Ellipse((300, -100), (500, 100), 0, 180, "red", 0, 0)
        version = shapes.Text(frames.VERSION, (360, 35), "red", 20, 255)

        self.addShapes([frameBackground, whiteEllipse, name, mainText, \
                                  usage, usage2, circle, version])
Exemplo n.º 3
0
    def __init__(self, colors):
        frames.Frame.__init__(self, colors)
        self.__data = getIC()

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, frames.HEIGHT // 4),
                                "black", 0, 0)
        title = shapes.Text('Inner Climate', (frames.WIDTH // 2, 23), "black",
                            25, 255)
        mainTable = shapes.Table((0, frames.HEIGHT // 4), (frames.WIDTH, frames.HEIGHT), \
                             "black", 255, 0, 2, 2)

        #self.addShape(shapes.Text("TBD", (200, 150), "black", 0, 0))
        mainTable.addShapes([shapes.Picture((0, 0), (0, 0), \
                                 "black", 0, 0, "Icons/temp_black", "Icons/temp_red"), \
                        shapes.Picture((0, 0), (0, 0), "black", 0, 0, \
                                 "Icons/humidity_black", "Icons/humidity_red"), \
                        shapes.Text('temp', (0,0), "black", 16, 0), \
                        shapes.Text('press', (0,0), "black", 16, 0)])

        mainTable.addBackground("black", 255, 255)

        self.addShapes([titleRect, title, mainTable])

        self.updateInnerClimate()
Exemplo n.º 4
0
def ruler(start, end, ticks=4, sub_ticks=4, absolute=False, snap=False, **kwds):
    """
    Draw a ruler in 3-D, with major and minor ticks.

    INPUT:

    - ``start`` - the beginning of the ruler, as a list,
      tuple, or vector.

    - ``end`` - the end of the ruler, as a list, tuple,
      or vector.

    - ``ticks`` - (default: 4) the number of major ticks
      shown on the ruler.

    - ``sub_ticks`` - (default: 4) the number of shown
      subdivisions between each major tick.

    - ``absolute`` - (default: ``False``) if ``True``, makes a huge ruler
      in the direction of an axis.

    - ``snap`` - (default: ``False``) if ``True``, snaps to an implied
      grid.

    Type ``line3d.options`` for a dictionary of the default
    options for lines, which are also available.

    EXAMPLES:

    A ruler::

        sage: from sage.plot.plot3d.shapes2 import ruler
        sage: R = ruler([1,2,3],vector([2,3,4])); R

    A ruler with some options::

        sage: R = ruler([1,2,3],vector([2,3,4]),ticks=6, sub_ticks=2, color='red'); R

    The keyword ``snap`` makes the ticks not necessarily coincide
    with the ruler::

        sage: ruler([1,2,3],vector([1,2,4]),snap=True)

    The keyword ``absolute`` makes a huge ruler in one of the axis
    directions::

        sage: ruler([1,2,3],vector([1,2,4]),absolute=True)

    TESTS::

        sage: ruler([1,2,3],vector([1,3,4]),absolute=True)
        Traceback (most recent call last):
        ...
        ValueError: Absolute rulers only valid for axis-aligned paths
    """
    start = vector(RDF, start)
    end   = vector(RDF, end)
    dir = end - start
    dist = math.sqrt(dir.dot_product(dir))
    dir /= dist

    one_tick = dist/ticks * 1.414
    unit = 10 ** math.floor(math.log(dist/ticks, 10))
    if unit * 5 < one_tick:
        unit *= 5
    elif unit * 2 < one_tick:
        unit *= 2

    if dir[0]:
        tick = dir.cross_product(vector(RDF, (0,0,-dist/30)))
    elif dir[1]:
        tick = dir.cross_product(vector(RDF, (0,0,dist/30)))
    else:
        tick = vector(RDF, (dist/30,0,0))

    if snap:
        for i in range(3):
            start[i] = unit * math.floor(start[i]/unit + 1e-5)
            end[i] = unit * math.ceil(end[i]/unit - 1e-5)

    if absolute:
        if dir[0]*dir[1] or dir[1]*dir[2] or dir[0]*dir[2]:
            raise ValueError, "Absolute rulers only valid for axis-aligned paths"
        m = max(dir[0], dir[1], dir[2])
        if dir[0] == m:
            off = start[0]
        elif dir[1] == m:
            off = start[1]
        else:
            off = start[2]
        first_tick = unit * math.ceil(off/unit - 1e-5) - off
    else:
        off = 0
        first_tick = 0

    ruler = shapes.LineSegment(start, end, **kwds)
    for k in range(1, int(sub_ticks * first_tick/unit)):
        P = start + dir*(k*unit/sub_ticks)
        ruler += shapes.LineSegment(P, P + tick/2, **kwds)
    for d in srange(first_tick, dist + unit/(sub_ticks+1), unit):
        P = start + dir*d
        ruler += shapes.LineSegment(P, P + tick, **kwds)
        ruler += shapes.Text(str(d+off), **kwds).translate(P - tick)
        if dist - d < unit:
            sub_ticks = int(sub_ticks * (dist - d)/unit)
        for k in range(1, sub_ticks):
            P += dir * (unit/sub_ticks)
            ruler += shapes.LineSegment(P, P + tick/2, **kwds)
    return ruler
Exemplo n.º 5
0
 def _action(self, message, standardized_message, frame, shape_objs,
             text_objs, draw_objs, constants_dict):
     if 'system' in standardized_message:
         if 'on' in standardized_message:
             constants_dict['system'] = True
             logger.info('Turning system on')
         elif 'off' in standardized_message:
             constants_dict['system'] = False
             logger.info('Turning system off')
     if not constants_dict.get('system'):
         return frame, shape_objs, text_objs, draw_objs, constants_dict
     if 'name' or 'named' in standardized_message:
         if 'named' in standardized_message:
             name_idx = standardized_message.index('named') + 1
             name = ' '.join(standardized_message[name_idx:])
         elif 'name' in standardized_message:
             name_idx = standardized_message.index('name') + 1
             name = ' '.join(standardized_message[name_idx:])
     if 'create' in standardized_message:
         if 'color' in standardized_message:
             color_idx = standardized_message.index('color')
             color = standardized_message[color_idx + 1]
             color = 'COLOR_' + color.upper()
         else:
             color = constants.DEFAULT_SHAPE_COLOR
         if 'rectangle' in standardized_message:
             shape_objs[name] = shapes.Rectangle(name, color=color)
         elif 'circle' in standardized_message:
             shape_objs[name] = shapes.Circle(name, color=color)
     elif 'text' in standardized_message:
         text_idx = standardized_message.index('text')
         text_message = standardized_message[text_idx + 1]
         logger.info('Message text: {}'.format(text_message))
         if 'shape' in standardized_message:
             shape_idx = standardized_message.index('shape')
             shape_name = standardized_message[shape_idx + 1]
             logger.info('Message shape name: {}'.format(shape_name))
             text_objs[name] = shapes.Text(text_message,
                                           shape_objs[shape_name])
         else:
             text_objs[name] = shapes.Text(text_message)
     elif 'remove' in standardized_message:
         if 'shape' in standardized_message:
             del shape_objs[name]
         elif 'text' in standardized_message:
             del text_objs[name]
         elif 'draw' in standardized_message:
             draw_objs.clear()
     elif 'clear all objects' in message:
         shape_objs.clear()
         text_objs.clear()
         draw_objs.clear()
     elif 'connect' in standardized_message:
         shape_idx = standardized_message.index('shape')
         with_idx = standardized_message.index('with')
         shape_1 = standardized_message[(shape_idx + 1)]
         shape_2 = standardized_message[with_idx + 1]
         if shape_1 and shape_2 in shape_objs.keys():
             shape_objs[shape_1].shape_connections.append(shape_2)
     elif 'draw mode' in standardized_message:
         constants_dict['draw_mode'] = True
     elif 'boxes' in standardized_message:
         if 'on' in standardized_message:
             constants_dict['draw_box'] = True
         elif 'off' in standardized_message:
             constants_dict['draw_box'] = False
     elif 'resize' in standardized_message:
         if 'on' in standardized_message:
             constants_dict['resize'] = True
         if 'off' in standardized_message:
             constants_dict['resize'] = False
     elif 'load total process' in message:
         constants_dict['load_process'] = True
     elif 'clear total process' in message:
         constants_dict['load_process'] = False
     return frame, shape_objs, text_objs, draw_objs, constants_dict
Exemplo n.º 6
0
    def __init__(self, colors, city):
        frames.Frame.__init__(self, colors)

        owmkey = open("owmkey", "r")
        self.__owmApiCall = ('http://api.openweathermap.org/data/2.5/weather?id=' \
                              + city + '&APPID=' + owmkey.read()).split()[0]
        owmkey.close()

        self.weatherLastUpdate = datetime.datetime.now()

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, frames.HEIGHT // 4),
                                "black", 0, 0)
        sideTable = shapes.Table((0, frames.HEIGHT // 4), (frames.WIDTH // 3, frames.HEIGHT), \
                             "black", 255, 0, 2, 6)
        mainRect = shapes.Rect((frames.WIDTH // 3, frames.HEIGHT // 4), \
                            (frames.WIDTH, (3 * frames.HEIGHT) // 4), "black", 255, 0)
        bottomRect = shapes.Rect((frames.WIDTH // 3, (3 * frames.HEIGHT) // 4), \
                            (frames.WIDTH, frames.HEIGHT), "black", 255, 0)
        city = shapes.Text('City', (frames.WIDTH // 2, 23), "black", 25, 255)
        date = shapes.Text('Date: ', (frames.WIDTH // 2, 55), "black", 25, 255)
        temp = shapes.Text('Temperature: ', (225, frames.HEIGHT // 4 + 30),
                           "black", 24, 0)
        clouds = shapes.Text('Clouds: ', (200, 200), "black", 20, 0)
        weather = shapes.Text('weatherDesc', (335, 200), "black", 20, 0)
        weatherMain = shapes.Picture((frames.WIDTH - 160, frames.HEIGHT // 4 - 20), \
                               (frames.WIDTH, frames.HEIGHT // 4 + 160 - 20), \
                               "black", 0, 0, "OWM/10d_black", "OWM/10d_red")
        tempSym = shapes.Picture((frames.WIDTH // 3, frames.HEIGHT // 4 + 10), \
                                 (frames.WIDTH // 3 + 50, frames.HEIGHT // 4 + 50 + 10), \
                                 "black", 0, 0, "Icons/temp_black", "Icons/temp_red")

        # setup texts, last 6 are placeholders
        sideTable.addShapes([shapes.Picture((0,0), (50,50), "black", 0, 0, \
                             "Icons/sunrise_black", "Icons/sunrise_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/sunset_black", "Icons/sunset_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/pressure_black", "Icons/pressure_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/humidity_black", "Icons/humidity_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/windspeed_black", "Icons/windspeed_red"), \
                           shapes.Picture((0, 0), (50, 50), "black", 0, 0, \
                             "Icons/winddir_black", "Icons/winddir_red"), \
                           shapes.Text('sunr', (0,0), "black", 16, 0), \
                           shapes.Text('suns', (0,0), "black", 16, 0), \
                           shapes.Text('press', (0,0), "black", 16, 0), \
                           shapes.Text('humid', (0,0), "black", 16, 0), \
                           shapes.Text('win', (0,0), "black", 16, 0), \
                           shapes.Text('n/a', (0,0), "black", 16, 0)])

        sideTable.addBackground("black", 255, 255)

        self.addShapes([titleRect, sideTable, mainRect, bottomRect, city, date, \
                                   temp, clouds, weather, weatherMain, tempSym])

        self.updateWeather()
Exemplo n.º 7
0
    def __init__(self, colors, programName):
        frames.Frame.__init__(self, colors)
        # plan: sqlite db with marking of last performed exercise, then fill
        # with current tbd exercises for the week, swipe down for done
        self.__programName = programName

        titleRect = shapes.Rect((0, 0), (frames.WIDTH, frames.HEIGHT // 8),
                                "red", 0, 0)
        titleText = shapes.Text("Big 6", titleRect.getCenter(), "red", 24, 255)
        table = shapes.Table((0, frames.HEIGHT // 8 + 1), (frames.WIDTH - 1, frames.HEIGHT - 1), \
                             "black", 255, 0, 5, 6)

        table.addShapes([shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/squats_black", "Training/squats_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/handstand_black", "Training/handstand_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/legraise_black", "Training/legraise_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/bridge_black", "Training/bridge_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/pushups_black", "Training/pushups_red"), \
                         shapes.Picture((0, 0), (39, 39), "black", 0, 0, \
                         "Training/pullup_black", "Training/pullup_red") \
                        ])
        table.addShape(shapes.Text("1 floor", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 head ", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 tucks", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 short", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("1 wall ", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("0 dbell", (0, 0), "black", 14, 0))

        table.addShape(shapes.Text("25,25,25", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("30 sec.", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("12,12,7", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("12,12,12", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("15,10,0", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("12,12,0", (0, 0), "black", 14, 0))

        table.addShape(shapes.Text("30,30,30", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("40 sec.", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("14,14,10", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("14,14,14", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("15,15,0", (0, 0), "black", 14, 0))
        table.addShape(shapes.Text("14,14,0", (0, 0), "black", 14, 0))

        for i in range(0, 1):
            table.addShape(shapes.Text("50,50,50", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("2 min.", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("40,40,40", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("50,50,50", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("50,50,50", (0, 0), "red", 14, 0))
            table.addShape(shapes.Text("40,40,40", (0, 0), "red", 14, 0))

        self.addShapes([titleRect, titleText, table])