コード例 #1
0
    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)
コード例 #2
0
ファイル: tilting_color.py プロジェクト: cclauss/Pythonista-4
 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)
コード例 #3
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)
コード例 #4
0
ファイル: photo_text.py プロジェクト: cclauss/photo_text
 def draw(self):
     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], 5)
     scene.fill(*color('white'))   # watch+battery -> white background
     scene.rect(0, 748, 1024, 20)  # watch+battery
コード例 #5
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)
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
 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)
コード例 #9
0
ファイル: screen_promote.py プロジェクト: c0ns0le/Pythonista
 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)
コード例 #10
0
ファイル: photo_text.py プロジェクト: c0ns0le/Pythonista
 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
コード例 #11
0
ファイル: graphics.py プロジェクト: Vik2015/gamepie
def write(text, x, y):
    scene.text(
        text,
        __settings__.fontname,
        __settings__.fontsize,
        x,
        getHeight() - y,
        3
    )
コード例 #12
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)
コード例 #13
0
 def draw_toggle(name, curval, pos):
     name = str(name)
     val = str(curval)
     x, y = pos.x, pos.y
     w = h = scale_factor
     mid = Coord(x + (w / 2), y + (h / 2))
     label = Coord(mid.x, mid.y + 10)
     state = Coord(mid.x, mid.y - 10)
     scene.text(name, x=label.x, y=label.y)
     scene.text(val, x=state.x, y=state.y)
コード例 #14
0
ファイル: photo_text.py プロジェクト: itdvl/photo_text
 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
コード例 #15
0
ファイル: screen_options.py プロジェクト: c0ns0le/Pythonista
 def draw_toggle(name, curval, pos):
     name = str(name)
     val = str(curval)
     x, y = pos.x, pos.y
     w = h = scale_factor
     mid = Coord(x + (w / 2), y + (h / 2))
     label = Coord(mid.x, mid.y + 10)
     state = Coord(mid.x, mid.y - 10)
     scene.text(name, x=label.x, y=label.y)
     scene.text(val, x=state.x, y=state.y)
コード例 #16
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)
コード例 #17
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)
コード例 #18
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)
コード例 #19
0
ファイル: touchpad.py プロジェクト: NuuJoy/nuuJoyLib
 def scene_draw(self):
     if self.touch:
         if (self.magnitude < 0.99 * self.max_length):
             scene.stroke_weight(self.color['normal']['weight'])
             scene.stroke(*self.color['normal']['stroke'])
             scene.fill(*self.color['normal']['fill'])
         else:
             scene.stroke_weight(self.color['highlight']['weight'])
             scene.stroke(*self.color['highlight']['stroke'])
             scene.fill(*self.color['highlight']['fill'])
         scene.ellipse(self.boundary['left'], self.boundary['lower'],
                       2.0 * self.max_length, 2.0 * self.max_length)
         scene.line(self.ref_x, self.ref_y, self.clamp_x, self.clamp_y)
         scene.text(self.label, x=self.ref_x, y=self.ref_y)
コード例 #20
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])
コード例 #21
0
ファイル: snake.py プロジェクト: cclauss/snake-ios
 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")
コード例 #22
0
ファイル: sounder.py プロジェクト: wuxi20/Pythonista
 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)
コード例 #23
0
ファイル: sounder.py プロジェクト: c0ns0le/Pythonista
 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)
コード例 #24
0
ファイル: touchpad.py プロジェクト: NuuJoy/nuuJoyLib
 def scene_draw(self):
     if self.touch:
         if not (int(self.x) or int(self.y)):
             scene.stroke_weight(self.color['normal']['weight'])
             scene.stroke(*self.color['normal']['stroke'])
             scene.fill(*self.color['normal']['fill'])
         else:
             scene.stroke_weight(self.color['highlight']['weight'])
             scene.stroke(*self.color['highlight']['stroke'])
             scene.fill(*self.color['highlight']['fill'])
         scene.rect(self.boundary['left'], self.boundary['lower'],
                    2.0 * self.max_length, 2.0 * self.max_length)
         scene.line(self.clamp_x, self.boundary['upper'], self.clamp_x,
                    self.boundary['lower'])
         scene.line(self.boundary['left'], self.clamp_y,
                    self.boundary['right'], self.clamp_y)
         scene.text(self.label, x=self.ref_x, y=self.ref_y)
