示例#1
0
    def draw(self):
        portrait = self.size.h > self.size.w
        scene.background(0.40, 0.80, 1.00) # light blue background color

        if portrait:
            self.play_btn_rect = scene.Rect(200, 358, 600, 100)
            self.char_btn_rect = scene.Rect(140, 485, 470, 100)
        else:
            self.play_btn_rect = scene.Rect( 20, 358, 350, 100)
            self.char_btn_rect = scene.Rect( 20, 485, 230, 100)
        
        scene.fill(0.50, 1.00, 0.00) # play button fill color
        scene.rect(*self.play_btn_rect)
        scene.fill(1.00, 1.00, 1.00) # character select button fill color
        scene.rect(*self.char_btn_rect)
        
        scene.tint(1.00, 1.00, 1.00) # white text color
        fs, x, y = (100, 385, 850) if portrait else (150, 525, 600)
        scene.text('Cloud Jump', MENU_FONT,  font_size=fs, x=x, y=y)
        fs, x, y = ( 65, 380, 650) if portrait else ( 65, 200, 400)
        scene.text('Play Game', BUTTON_FONT, font_size=fs, x=x, y=y)
        scene.tint(0.00, 0.50, 1.00) # blue text color
        fs, x, y = ( 54, 380, 521) if portrait else ( 54, 260, 285)
        scene.text('Character Select', BUTTON_FONT, font_size=fs, x=x, y=y)
        scene.tint(1.00, 1.00, 1.00) # white text color
        fs =  30
        if portrait:
            x, y = self.bounds.w / 2.0, self.bounds.h / 1.34
        else:
            x, y = self.bounds.w / 1.4, self.bounds.h / 1.7
        s = 'Welcome {}!'.format(player_name)
        scene.text(s, MENU_FONT, font_size=fs, x=x, y=y)

        for i in xrange(11):
            scene.image('PC_Grass_Block', self.bounds.w / 11 * i, 0)
示例#2
0
 def draw(self):
     scene.background(0, 0, 0)
     for c in self.cells.values():
         if c.alive:
             c.draw()
     scene.stroke(1,1,1)
     scene.stroke_weight(1)
     scene.image(self.grid_img, 0, 0)
示例#3
0
 def draw(self):
     scene.background(0, 0, 0)
     for c in self.cells.values():
         if c.alive:
             c.draw()
     scene.stroke(1, 1, 1)
     scene.stroke_weight(1)
     scene.image(self.grid_img, 0, 0)
示例#4
0
 def draw(self):
     scene.background(0, 0, 0)
     for piece in self.pieces:
         img = self.img_names[piece.pythonista_gui_img_name]
         pos = piece.coord.as_screen
         scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
     tpos = Coord(screen_width / 2, screen_height / 2 + 2 * scale_factor)
     scene.text('Select a piece to promote to', x=tpos.x, y=tpos.y)
示例#5
0
 def draw(self):
     scene.background(0, 0, 0)
     for i, piece in enumerate(self.pieces):
         img = self.img_names[piece.pythonista_gui_imgname]
         pos = piece.coord.as_screen()
         scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
     tpos = Coord(screen_width/2, screen_height/2 + 2*scale_factor)
     scene.text('Select a piece to promote to', x=tpos.x, y=tpos.y)
示例#6
0
 def draw(self):
     scene.background(0.09,0.09,0.102)
     scene.image(self.bgImages[self.bgIndex],
                                  200, 300, 300, 300)
     scene.fill(0.3, 0.3, 0.3, 1)
     scene.no_stroke()
     scene.text(theMessage, font_name='Chalkduster',
                            font_size=22, alignment=9)
     scene.ellipse(self.tapLoc.x - 50,
                   self.tapLoc.y - 50, 100, 100)
  def draw(self):
    if self.xy_velocity and not self.cur_touch:
      #self.dx += self.xy_velocity[0] * self.dt
      self.dy += self.xy_velocity[1] * self.dt
      decay = exp( - self.dt / self.velocity_decay_timescale_seconds )
      self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay)
      if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)):
        self.xy_velocity = None

    # Get day of week...Monday=1, etc
    day = datetime.datetime.today().isoweekday()

    # Rotate a color for each day in week
    r,g,b = get_background_color(day)
    scene.background(r,g,b)

    scene.translate(self.dx, self.dy)
    scene.fill(1, 1, 1)
    scene.stroke(1, 1, 1)
    # Line thickness
    scene.stroke_weight(1)

    # Vertical lines
    scene.line(-150,-931,-150,255)
    scene.line(150,-931,150,255)

    # Horizontal lines
    scene.line(-150,255,150,255)
    scene.line(-150,230,150,230)
    scene.line(-150,60,150,60)
    scene.line(-150,35,150,35)
    scene.line(-150,-104,150,-104)
    scene.line(-150,-241,150,-241)
    scene.line(-150,-379,150,-379)
    scene.line(-150,-517,150,-517)
    scene.line(-150,-655,150,-655)
    scene.line(-150,-794,150,-794)
    scene.line(-150,-931,150,-931)

    '''
    Text will be white by default and
    images drawn in their natural colors
    unless tint(r,g,b,a) function is used
    '''
    scene.text(weather_now,font_size=12,x=-140,y=250, alignment=3)
    scene.text(forecast,font_size=12,x=-140,y=55, alignment=3)

    # Insert icons into scene
    for i, image in enumerate(self.images):
      scene.image(image,75,y[i])
