Ejemplo n.º 1
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     scene.fill(0, 1, 0)  # 0,1,0 = green
     scene.rect(
         *self.rect1)  # *self.rect1 = self.rect1[0], ..., self.rect1[3]
     scene.fill(1, 0, 0)  # 1,0,0 = red
     scene.rect(*self.rect2)
Ejemplo n.º 2
0
 def draw(self):
     scene.background(0,0,1) # 0,0,1 = blue
     if self.color == 1:
         scene.fill(0,1,0)       # 0,1,0 = green
     elif self.color == 2:
         scene.fill(1,0,0)       # 1,0,0 = red
     scene.rect(50,50,50,50)
 def draw(self):
     scene.background(0,0,0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1,1,1)   # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
     locations = [[0,0],[0,0]]
     i = 0
     if len(self.touches) == 2:
         for touch in self.touches.values():
             locations[i] = touch.location
             i += 1
         if self.reset:
             self.reset = False
             self.distance_old = math.sqrt(math.pow((locations[1][0] - locations[0][0]),2) + pow((locations[1][1] - locations[0][1]),2))
         else:
             self.distance_new = math.sqrt(math.pow((locations[1][0] - locations[0][0]),2) + pow((locations[1][1] - locations[0][1]),2))
             self.distance_abs = self.distance_new - self.distance_old
             self.reset = True
         if self.distance_abs != 0:
             zoom_new = self.distance_abs/self.bounds.w*self.zoom_speed
             if zoom_new < 0:
                 self.zoom += zoom_new
             else:
                 self.zoom += zoom_new
             if self.zoom < self.zoom_min:
                 self.zoom = self.zoom_min
             elif self.zoom > self.zoom_max:
                 self.zoom = self.zoom_max
             self.root_layer.animate('scale_x', self.zoom, duration=0.0)
             self.root_layer.animate('scale_y', self.zoom, duration=0.0)     
Ejemplo n.º 4
0
 def draw(self):
     scene.background(0,0,1) # 0,0,1 = blue
     self.rect1_layer.update(self.dt)   # alpha animation
     self.rect1_layer.draw()            # alpha animation
     #scene.fill(0,1,0)       # 0,1,0 = green
     #scene.ellipse(*self.rect1) # *self.rect1 = self.rect1[0], ..., self.rect1[3]
     scene.fill(1,0,0)       # 1,0,0 = red
Ejemplo n.º 5
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     if self.color == 1:
         scene.fill(0, 1, 0)  # 0,1,0 = green
     elif self.color == 2:
         scene.fill(1, 0, 0)  # 1,0,0 = red
     scene.rect(50, 50, 50, 50)
    def draw(self):
        scene.background(0, 0.5, 1.0)
        scene.fill(1, 1, 1)
        scene.rect(self.x,self.y, 32, 32)  # player
        scene.fill(0, 0, 0)
        scene.rect(self.x - 70, self.y + 75, 700, 32)  # roof
        self.floor = scene.rect(self.x - 70, self.y - 75, 700, 32)  # floor
        print('self.floor is always None:', self.floor)
        if not self.grav:
            self.acel += 1

  #text
        scene.tint(0, 0, 0, 1)
        if self.dead:
            scene.text('You are DEAD', 'Arial', 12, 48, self.y + 16)
        else:
            self.pts += 1
        scene.text('Points: %i' % self.pts, 'Arial', 12, self.x-48, self.y + 32)

  # Touch input:
        scene.fill(1,0,0)
        if not self.grav:
            self.acel += 1

  # Physics
        if not self.dead:
            self.y += self.acel
        if self.y < self.floor:
            self.y = self.floor
            self.acel = 0
        else:
            print('problem: {} > {}'.format(self.y, self.floor))
            self.acel -= self.g
        self.acel = max(min(self.acel, self.ms), -self.ms)
    def draw(self):
        scene.background(0,0,0)
        scene.stroke_weight(4)

        for colored_line in self.colored_lines:
            scene.stroke(*colored_line.color)
            scene.line(*colored_line.line)