コード例 #25
0
ファイル: Magic8Ball.py プロジェクト: cclauss/Magic8Ball
	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())
コード例 #26
0
ファイル: imageCongaLine.py プロジェクト: c0ns0le/Pythonista
 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()
コード例 #27
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()
コード例 #28
0
ファイル: touchpad.py プロジェクト: NuuJoy/nuuJoyLib
 def scene_draw(self):
     if self.touch:
         scene.stroke_weight(self.color['highlight']['weight'])
         scene.stroke(*self.color['highlight']['stroke'])
         scene.fill(*self.color['highlight']['fill'])
         scene.line(self.touch.location.x, self.respond_area['y1'],
                    self.touch.location.x, self.respond_area['y2'])
         scene.line(self.respond_area['x1'], self.touch.location.y,
                    self.respond_area['x2'], self.touch.location.y)
     else:
         scene.stroke_weight(self.color['normal']['weight'])
         scene.stroke(*self.color['normal']['stroke'])
         scene.fill(*self.color['normal']['fill'])
     scene.rect(self.respond_area['x1'], self.respond_area['y1'],
                self.respond_area['x2'], self.respond_area['y2'])
     scene.text(self.label,
                x=self.respond_area['x1'],
                y=self.respond_area['y1'])
コード例 #29
0
ファイル: button.py プロジェクト: Illusion1037/Pythonista
	def draw(self):
		self.prevmode = self.mode
		self.mode = 'off'
		for touch in touches:
			if touch.location in scene.Rect(*self.rect):
				self.mode = 'on'
			elif self.prevmode == 'on':
				self.mode = 'up'
				
		if self.mode == 'on':
			scene.fill(*self.altcolor)
			scene.tint(*self.alttxtcolor)
			scene.stroke(*self.altbordrcolor)
		else:
			scene.fill(*self.color)
			scene.tint(*self.txtcolor)
			scene.stroke(*self.bordrcolor)
		
		scene.stroke_weight(self.bordrw)
		scene.rect(*self.rect)
		scene.text(self.text, self.font, self.fontsize, self.rect[0] + self.rect[2] / 2, self.rect[1] + self.rect[3] / 2)
コード例 #30
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)
コード例 #31
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())
コード例 #32
0
ファイル: touchpad.py プロジェクト: NuuJoy/nuuJoyLib
 def scene_draw(self):
     if not (self.touch or (self.toggle)):
         scene.stroke_weight(self.color['normal']['weight'])
         scene.stroke(*self.color['normal']['stroke'])
         scene.fill(*self.color['normal']['fill'])
     else:
         scene.stroke_weight(self.color['highlight']['weight'])
         scene.stroke(*self.color['highlight']['stroke'])
         scene.fill(*self.color['highlight']['fill'])
     scene.rect(self.respond_area['x1'] * self.scrnWdth,
                self.respond_area['y1'] * self.scrnHght,
                (self.respond_area['x2'] - self.respond_area['x1']) *
                self.scrnWdth,
                (self.respond_area['y2'] - self.respond_area['y1']) *
                self.scrnHght)
     scene.text(
         self.label,
         x=0.5 * (self.respond_area['x1'] + self.respond_area['x2']) *
         self.scrnWdth,
         y=0.5 * (self.respond_area['y1'] + self.respond_area['y2']) *
         self.scrnHght,
     )