示例#8
0
    def draw(self):
        scale_factor = self.square_size
        scene.background(0, 0, 0)
        scene.fill(1, 1, 1, 1)
        board = self.game_view.game.board
        if self.render_mode['pieces']:
            for piece in board.pieces:
                scene.tint(1, 1, 1, 0.5)
                pos = self.as_screen(piece)  # piece.coord.as_screen
                #print(self.img_names)
                img = self.img_names[piece.name]
                scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
                scene.tint(1, 1, 1, 1)
                if piece.fen_loc == self.selected:
                    scene.fill(0.23347, 0.3564, 0.59917, 0.6)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
            if self.render_mode['timers']:
                white = str(board.player1.timer.get_run())
                black = str(board.player2.timer.get_run())
                bpos = Coord(992, 672)
                wpos = Coord(992, 96)
                scene.tint(1, 1, 1, 1)
                scene.text(black, x=bpos.x, y=bpos.y)
                scene.text(white, x=wpos.x, y=wpos.y)
                scene.tint(1, 1, 1, 1)
        if self.render_mode['sqrs']:
            for tile in board.tiles:
                x = int(tile.color == 'white')  # zero or one Thi is code
                color = (x, x, x, 0.57)  # alpha value
                scene.fill(*color)
                pos = self.as_screen(tile)  # tile.as_screen
                scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                scene.fill(1, 1, 1, 1)
                if self.render_mode['coords']:
                    center = Coord(pos.x + (scale_factor / 2),
                                   pos.y + (scale_factor / 2))
                    chess_pos = center + Coord(0, 10)
                    coord_pos = center - Coord(0, 10)
                    chess = tile.coord.as_chess
                    coord = str(tile.coord.as_tup)
                    scene.text(chess, x=chess_pos.x, y=chess_pos.y)
                    scene.text(coord, x=coord_pos.x, y=coord_pos.y)
            #if self.err_pos:  # FIXME this needs to be reenabled!
            #    sc = self.err_pos.as_screen
            #    scene.fill(1, 0, 0, 0.3)
            #    scene.rect(sc.x, sc.y, scale_factor, scale_factor)
            #    scene.fill(1, 1, 1, 1)
            #    scene.tint(0, 0, 1, 1)
            #    scene.text('Move\nInvalid', x=(sc.x + scale_factor/2), y=(sc.y + scale_factor/2))
            #    scene.tint(1, 1, 1, 1)
        if self.render_mode['valid']:
            for tile in board.tiles:
                #if self.valid_cache:
                #    print([x for x in self.valid_cache])
                #if tile.coord in self.valid_cache:  # FIXME
                if tile.fen_loc in self.valid_cache:
                    pos = self.as_screen(tile)  # tile.coord.as_screen
                    scene.fill(0.47934, 0.81198, 0.41839, 0.3)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
        if self.render_mode['turn_color']:
            if board.turn == 'white':
                turn_y = 1 * scale_factor
            elif board.turn == 'black':
                turn_y = 7 * scale_factor
            pos = Coord(896, turn_y)
            size = Coord(scale_factor / 2, scale_factor / 2)
            scene.tint(1, 1, 1, 1)
            scene.image(self.turn_indicator_img, pos.x, pos.y, size.x, size.y)
            scene.tint(1, 1, 1, 1)
        if self.won:
            pos = Coord(self.size.w / 2, self.size.h / 2)
            scene.tint(0.32645, 0.28306, 0.93492)
            # commented out until the bug in ChessGame.is_won() is fixed to be
            # less annoying
            scene.text('{} wins'.format(self.won),
                       x=pos.x,
                       y=pos.y,
                       font_size=40.0)
            scene.tint(1, 1, 1, 1)

        # Buttons
        x = scale_factor / 2
        scene.text('AI Easy', x=x, y=scale_factor * 6 - x)
        scene.text('AI Hard', x=x, y=scale_factor * 5 - x)
        scene.text('Get score', x=x, y=scale_factor * 4 - x)
        if self.disp_score:
            scene.text(str(self.pos_score),
                       x=x,
                       y=scale_factor * 4 - scale_factor / 1.5)
        scene.text('Undo', x=x, y=scale_factor * 3 - x)
        scene.text('Deselect', x=x, y=scale_factor * 2 - x)
        scene.text('Options', x=x, y=scale_factor * 7 - x)
  def draw(self):
    if self.xy_velocity and not self.cur_touch:
      #self.dx += self.xy_velocity[0] * self.dt
      self.dy += self.xy_velocity[1] * self.dt
      decay = exp( - self.dt / self.velocity_decay_timescale_seconds )
      self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay)
      if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second)
      and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)):
        self.xy_velocity = None

    # Save battery life
    #scene.frame_interval = 3

    scene.translate(self.dx, self.dy)
    scene.stroke(1, 1, 1)
    # Line thickness
    scene.stroke_weight(1)

    # Get day of week...Monday=1, etc
    day = datetime.datetime.today().isoweekday()

    # Rotate a color for each day of week
    r, g, b = get_background_color(day)
    scene.background(r, g, b)

    # Vertical lines for sides of main border
    scene.line(-155, y1_y2[7], -155, 240)
    scene.line(155, y1_y2[7], 155, 240)

    # Horizontal line constants
    x1 = -155
    x2 = 155
    '''
    Set text size for best mix of space &
    apperance...all text defaults to white unless
    tint() is used.
    '''
    font_sz = 10

    # Display city header and info
    scene.line(x1, 240, x2, 240)
    scene.text(city_name, font_size = font_sz * 2, x = 0, y = 220, alignment = 5)
    scene.text(conditions, font_size = font_sz + 4, x = 0, y = 195, alignment = 5)
    scene.text(temp_now, font_size = font_sz + 4, x = 0, y = 172, alignment = 5)

    # Display header box and current conditions
    scene.line(x1, 155, x2, 155)
    scene.line(x1, 130, x2, 130)
    scene.text(w, font_size = font_sz, x = -150, y = 150, alignment = 3)

    # Display header box for 24 hr forecast
    scene.line(x1, -40, x2, -40)
    scene.text('Next 24 Hours:', font_size = font_sz, x = -150, y = -45, alignment = 3)

    # Division lines for 24 hr forecast
    y = -65
    for i in range(4):
      scene.line(x1, y, x2, y)
      y = y - 80

    # Divide 24 hrs into 4 rows of 6 hrs each
    x = -205
    y = -70
    count = 0
    the_x = []
    the_y = []
    for i in range(24):
      # Display six hours per row
      if count%6 == 0 and count <> 0:
        x = -205
        y = y - 80
      x = x + 55
      # Get coordinates for icon placement
      the_x.append(x - 4)
      the_y.append(y - 55)
      count += 1
      # Percent of precip...no zeros
      if the_pops[i] == '0%':
        the_pops[i] = ''
      # Display hour, pop, & temp in grid
      msg = '{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i], the_temps[i])
      scene.text(msg, font_size = font_sz, x = x, y = y, alignment = 3)

    # Insert icons into 24 hour forecast
    for i, image in enumerate(self.images):
      if i <= 23:
        # Reduce icon size for space
        scene.image(image, the_x[i], the_y[i], 30, 30)

    # Display header box for extended forecast
    scene.line(x1, -385, x2, -385)
    scene.text('Next 7 Days:', font_size = font_sz, x = -150, y = -390, alignment = 3)

    # Display extended forecast
    scene.line(x1, -410, x2, -410)
    scene.text(txt_wrapped_f, font_size = font_sz, x = -150, y = -402, alignment = 3)

    # Insert icons into extended forecast
    for i, image in enumerate(self.images):
      if i >= 24:
        # Tweak icon placement a bit more for best appearance
        scene.image(image, 113, icon_y[i-24], 40, 40)

    # Division lines for days of week
    for i in range(len(y1_y2)):
      if i > 0:
        scene.line(x1, y1_y2[i], x2, y1_y2[i])