Ejemplo n.º 8
0
 def draw(self):
     self.invocations += 1
     scene.background(0, 0, 0)
     scene.fill(1, 0, 0)
     self.active_scene.touches = self.touches
     self.active_scene.t = self.t - self.tmp_t
     self.active_scene.draw()
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1, 1, 1)  # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
     locations = [[0, 0], [0, 0]]
     i = 0
     if len(self.touches) == 2:
         for touch in self.touches.values():
             locations[i] = touch.location
             i += 1
         if self.reset:
             self.reset = False
             self.distance_old = math.sqrt(
                 math.pow((locations[1][0] - locations[0][0]), 2) +
                 pow((locations[1][1] - locations[0][1]), 2))
         else:
             self.distance_new = math.sqrt(
                 math.pow((locations[1][0] - locations[0][0]), 2) +
                 pow((locations[1][1] - locations[0][1]), 2))
             self.distance_abs = self.distance_new - self.distance_old
             self.reset = True
         if self.distance_abs != 0:
             zoom_new = self.distance_abs / self.bounds.w * self.zoom_speed
             if zoom_new < 0:
                 self.zoom += zoom_new
             else:
                 self.zoom += zoom_new
             if self.zoom < self.zoom_min:
                 self.zoom = self.zoom_min
             elif self.zoom > self.zoom_max:
                 self.zoom = self.zoom_max
             self.root_layer.animate('scale_x', self.zoom, duration=0.0)
             self.root_layer.animate('scale_y', self.zoom, duration=0.0)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
 def draw(self):
     x,y,z = motion.get_attitude() if use_motion else scene.gravity()
     r,g,b = abs(x), abs(y), abs(z)
     scene.background(r, g, b)
     super(Advice, self).draw()
     scene.tint(1-r, 1-g, 1-b)
     scene.text(self.answer, 'Futura', 45, *self.center)
Ejemplo n.º 12
0
 def draw(self):
     x,y,z = motion.get_attitude() if use_motion else scene.gravity()
     r,g,b = abs(x), abs(y), abs(z)  # No negative colors
     scene.background(r, g, b)
     scene.tint(1-r, 1-g, 1-b)
     scene.text(fmt.format(x, y, z), font_size=32,
                x=self.center.x, y=self.center.y)
Ejemplo n.º 13
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     scene.stroke(1, 0, 0)  # 1,0,0 = red
     scene.stroke_weight(5)
     scene.line(50, 50, 100, 50)
     scene.line(100, 50, 75, 75)
     scene.line(75, 75, 50, 50)
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
 def draw(self):
     # Called for every frame (typically 60 per second).
     scene.background(0, 0, 0)
     # Draw a circle for every finger touch
     scene.fill(*self.fgColor)
     for touch in self.touches.values():
         scene.ellipse(touch.location.x - 50, touch.location.y - 50, 100,
                       100)
Ejemplo n.º 16
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)
Ejemplo n.º 17
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     self.rect1_layer.update(self.dt)  # alpha animation
     self.rect1_layer.draw()  # alpha animation
     #scene.fill(0,1,0)       # 0,1,0 = green
     #scene.ellipse(*self.rect1) # *self.rect1 = self.rect1[0], ..., self.rect1[3]
     scene.fill(1, 0, 0)  # 1,0,0 = red
     scene.ellipse(*self.circle2)
Ejemplo n.º 18
0
 def draw(self):
     scene.background(0.40, 0.80, 1.00)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     self.cloud.frame.x += 1
     if not self.bounds.intersects(self.cloud.frame):
         del self.cloud  # whack the old cloud
         self.setup()  # and create a new one
 def draw(self):
     ''' real time drawing only'''
     scene.background(0, 0, 0)
     if self.touch:
         scene.fill(self.spot_color)
         loc = self.touch.location
         scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
         scene.text('{}, {}'.format(*loc), 'Futura', 20, 100, 50)
Ejemplo n.º 20
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)
Ejemplo n.º 21
0
 def draw(self):
     scene.background(bg_color.r, bg_color.g, bg_color.b)
     fg_color = inverse_color(bg_color)
     scene.tint(*fg_color)  # .r, fg_color.g, fg_color.b)
     the_text = fmt.format(*bg_color)
     if local_ip_addr:  # if remote user has not yet connected
         the_text += '\n\n' + ip_fmt.format(local_ip_addr)
     scene.text(the_text, font_size=40, x=self.x, y=self.y)
Ejemplo n.º 22
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)
Ejemplo n.º 23
0
 def draw(self):
     scene.background(0.9, 0.9, 0.9)
     sx, sy = self.size
     mx = 0.5 * (sx - self.wall.bounds.w)
     my = 0.5 * (sy - self.wall.bounds.h)
     self.wall.move(mx, my)
     self.draw_tiles(self.wall.tiles)
     self.wall.update()
