def main(args): from render.render import Render from dddUtils.ioOBJ import load from numpy import array data = load(args.fn) size = args.size one = 1.0 / size vertices = data['vertices'][:, :2] back = [1, 1, 1, 1] front = [0, 0, 0, args.alpha] rad = args.rad * one vertices -= get_mid(vertices) vertices *= args.scale vertices += array([[0.5, 0.5]]) render = Render(size, back, front) render.ctx.set_source_rgba(*front) render.ctx.set_line_width(one) out = ''.join(args.fn.split('.')[:-1]) + '.png' for vv in vertices: render.circle(vv[0], vv[1], rad, fill=True) render.write_to_png(out) return
def main(args): from render.render import Render from dddUtils.ioOBJ import load from numpy import array data = load(args.fn) size = args.size one = 1.0/size vertices = data['vertices'][:,:2] back = [1,1,1,1] front = [0,0,0,args.alpha] rad = args.rad*one vertices -= get_mid(vertices) vertices *= args.scale vertices += array([[0.5,0.5]]) render = Render(size, back, front) render.ctx.set_source_rgba(*front) render.ctx.set_line_width(one) out = ''.join(args.fn.split('.')[:-1])+'.png' for vv in vertices: render.circle(vv[0], vv[1], rad, fill=True) render.write_to_png(out) return
class EntityPulseExplosion(Entity): color = (3, 169, 244) def __init__(self, game, x, y, max_radius=None): super().__init__(game, BoundBox(Vector2(x, y), Vector2(x, y))) self.radius = 0 self.radius_speed = 0 if max_radius is None: max_radius = math.hypot(game.width / 2, game.height / 2) self.max_radius = max_radius self.fade_tick = 30 self.screen = pygame.Surface((game.width, game.height)) self.screen.set_colorkey((240, 240, 240)) self.renderer = Render(self.screen) def update(self, events): super().update(events) if self.radius < self.max_radius: self.radius_speed += 1 self.radius += self.radius_speed else: self.fade_tick -= 1 if self.fade_tick < 0: self.set_dead() def render(self, render): self.renderer.fill((240, 240, 240)) self.screen.set_alpha(self.fade_tick / 30 * 255) self.renderer.circle(self, self.radius, self.color) render.screen.blit(self.screen, (0, 0))