示例#10
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1, 1)
     if self.render_mode['pieces']:
         for piece in self.game.board.pieces:
             scene.tint(1, 1, 1, 0.5)
             pos = piece.coord.as_screen()
             img = self.img_names[piece.pythonista_gui_imgname]
             scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
             scene.tint(1, 1, 1, 1)
             if piece.coord == self.selected:
                 scene.fill(0.23347,0.3564,0.59917, 0.6)
                 scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                 scene.fill(1, 1, 1, 1)
         if self.render_mode['timers']:
             white = str(self.game.board.player1.timer.get_run())
             black = str(self.game.board.player2.timer.get_run())
             bpos = Coord(992, 672)
             wpos = Coord(992, 96)
             scene.tint(1, 1, 1, 1)
             scene.text(black, x=bpos.x, y=bpos.y)
             scene.text(white, x=wpos.x, y=wpos.y)
             scene.tint(1, 1, 1, 1)
     if self.render_mode['sqrs']:
         for tile in self.game.board.tiles:
             color = tile.color.tilecolor
             color += (0.57,)  # alpha value
             pos = tile.coord.as_screen()
             scene.fill(*color)
             scene.rect(pos.x, pos.y, scale_factor, scale_factor)
             scene.fill(1, 1, 1, 1)
             if self.render_mode['coords']:
                 center = Coord(pos.x + (scale_factor / 2), pos.y + (scale_factor / 2))
                 chess_pos = center + Coord(0, 10)
                 coord_pos = center - Coord(0, 10)
                 chess = tile.coord.as_chess()
                 coord = str(tile.coord.as_tup())
                 scene.text(chess, x=chess_pos.x, y=chess_pos.y)
                 scene.text(coord, x=coord_pos.x, y=coord_pos.y)
         if self.err_pos.x is not None:
             sc = self.err_pos.as_screen()
             scene.fill(1, 0, 0, 0.3)
             scene.rect(sc.x, sc.y, scale_factor, scale_factor)
             scene.fill(1, 1, 1, 1)
             scene.tint(0, 0, 1, 1)
             scene.text('Move\nInvalid', x=(sc.x + scale_factor/2), y=(sc.y + scale_factor/2))
             scene.tint(1, 1, 1, 1)
     if self.render_mode['valid']:
         for tile in self.game.board.tiles:
             if tile.coord in self.valid_cache:
                 pos = tile.coord.as_screen()
                 scene.fill(0.47934,0.81198,0.41839, 0.3)
                 scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                 scene.fill(1, 1, 1, 1) 
     if self.render_mode['turn']:
         if self.game.board.turn == 'white':
             turn_y = 1 * scale_factor
         elif self.game.board.turn == 'black':
             turn_y = 7 * scale_factor
         pos = Coord(896, turn_y)
         size = Coord(scale_factor / 2, scale_factor / 2)
         scene.tint(1, 1, 1, 1)
         scene.image(self.turn_indicator_img, pos.x, pos.y, size.x, size.y)
         scene.tint(1, 1, 1, 1)
     if self.won:
         pos = Coord(self.size.w/2, self.size.h/2)
         scene.tint(0.32645,0.28306,0.93492)
         # commented out until the bug in ChessGame.is_won() is fixed to be 
         # less annoying
         scene.text('{} wins'.format(self.won), x=pos.x, y=pos.y, font_size=40.0)
         scene.tint(1, 1, 1, 1)
     
     # Buttons
     scene.text('AI Easy', x=scale_factor/2, y=scale_factor*6 - scale_factor/2)
     scene.text('AI Hard', x=scale_factor/2, y=scale_factor*5 - scale_factor/2)
     scene.text('Get score', x=scale_factor/2, y=scale_factor*4 - scale_factor/2)
     if self.disp_score:
         scene.text(str(self.pos_score), x=scale_factor/2, y=scale_factor*4 - scale_factor/1.5)
     scene.text('Undo', x=scale_factor/2, y=scale_factor*3 - scale_factor/2)
     scene.text('Deselect', x=scale_factor/2, y=scale_factor*2 - scale_factor/2)
     scene.text('Options', x=scale_factor/2, y=scale_factor*7 - scale_factor/2)