Ejemplo n.º 24
0
 def draw(self):
     scene.background(bg_color.r, bg_color.g, bg_color.b)
     fg_color = inverse_color(bg_color)
     scene.tint(*fg_color) # .r, fg_color.g, fg_color.b)
     the_text = fmt.format(*bg_color)
     if local_ip_addr:  # if remote user has not yet connected
         the_text += '\n\n' + ip_fmt.format(local_ip_addr)
     scene.text(the_text, font_size=40, x=self.x, y=self.y)
Ejemplo n.º 25
0
 def draw(self):
     self.game_loop()
     scene.background(0.40, 0.80, 1.00)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     for sprite in self.scenery:
         sprite.draw()
     self.draw_text()
Ejemplo n.º 26
0
 def draw(self):
     scene.background(0.00, 0.05, 0.20)
     super(MyScene, self).draw()
     s = 45 if self.size.w > 100 else 7
     scene.text('Welcome to\nMyMagic8Ball\n\n\n', 'Futura', s, *self.center)
     t = 100 if self.size.w > 100 else 7
     scene.text('\n🎱', 'Futura', t, *self.center)
     s = 27 if self.size.w > 100 else 7
     scene.text('\n\n\n\n\n\n\n\n\n\n\n\nBy: Adedayo Ogunnoiki', 'Futura', s, *self.center)
Ejemplo n.º 27
0
    def draw(self):
        scene.background(0, 0, 0)

        for button in self.buttons:
            name, title, value, position, action = button
            if action:  # toggles have action == None
                self.draw_button(title, position)
            else:
                self.draw_toggle(title, self.data[name], position)
Ejemplo n.º 28
0
    def draw(self):
        scene.background(0, 0, 0)

        for button in self.buttons:
            name, title, value, position, action = button
            if action:  # toggles have action == None
                self.draw_button(title, position)
            else:
                self.draw_toggle(title, self.data[name], position)
Ejemplo n.º 29
0
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     if not self.frame_count % 180:  # once every three seconds
         if self.photo_layer.image:  # unload old image to save RAM
             scene.unload_image(self.photo_layer.image)
         self.photo_layer.image = get_random_photo()
     self.frame_count += 1
Ejemplo n.º 30
0
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     if not self.frame_count % 180:  # once every three seconds
         if self.photo_layer.image:  # unload old image to save RAM
             scene.unload_image(self.photo_layer.image)
         self.photo_layer.image = get_random_photo()
     self.frame_count += 1
Ejemplo n.º 31
0
 def draw(self):
     scene.background(0, 0, 0)
     
     for b in self.buttons:
         # use '== True' here to avoid catching values like "NA"
         if b[2] == True:
             self.draw_toggle(b[1], self.data[b[0]], b[3])
         elif b[2] in (False, 'NA'):
             self.draw_button(b[1], b[3])
Ejemplo n.º 32
0
 def draw(self):
     scene.background(*color('black'))
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.tint(*self.current_color())  # draw the user's text
     scene.text(self.text, self.current_font(), self.fontsize,
                self.position[0], self.position[1]+self.btn_height, 5)   # add ...position[1]+self.btn_height
     scene.fill(*color('white'))   # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
Ejemplo n.º 33
0
 def draw(self):
     scene.background(*color('black'))
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.tint(*self.current_color())  # draw the user's text
     scene.text(self.text, self.current_font(), self.fontsize,
                self.position[0], self.position[1] + self.btn_height,
                5)  # add ...position[1]+self.btn_height
     scene.fill(*color('white'))  # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
Ejemplo n.º 34
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)
Ejemplo n.º 35
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)
Ejemplo n.º 36
0
 def draw(self):
     scene.background(0, 0.5, 1)
     self.player.draw()
     self.player.keep_in_bounds(self.bounds)
     player_frame = self.player.frame
     for enemy in self.enemies:
         enemy.draw()
         enemy.keep_in_bounds(self.bounds)
         if (self.player.is_moving
         and enemy.frame.intersects(player_frame)):
             sound.play_effect('arcade:Explosion_1')
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     # draw the text
     name_text = animal_name(self.current_animal.image)
     score_text = "Score: %d" % self.score
     w, h = self.size
     y = h - 100
     scene.text(name_text, font_name=font_name, font_size=72.0, x=w * 0.5, y=y, alignment=5)
     scene.text(score_text, font_name=font_name, font_size=24.0, x=w / 20, y=y, alignment=6)
