def poly_func(): theta = 0 y_offset = 0 if n == 3: y_offset = -5 if n % 2 == 1: theta = -math.pi/n/2 poly = draw._concat(draw._iter_ngon(x+w/2,y+h/2+y_offset,(w-10)/2,n,theta)) graphics.set_color(1,1,1,1) draw.polygon(poly) graphics.set_color(0,0,0,1) graphics.set_line_width(1) draw.line_loop(poly)
def doodle(self, dt=0): if self.fire: bs_scaled = int(1.5 + (graphics.brush_size - 1) * 0.2) spread = 10 * bs_scaled graphics.set_color(*graphics.get_line_color()) for i in xrange(0, spread*6, max(spread/10, 1)): xscale = min(1.0, 0.3+0.7*i/(spread)) xscale = min(xscale, 0.2+0.8*(spread*6-i)/(spread*6)) fx = self.x + random.randint(-spread, spread)*xscale fy = self.y + -spread + i size = (5.0-5.0*(i/float(spread*6))) * bs_scaled // 2 draw.ellipse(fx-size, fy-size, fx+size, fy+size) #draw.points((fx, fy)) graphics.set_color(*graphics.get_fill_color()) for i in xrange(0, spread*2, max(spread/10, 1)): xscale = min(0.3 + 0.7*i/spread, 1) fx = self.x + random.randint(-spread, spread)*xscale fy = self.y + -spread + i size = (5.0-5.0*(i/float(spread*4))) * bs_scaled // 2 draw.ellipse(fx-size, fy-size, fx+size, fy+size) #draw.points((fx, fy)) else: graphics.set_line_width(graphics.brush_size/2) colors = [] points = [self.make_point() for i in xrange(self.dots_per_frame)] if not self.hollow and not self.variable_size: draw.points( sum(points,[]), draw._concat([self.get_color() for i in xrange(self.dots_per_frame)]) ) else: for i in xrange(len(points)): x, y = points[i] if self.variable_size: rad = max( random.random()*graphics.brush_size/2.0 + graphics.brush_size/2.0, 4 ) else: rad = graphics.brush_size/2.0 graphics.set_color(*self.get_color()) if random.random() < self.chance: if self.hollow: graphics.set_line_width(graphics.brush_size*0.2) draw.ellipse_outline(x-rad,y-rad,x+rad,y+rad) else: draw.ellipse(x-rad,y-rad,x+rad,y+rad)