示例#11
0
def draw(image, x, y):
    scene.image(image.getImageName(), x,
                getHeight() - image.getHeight() - y)
示例#12
0
    def draw(self):
        scale_factor = self.square_size
        scene.background(0, 0, 0)
        scene.fill(1, 1, 1, 1)
        board = self.game_view.game.board
        if self.render_mode['pieces']:
            for piece in board.pieces:
                scene.tint(1, 1, 1, 0.5)
                pos = self.as_screen(piece)  # piece.coord.as_screen
                #print(self.img_names)
                img = self.img_names[piece.name]
                scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
                scene.tint(1, 1, 1, 1)
                if piece.fen_loc == self.selected:
                    scene.fill(0.23347,0.3564,0.59917, 0.6)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
            if self.render_mode['timers']:
                white = str(board.player1.timer.get_run())
                black = str(board.player2.timer.get_run())
                bpos = Coord(992, 672)
                wpos = Coord(992, 96)
                scene.tint(1, 1, 1, 1)
                scene.text(black, x=bpos.x, y=bpos.y)
                scene.text(white, x=wpos.x, y=wpos.y)
                scene.tint(1, 1, 1, 1)
        if self.render_mode['sqrs']:
            for tile in board.tiles:
                x = int(tile.color == 'white')  # zero or one Thi is code
                color = (x, x, x, 0.57)  # alpha value
                scene.fill(*color)
                pos = self.as_screen(tile)  # tile.as_screen
                scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                scene.fill(1, 1, 1, 1)
                if self.render_mode['coords']:
                    center = Coord(pos.x + (scale_factor / 2), pos.y + (scale_factor / 2))
                    chess_pos = center + Coord(0, 10)
                    coord_pos = center - Coord(0, 10)
                    chess = tile.coord.as_chess
                    coord = str(tile.coord.as_tup)
                    scene.text(chess, x=chess_pos.x, y=chess_pos.y)
                    scene.text(coord, x=coord_pos.x, y=coord_pos.y)
            #if self.err_pos:  # FIXME this needs to be reenabled!
            #    sc = self.err_pos.as_screen
            #    scene.fill(1, 0, 0, 0.3)
            #    scene.rect(sc.x, sc.y, scale_factor, scale_factor)
            #    scene.fill(1, 1, 1, 1)
            #    scene.tint(0, 0, 1, 1)
            #    scene.text('Move\nInvalid', x=(sc.x + scale_factor/2), y=(sc.y + scale_factor/2))
            #    scene.tint(1, 1, 1, 1)
        if self.render_mode['valid']:
            for tile in board.tiles:
                #if self.valid_cache:
                #    print([x for x in self.valid_cache])
                #if tile.coord in self.valid_cache:  # FIXME
                if tile.fen_loc in self.valid_cache:
                    pos = self.as_screen(tile)  # tile.coord.as_screen
                    scene.fill(0.47934,0.81198,0.41839, 0.3)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
        if self.render_mode['turn_color']:
            if board.turn == 'white':
                turn_y = 1 * scale_factor
            elif board.turn == 'black':
                turn_y = 7 * scale_factor
            pos = Coord(896, turn_y)
            size = Coord(scale_factor / 2, scale_factor / 2)
            scene.tint(1, 1, 1, 1)
            scene.image(self.turn_indicator_img, pos.x, pos.y, size.x, size.y)
            scene.tint(1, 1, 1, 1)
        if self.won:
            pos = Coord(self.size.w/2, self.size.h/2)
            scene.tint(0.32645,0.28306,0.93492)
            # commented out until the bug in ChessGame.is_won() is fixed to be
            # less annoying
            scene.text('{} wins'.format(self.won), x=pos.x, y=pos.y, font_size=40.0)
            scene.tint(1, 1, 1, 1)

        # Buttons
        x=scale_factor/2
        scene.text('AI Easy', x=x, y=scale_factor*6 - x)
        scene.text('AI Hard', x=x, y=scale_factor*5 - x)
        scene.text('Get score', x=x, y=scale_factor*4 - x)
        if self.disp_score:
            scene.text(str(self.pos_score), x=x, y=scale_factor*4 - scale_factor/1.5)
        scene.text('Undo', x=x, y=scale_factor*3 - x)
        scene.text('Deselect', x=x, y=scale_factor*2 - x)
        scene.text('Options', x=x, y=scale_factor*7 - x)