Ejemplo n.º 38
0
 def draw(self):
     scene.background(0, 0.5, 1)
     self.player.draw()
     self.player.keep_in_bounds(self.bounds)
     player_frame = self.player.frame
     for enemy in self.enemies:
         enemy.draw()
         enemy.keep_in_bounds(self.bounds)
         if (self.player.is_moving
                 and enemy.frame.intersects(player_frame)):
             sound.play_effect('arcade:Explosion_1')
Ejemplo n.º 39
0
 def draw(self):
     scene.background(0, 0, 0)
     if self.touch:
         scene.fill('red')
         loc = self.touch.location
         scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
         scene.text('{}, {}'.format(*loc), 'Futura', 20, 100, 50)
         points.append(loc)  # is it be useful to check if loc == prev_loc?
     elif points:
         scene.fill('blue')
         for loc in points:
             scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
Ejemplo n.º 40
0
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1, 1, 1)
     scene.stroke(*self.stroke_color)
     scene.stroke_weight(4)
     scene.rect(0, 180, 320, 15)
     scene.rect(0, 290, 320, 15)
     scene.rect(92, 87, 15, 310)
     scene.rect(208, 87, 15, 310)
     for l in self.lines:
         scene.line(*l)
Ejemplo n.º 41
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

    # 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])
Ejemplo n.º 42
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1)
     x = screen_width / 2
     s_y = screen_height / 2 + 100
     d_y = s_y - 30
     l_y = d_y - 75
     scene.tint(0.32645,0.28306,0.93492)
     scene.text('PhantomChess version {}'.format(version), x=x, y=s_y, font_size=20.0)
     scene.tint(1, 1, 1)
     if debug:
         scene.text('Debugger set to level {}'.format(debug), x=x, y=d_y)
     for i, line in enumerate(short().splitlines()):
         scene.text(line, x=x, y=l_y - (i*20))
Ejemplo n.º 43
0
 def draw(self):
     ui.background(*COLORS["mbg"])
     ui.fill(*COLORS["bg"])
     ui.rect(*self.bounds)
     ui.fill(*COLORS["walls"])
     for wall in self.walls:
         self.draw_cell(*wall)
     self.apple.draw(self)
     self.snake.update(self)
     self.snake.draw(self)
     sx, sy = self.scorepos
     ui.text("Score: %d" % self.score, "Monofur", 30, sx, sy, 9)
     if self.snake.dead:
         self.draw_text_center("Game Over")
Ejemplo n.º 44
0
 def draw(self):
     if not self.frameCount % framesPerSound:
         try:
             self.soundName = next(getSoundName)
             #sound.load_effect(self.soundName)
             sound.play_effect(self.soundName)
         except StopIteration:
             self.soundName = None
     self.frameCount += 1
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     if self.soundName:
         x, y = self.bounds.center()
         scene.text(self.soundName, x=x, y=y, font_size=self.fontSize)
Ejemplo n.º 45
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1)
     x, y = self.bounds.center()
     #print(self.bounds)
     s_y = y + 100
     d_y = s_y - 30
     l_y = s_y - 75
     scene.tint(0.32645, 0.28306, 0.93492)
     scene.text('PhantomChess version {}'.format(C.version), x=x, y=s_y, font_size=20.0)
     scene.tint(1, 1, 1)
     if C.debug:
         scene.text('Debugger set to level {}'.format(C.debug), x=x, y=d_y)
     for i, line in enumerate(short().splitlines()):
         scene.text(line, x=x, y=l_y - (i*20))
Ejemplo n.º 46
0
 def draw(self):
     if not self.frameCount % framesPerSound:
         try:
             self.soundName = getSoundName.next()
             #sound.load_effect(self.soundName)
             sound.play_effect(self.soundName)
         except StopIteration:
             self.soundName = None
     self.frameCount += 1
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     if self.soundName:
         x, y = self.bounds.center()
         scene.text(self.soundName, x=x, y=y, font_size=self.fontSize)
