def draw_spiral_weave(self, x, y, angle, ds): if self.spiral: self.spiral_angle += 4.7 * ds * self.freq_scale if self.weave: self.spiral_angle = angle+math.pi/2 self.spiral_radius = max(graphics.brush_size,5)*math.sin(self.iteration*self.freq_scale) x_add = self.spiral_radius*math.cos(self.spiral_angle) y_add = self.spiral_radius*math.sin(self.spiral_angle) x1 = x + x_add y1 = y + y_add x2 = x - x_add y2 = y - y_add self.last_color_1 = graphics.get_line_color() self.last_color_2 = graphics.get_fill_color() graphics.set_color(color=self.last_color_1) self.draw_point(x1,y1) graphics.set_line_width(graphics.brush_size) draw.line(x1, y1, self.lastx1, self.lasty1) graphics.set_color(color=self.last_color_2) self.draw_point(x2,y2) graphics.set_line_width(graphics.brush_size) draw.line(x2, y2, self.lastx2, self.lasty2) self.lastx1, self.lasty1 = x1, y1 self.lastx2, self.lasty2 = x2, y2
def color_function(self, x, y): distance = math.sqrt((self.start_x-x)*(self.start_x-x)+(self.start_y-y)*(self.start_y-y)) if graphics.fill_rainbow(): return graphics.rainbow_colors[int(distance*0.5 / graphics.user_line_size % len(graphics.rainbow_colors))] if distance % (graphics.user_line_size*2) < graphics.user_line_size: return graphics.get_fill_color() if graphics.line_rainbow(): return graphics.rainbow_colors[(int((x+y)/10)) % len(graphics.rainbow_colors)] return graphics.get_line_color()
def color_function(self, x, y): denom = int(graphics.user_line_size)*2 if (x/denom + y/denom) % 2 == 0: if graphics.fill_rainbow(): return graphics.rainbow_colors[(int(x/denom)+int(y/denom)) % len(graphics.rainbow_colors)] return graphics.get_fill_color() if graphics.line_rainbow(): return graphics.rainbow_colors[(int(x/denom)+int(y/denom)) % len(graphics.rainbow_colors)] return graphics.get_line_color()
def color_function(self, x, y): lightness = random.random()*0.4-0.2 fill_color = graphics.get_fill_color() return [ fill_color[0]+lightness, fill_color[1]+lightness, fill_color[2]+lightness, fill_color[3] ]
def get_color(self): which_color = 1 if self.dual_color: which_color = random.randint(0,1) if which_color: color = graphics.get_line_color() else: color = graphics.get_fill_color() if self.noisy: lightness = random.random()*0.4-0.2 return [ color[0]+lightness, color[1]+lightness, color[2]+lightness, color[3] ] else: return color
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)
def color_function(self, x, y): return graphics.get_fill_color()
def start_drawing(self, x, y): self.x, self.y = x, y self.fill_colors = [] for i in range(self.sides+1): self.fill_colors.extend(graphics.get_fill_color()) self.line_color = graphics.get_line_color()
def start_drawing(self, x, y): self.x1, self.y1 = x, y self.fill_color = graphics.get_fill_color() self.line_color = graphics.get_line_color()