コード例 #33
0
    def draw(self):
        self.prevmode = self.mode
        self.mode = 'off'
        for touch in touches:
            if touch.location in scene.Rect(*self.rect):
                self.mode = 'on'
            elif self.prevmode == 'on':
                self.mode = 'up'

        if self.mode == 'on':
            scene.fill(*self.altcolor)
            scene.tint(*self.alttxtcolor)
            scene.stroke(*self.altbordrcolor)
        else:
            scene.fill(*self.color)
            scene.tint(*self.txtcolor)
            scene.stroke(*self.bordrcolor)

        scene.stroke_weight(self.bordrw)
        scene.rect(*self.rect)
        scene.text(self.text, self.font, self.fontsize,
                   self.rect[0] + self.rect[2] / 2,
                   self.rect[1] + self.rect[3] / 2)
コード例 #34
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)
コード例 #35
0
ファイル: screen_loading.py プロジェクト: c0ns0le/Pythonista
 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))
コード例 #36
0
ファイル: screen_loading.py プロジェクト: c0ns0le/Pythonista
 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))
コード例 #37
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))
コード例 #38
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])
コード例 #39
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)
コード例 #40
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 = 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])
コード例 #41
0
 def draw_button(name, pos):
     name = str(name)
     x, y = pos.x, pos.y
     w = h = scale_factor
     mid = Coord(x + (w / 2), y + (h / 2))
     scene.text(name, x=mid.x, y=mid.y)
コード例 #42
0
 def draw(self):
     scene.background(0, 0, 0)
     msg = fmt.format(self.event_name, (self.event_date - datetime.date.today()).days)
     scene.text(msg, 'Futura', self.font_size, *self.center)
コード例 #43
0
 def draw(self):
     scene.background(0, 0, 0)
     msg = fmt.format(self.event_name,
                      (self.event_date - datetime.date.today()).days)
     scene.text(msg, 'Futura', self.font_size, *self.center)
コード例 #44
0
ファイル: CloudJump2.py プロジェクト: tjferry14/Cloud-Jump-2
def tinted_text(s, x, y, tint_color=Color(0, 0, 1, 0)):
    tint(0, 0, 0)
    text(s, GAME_FONT, 48, x + 2, y - 2)
    tint(*tint_color)
    text(s, GAME_FONT, 48, x, y)
コード例 #45
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)

    # 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])
コード例 #46
0
ファイル: CloudJump2.py プロジェクト: jsbain/Cloud-Jump-2
def tinted_text(s, x, y, tint_color = scene.Color(0, 0, 1)):
    scene.tint(0, 0, 0)
    scene.text(s, GAME_FONT, 48, x + 2, y - 2)
    scene.tint(*tint_color)
    scene.text(s, GAME_FONT, 48, x, y)
コード例 #47
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.textPosition[0], self.textPosition[1], 5)
コード例 #48
0
ファイル: KeyboardHack.py プロジェクト: cclauss/Pythonista-4
 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)
コード例 #49
0
ファイル: screen_main.py プロジェクト: c0ns0le/Pythonista
 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)
コード例 #50
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)
コード例 #51
0
def tinted_text(s, x, y, tint_color = scene.Color(0, 0, 1)):
    font_name = 'AppleSDGothicNeo-Bold'
    scene.tint(0, 0, 0)
    scene.text(s, font_name, 48, x + 2, y - 2)
    scene.tint(*tint_color)
    scene.text(s, font_name, 48, x, y)
コード例 #52
0
def tinted_text(s, x, y, tint_color=Color(0, 0, 1, 0)):
    tint(0, 0, 0)
    text(s, GAME_FONT, 48, x + 2, y - 2)
    tint(*tint_color)
    text(s, GAME_FONT, 48, x, y)
コード例 #53
0
ファイル: screen_options.py プロジェクト: c0ns0le/Pythonista
 def draw_button(name, pos):
     name = str(name)
     x, y = pos.x, pos.y
     w = h = scale_factor
     mid = Coord(x + (w / 2), y + (h / 2))
     scene.text(name, x=mid.x, y=mid.y)