def paint_pixel(self, pos, color=Color(0, 0, 0)): x, y = self._map_point(*pos) self._screen.set_at(x, y, rgb(color))
def linecolor(self, value): if value is None: self._linecolor = None else: self._color = Color(value)
Re-define os objetos do módulo FGAme.physics e adiciona propriades extras de renderização """ from PIL import ImageChops from FGAme import conf from FGAme import draw from FGAme import physics from FGAme.draw import Color, colorproperty, Image from FGAme.mathtools import asvector from FGAme.utils import lazy __all__ = [ 'AABB', 'Circle', 'Poly', 'RegularPoly', 'Rectangle', ] black = Color('black') class Body(physics.Body): def __init__(self, *args, **kwargs): # Visualization parameters image = { 'image': kwargs.pop('image', None) } for k in list(kwargs): if k.startswith('image_'): image[k] = kwargs.pop(k) self.color = kwargs.pop('color', black) self.linecolor = kwargs.pop('linecolor', None) self.linewidth = kwargs.pop('linewidth', 1) self.visible = kwargs.pop('visible', True)
import string import pygame from FGAme import conf from FGAme.draw import Color, rgb from FGAme.input import Input from FGAme.mainloop import MainLoop from FGAme.screen import Canvas pygame.init() black = Color('black') white = Color('white') class PyGameCanvas(Canvas): _pg_draw_circle = pygame.draw.circle _pg_draw_rect = pygame.draw.rect _pg_draw_poly = pygame.draw.polygon _pg_segment = pygame.draw.line def show(self): self._screen = pygame.display.set_mode((self.width, self.height)) super(PyGameCanvas, self).show() def get_pygame_screen(self): return self._screen def flip(self): pygame.display.update()
def paint_pixel(self, pos, color=Color(0, 0, 0)): x, y = self._map_point(*pos) # TODO: talvez use pygame.display.get_surface() para obter a tela # correta # http://stackoverflow.com/questions/10354638/pygame-draw-single-pixel self._screen.set_at(x, y, rgb(color))
def paint_line(self, pt1, pt2, color=Color(0, 0, 0), solid=True): raise NotImplementedError
def paint_rect(self, rect, color=Color(0, 0, 0), solid=True): x, y, dx, dy = rect x, y = self._map_point((x, y + dy)) pygame.draw.rect(self._screen, rgb(color), (x, y, dx, dy))
def paint_poly(self, points, color=Color(0, 0, 0), solid=True): points = [self._map_point(pt) for pt in points] pygame.draw.polygon(self._screen, rgb(color), points)
def paint_circle(self, radius, pos, color=Color(0, 0, 0), solid=True): x, y = pos.trunc() self._circle(self._screen, rgb(color), (x, self.height - y), int(radius))