示例#13
0
 def draw(self):
     scene.background(0, 0, 1)
     scene.image(self.iid, self.x, self.y, self.w * self.zoom, self.h * self.zoom)
     self.plusbutton.draw()
     self.minusbutton.draw()
示例#14
0
	def draw(self):
		scene.background(0.40, 0.80, 1.00)
		scene.fill(1.00, 1.00, 1.00)

		scene.image('Boy', *self.p1_rect)
		scene.image('Girl', *self.p2_rect)
		scene.image('Guardsman', *self.p3_rect)
		scene.image('Hamster_Face', *self.p4_rect)
		scene.image('Mouse_Face', *self.p5_rect)
		scene.image('Man', *self.p6_rect)
    def draw(self):
        if self.xy_velocity and not self.cur_touch:
            #self.dx += self.xy_velocity[0] * self.dt
            self.dy += self.xy_velocity[1] * self.dt
            decay = exp(-self.dt / self.velocity_decay_timescale_seconds)
            self.xy_velocity = (self.xy_velocity[0] * decay,
                                self.xy_velocity[1] * decay)
            if ((abs(self.xy_velocity[0]) <=
                 self.min_velocity_points_per_second)
                    and (abs(self.xy_velocity[1]) <=
                         self.min_velocity_points_per_second)):
                self.xy_velocity = None

        # Save battery life
        #scene.frame_interval = 3

        scene.translate(self.dx, self.dy)
        scene.stroke(1, 1, 1)
        # Line thickness
        scene.stroke_weight(1)

        scene.line(1, 25, 20, 25)

        # Get day of week...Monday=1, etc
        day = datetime.datetime.today().isoweekday()

        # Rotate a color for each day of week
        r, g, b = get_background_color(day)
        scene.background(r, g, b)

        # Vertical lines for sides of main border
        scene.line(-155, y1_y2[7], -155, 240)
        scene.line(155, y1_y2[7], 155, 240)

        # Horizontal line constants
        x1 = -155
        x2 = 155
        '''
    Set text size for best mix of space &
    apperance...all text defaults to white unless
    tint() is used.
    '''
        font_sz = 10

        # Display city header and info
        scene.line(x1, 240, x2, 240)
        scene.text(city_name, font_size=font_sz * 2, x=0, y=220, alignment=5)
        scene.text(conditions, font_size=font_sz + 4, x=0, y=195, alignment=5)
        scene.text(temp_now, font_size=font_sz + 4, x=0, y=172, alignment=5)

        # Display header box and current conditions
        scene.line(x1, 155, x2, 155)
        scene.line(x1, 130, x2, 130)
        scene.text(w, font_size=font_sz, x=-150, y=150, alignment=3)

        # Display header box for 24 hr forecast
        scene.line(x1, -40, x2, -40)
        scene.text('Next 24 Hours:',
                   font_size=font_sz,
                   x=-150,
                   y=-45,
                   alignment=3)

        # Division lines for 24 hr forecast
        y = -65
        for i in range(4):
            scene.line(x1, y, x2, y)
            y = y - 80

        # Divide 24 hrs into 4 rows of 6 hrs each
        x = -205
        y = -70
        count = 0
        the_x = []
        the_y = []
        for i in range(24):
            # Display six hours per row
            if count % 6 == 0 and count <> 0:
                x = -205
                y = y - 80
            x = x + 55
            # Get coordinates for icon placement
            the_x.append(x - 4)
            the_y.append(y - 55)
            count += 1
            # Percent of precip...no zeros
            if the_pops[i] == '0%':
                the_pops[i] = ''
            # Display hour, pop, & temp in grid
            scene.text('{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i],
                                                 the_temps[i]),
                       font_size=font_sz,
                       x=x,
                       y=y,
                       alignment=3)

        # Insert icons into 24 hour forecast
        for i, image in enumerate(self.images):
            if i <= 23:
                # Reduce icon size for space
                scene.image(image, the_x[i], the_y[i], 30, 30)

        # Display header box for extended forecast
        scene.line(x1, -385, x2, -385)
        scene.text('Next 7 Days:',
                   font_size=font_sz,
                   x=-150,
                   y=-390,
                   alignment=3)

        # Display extended forecast
        scene.line(x1, -410, x2, -410)
        scene.text(txt_wrapped_f,
                   font_size=font_sz,
                   x=-150,
                   y=-402,
                   alignment=3)

        # Insert icons into extended forecast
        for i, image in enumerate(self.images):
            if i >= 24:
                # Tweak icon placement a bit more for best appearance
                scene.image(image, 113, icon_y[i - 24], 40, 40)

        # Division lines for days of week
        for i in range(len(y1_y2)):
            if i > 0:
                scene.line(x1, y1_y2[i], x2, y1_y2[i])