Ejemplo n.º 47
0
	def draw(self):
		self.frameCount += 1
		if self.frameCount % 80 == 0:
			try:
				fontName = getFontName.next()
				print(fontName)
				self.add_layer(FontSampleLayer(fontName))
			except StopIteration:
				pass
		scene.background(0, 0, 0)
		self.root_layer.update(self.dt)
		self.root_layer.draw()
		for theLayer in self.root_layer.sublayers:
			if isinstance(theLayer, FontSampleLayer):
				theLayer.move()
Ejemplo n.º 48
0
	def draw(self):
		x,y,z = motion.get_attitude() if use_motion else scene.gravity()
		r,g,b = abs(x), abs(y), abs(z)
		scene.background(r, g, b)
		scene.tint(1-r, 1-g, 1-b)
		scene.text(answer.format(x, y, z), font_size=45, x=self.center.x, y=self.center.y)
		for p in self.particles:
			p.update()
			p.draw()
		for t in self.touches.values():
			for p in self.particles:
				tx, ty = t.location.x, t.location.y
				d = (p.x - tx)*(p.x - tx)+(p.y - ty)*(p.y - ty)
				d = sqrt(d)
				p.vx = p.vx - 5/d*(p.x-tx)
				p.vy = p.vy - 5/d*(p.y-ty)
				p.colour = Color(random.random(), random.random(), random.random())
Ejemplo n.º 49
0
 def draw(self):
     if not self.frameCount % (imageWidth / 2):
         try:
             self.addMovingImage(getImageName.next())
         except StopIteration:
             self.imageName = None
             #for theLayer in self.root_layer.sublayers:
             #    if isinstance(theLayer, MovingImage):
             #        theLayer.drop()
     self.frameCount += 1
     scene.background(0, 0, 0)
     if self.imageName:
         scene.text(self.imageName, alignment=9)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     for theLayer in self.root_layer.sublayers:
         if isinstance(theLayer, MovingImage):
             theLayer.move()
Ejemplo n.º 50
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1)
     x, y = self.bounds.center()
     #print(self.bounds)
     s_y = y + 100
     d_y = s_y - 30
     l_y = s_y - 75
     scene.tint(0.32645, 0.28306, 0.93492)
     scene.text('PhantomChess version {}'.format(C.version),
                x=x,
                y=s_y,
                font_size=20.0)
     scene.tint(1, 1, 1)
     if C.debug:
         scene.text('Debugger set to level {}'.format(C.debug), x=x, y=d_y)
     for i, line in enumerate(short().splitlines()):
         scene.text(line, x=x, y=l_y - (i * 20))
Ejemplo n.º 51
0
 def draw(self):
     x, y, z = motion.get_attitude() if use_motion else scene.gravity()
     r, g, b = abs(x), abs(y), abs(z)
     scene.background(r, g, b)
     scene.tint(1 - r, 1 - g, 1 - b)
     scene.text(answer.format(x, y, z),
                font_size=45,
                x=self.center.x,
                y=self.center.y)
     for p in self.particles:
         p.update()
         p.draw()
     for t in self.touches.values():
         for p in self.particles:
             tx, ty = t.location.x, t.location.y
             d = (p.x - tx) * (p.x - tx) + (p.y - ty) * (p.y - ty)
             d = sqrt(d)
             p.vx = p.vx - 5 / d * (p.x - tx)
             p.vy = p.vy - 5 / d * (p.y - ty)
             p.colour = Color(random.random(), random.random(),
                              random.random())
Ejemplo n.º 52
0
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     # draw the text
     name_text = animal_name(self.current_animal.image)
     score_text = 'Score: %d' % self.score
     w, h = self.size
     y = h - 100
     scene.text(name_text,
                font_name=font_name,
                font_size=72.0,
                x=w * 0.5,
                y=y,
                alignment=5)
     scene.text(score_text,
                font_name=font_name,
                font_size=24.0,
                x=w / 20,
                y=y,
                alignment=6)
Ejemplo n.º 53
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 = 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])
Ejemplo n.º 55
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)
Ejemplo n.º 56
0
 def draw(self):
     self.game_loop()
     background(0.40, 0.80, 1.00)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     self.draw_text()
Ejemplo n.º 57
0
 def draw(self):
     scene.background(0.7, 0.7, 0.7)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
Ejemplo n.º 58
0
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1, 1, 1)  # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
Ejemplo n.º 59
0
 def draw(self):
     scene.background(0.7, 0.7, 0.7)  # grey
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.text(self.text, font_size=40, x=self.center.x, y=self.center.y)