示例#16
0
    def draw(self):
        if self.xy_velocity and not self.cur_touch:
            #self.dx += self.xy_velocity[0] * self.dt
            self.dy += self.xy_velocity[1] * self.dt
            decay = exp(-self.dt / self.velocity_decay_timescale_seconds)
            self.xy_velocity = (self.xy_velocity[0] * decay,
                                self.xy_velocity[1] * decay)
            if ((abs(self.xy_velocity[0]) <=
                 self.min_velocity_points_per_second)
                    and (abs(self.xy_velocity[1]) <=
                         self.min_velocity_points_per_second)):
                self.xy_velocity = None

        # Save battery life
        #scene.frame_interval = 3

        scene.translate(self.dx, self.dy)
        scene.stroke(1, 1, 1)
        # Line thickness
        scene.stroke_weight(1)

        scene.line(1, 25, 20, 25)

        # Get day of week...Monday=1, etc
        day = datetime.datetime.today().isoweekday()

        # Rotate a color for each day of week
        r, g, b = self.get_background_color(day)
        scene.background(r, g, b)
        '''
    Set text size for best mix of space &
    apperance...all text defaults to white unless
    tint() is used.
    '''
        font_sz = 10

        x1 = -((self.size.w / 2) - 2)  # -205 for iP6p, -158 for iP5
        x2 = (self.size.w / 2) - 2  # 205 for iP6p, 158 for iP5

        # If Pythonista 2 & iPhone 6+ or larger...
        if py_ver == '2' and is_P6:
            y_anchor = 325
            l_margin = x1 + 10
            # 24 hour temps in a 3x8 matrix
            rows = 3
            hrs_per_row = 8
        else:
            y_anchor = 240
            l_margin = x1 + 8
            # 24 hour temps in a 4x6 matrix
            rows = 4
            hrs_per_row = 6

        # Vertical lines for sides of main border
        scene.line(x1, y1_y2[7], x1, y_anchor)
        scene.line(x2, y1_y2[7], x2, y_anchor)
        # Display city header and info
        scene.line(x1, y_anchor, x2, y_anchor)
        scene.text(city_name,
                   font_size=font_sz * 2,
                   x=0,
                   y=y_anchor - 20,
                   alignment=5)
        scene.text(conditions,
                   font_size=font_sz + 4,
                   x=0,
                   y=y_anchor - 45,
                   alignment=5)
        scene.text(temp_now,
                   font_size=font_sz + 4,
                   x=0,
                   y=y_anchor - 68,
                   alignment=5)
        # Display header box and current conditions
        scene.line(x1, y_anchor - 85, x2, y_anchor - 85)
        scene.line(x1, y_anchor - 110, x2, y_anchor - 110)
        l_margin = x1 + 10
        scene.text(w,
                   font_size=font_sz,
                   x=l_margin,
                   y=y_anchor - 90,
                   alignment=3)
        # Display header box for 24 hr forecast
        scene.line(x1, y_anchor - 280, x2, y_anchor - 280)
        scene.text('Next 24 Hours:',
                   font_size=font_sz,
                   x=l_margin,
                   y=y_anchor - 285,
                   alignment=3)
        # Division lines for 24 hr forecast
        # Divide 24 hrs into 'rows' rows of 'hrs_per_row' hrs each
        y = y_anchor - 305
        for i in range(int(rows)):
            scene.line(x1, y, x2, y)
            y = y - 80

        x = x1 - 45
        y = y_anchor - 310
        count = 0
        the_x = []
        the_y = []

        for i in range(24):
            # Display 'hrs_per_row' hours per row
            if count % int(hrs_per_row) == 0 and count <> 0:
                x = x1 - 45
                y = y - 80
            x = x + 53
            # Get coordinates for icon placement
            the_x.append(x - 4)
            the_y.append(y - 55)
            count += 1
            # Percent of precip...no zeros
            if the_pops[i] == '0%':
                the_pops[i] = ''
            # Display hour, pop, & temp in grid
            scene.text('{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i],
                                                 the_temps[i]),
                       font_size=font_sz,
                       x=x,
                       y=y,
                       alignment=3)

        # Insert icons into 24 hour forecast
        for i, image in enumerate(self.images):
            if i <= 23:
                # Reduce icon size for space
                scene.image(image, the_x[i], the_y[i], 30, 30)

        if py_ver == '2' and is_P6:
            # Display header box for extended forecast
            scene.line(x1, y_anchor - 545, x2, y_anchor - 545)
            scene.text('Next 7 Days:',
                       font_size=font_sz,
                       x=l_margin,
                       y=y_anchor - 550,
                       alignment=3)
            # Display extended forecast
            scene.line(x1, y_anchor - 570, x2, y_anchor - 570)
            scene.text(txt_wrapped_f,
                       font_size=font_sz,
                       x=l_margin,
                       y=y_anchor - 563,
                       alignment=3)
        else:
            # Display header box for extended forecast
            scene.line(x1, y_anchor - 625, x2, y_anchor - 625)
            scene.text('Next 7 Days:',
                       font_size=font_sz,
                       x=l_margin,
                       y=y_anchor - 630,
                       alignment=3)
            # Display extended forecast
            scene.line(x1, y_anchor - 650, x2, y_anchor - 650)
            scene.text(txt_wrapped_f,
                       font_size=font_sz,
                       x=l_margin,
                       y=y_anchor - 643,
                       alignment=3)

        # Insert icons into extended forecast
        for i, image in enumerate(self.images):
            if i >= 24:
                # Tweak icon placement a bit more for best appearance
                if wa.pythonista_version()[:1] == '2' and wa.is_iP6p():
                    scene.image(image, 160, icon_y[i - 24], 40, 40)
                else:
                    scene.image(image, 113, icon_y[i - 24], 40, 40)

        # Division lines for days of week
        for i in range(len(y1_y2)):
            if i > 0:
                scene.line(x1, y1_y2[i], x2, y1_y2[i])
  def draw(self):
    if self.xy_velocity and not self.cur_touch:
      #self.dx += self.xy_velocity[0] * self.dt
      self.dy += self.xy_velocity[1] * self.dt
      decay = exp( - self.dt / self.velocity_decay_timescale_seconds )
      self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay)
      if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)):
        self.xy_velocity = None

    # Save battery life
    #scene.frame_interval = 3

    scene.translate(self.dx, self.dy)
    scene.stroke(1, 1, 1)
    # Line thickness
    scene.stroke_weight(1)

    scene.line(1, 25, 20, 25)

    # Get day of week...Monday=1, etc
    day = datetime.datetime.today().isoweekday()

    # Rotate a color for each day of week
    r, g, b = self.get_background_color(day)
    scene.background(r, g, b)

    '''
    Set text size for best mix of space &
    apperance...all text defaults to white unless
    tint() is used.
    '''
    font_sz = 10

    x1 = - ((self.size.w / 2) -2) # -205 for iP6p, -158 for iP5
    x2 = (self.size.w / 2) -2     # 205 for iP6p, 158 for iP5

    # If Pythonista 2 & iPhone 6+ or larger...
    if py_ver == '2' and is_P6:
      y_anchor = 325
      l_margin = x1 + 10
      # 24 hour temps in a 3x8 matrix
      rows = 3
      hrs_per_row = 8
    else:
      y_anchor = 240
      l_margin = x1 + 8
      # 24 hour temps in a 4x6 matrix
      rows = 4
      hrs_per_row = 6

    # Vertical lines for sides of main border
    scene.line(x1, y1_y2[7], x1, y_anchor)
    scene.line(x2, y1_y2[7], x2, y_anchor)
    # Display city header and info
    scene.line(x1, y_anchor, x2, y_anchor)
    scene.text(city_name, font_size = font_sz * 2, x = 0, y = y_anchor - 20, alignment = 5)
    scene.text(conditions, font_size = font_sz + 4, x = 0, y = y_anchor - 45, alignment = 5)
    scene.text(temp_now, font_size = font_sz + 4, x = 0, y = y_anchor - 68, alignment = 5)
    # Display header box and current conditions
    scene.line(x1, y_anchor - 85, x2, y_anchor - 85)
    scene.line(x1, y_anchor - 110, x2, y_anchor - 110)
    l_margin = x1 + 10
    scene.text(w, font_size = font_sz, x = l_margin, y = y_anchor - 90, alignment = 3)
    # Display header box for 24 hr forecast
    scene.line(x1, y_anchor - 280, x2, y_anchor - 280)
    scene.text('Next 24 Hours:', font_size = font_sz, x = l_margin, y = y_anchor - 285, alignment = 3)
    # Division lines for 24 hr forecast
    # Divide 24 hrs into 'rows' rows of 'hrs_per_row' hrs each
    y = y_anchor - 305
    for i in range(int(rows)):
      scene.line(x1, y, x2, y)
      y = y - 80

    x = x1 - 45
    y = y_anchor - 310
    count = 0
    the_x = []
    the_y = []

    for i in range(24):
      # Display 'hrs_per_row' hours per row
      if count%int(hrs_per_row) == 0 and count <> 0:
        x = x1 - 45
        y = y - 80
      x = x + 53
      # Get coordinates for icon placement
      the_x.append(x - 4)
      the_y.append(y - 55)
      count += 1
      # Percent of precip...no zeros
      if the_pops[i] == '0%':
        the_pops[i] = ''
      # Display hour, pop, & temp in grid
      scene.text('{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i], the_temps[i]), font_size = font_sz, x = x, y = y, alignment = 3)

    # Insert icons into 24 hour forecast
    for i, image in enumerate(self.images):
      if i <= 23:
        # Reduce icon size for space
        scene.image(image, the_x[i], the_y[i], 30, 30)

    if py_ver == '2' and is_P6:
      # Display header box for extended forecast
      scene.line(x1, y_anchor - 545, x2, y_anchor - 545)
      scene.text('Next 7 Days:', font_size = font_sz, x = l_margin, y = y_anchor - 550, alignment = 3)
      # Display extended forecast
      scene.line(x1, y_anchor - 570, x2, y_anchor - 570)
      scene.text(txt_wrapped_f, font_size = font_sz, x = l_margin, y = y_anchor - 563, alignment = 3)
    else:
      # Display header box for extended forecast
      scene.line(x1, y_anchor - 625, x2, y_anchor - 625)
      scene.text('Next 7 Days:', font_size = font_sz, x = l_margin, y = y_anchor - 630, alignment = 3)
      # Display extended forecast
      scene.line(x1, y_anchor - 650, x2, y_anchor - 650)
      scene.text(txt_wrapped_f, font_size = font_sz, x = l_margin, y = y_anchor - 643, alignment = 3)

    # Insert icons into extended forecast
    for i, image in enumerate(self.images):
      if i >= 24:
        # Tweak icon placement a bit more for best appearance
        if wa.pythonista_version()[:1] == '2' and wa.is_iP6p():
          scene.image(image, 160, icon_y[i - 24], 40, 40)
        else:
          scene.image(image, 113, icon_y[i - 24], 40, 40)

    # Division lines for days of week
    for i in range(len(y1_y2)):
      if i > 0:
        scene.line(x1, y1_y2[i], x2, y1_y2[i])