Example #1
0
 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
Example #2
0
 def draw_shape_rect(self):
     graphics.enable_line_stipple()
     graphics.set_line_width(1.0)
     graphics.set_color(color=graphics.get_line_color())
     draw.rect_outline(
         self.img_x+1, self.img_y+1, self.img_x+abs(self.w)-1, self.img_y+abs(self.h)-1
     )
     graphics.disable_line_stipple()
Example #3
0
 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()
Example #4
0
 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()
Example #5
0
 def start_drawing(self, x, y):
     tool.ChaserBrush.start_drawing(self,x,y)
     self.lastx1, self.lasty1 = x, y
     self.lastx2, self.lasty2 = x, y
     self.iteration = 0.0
     self.spiral_radius = max(graphics.brush_size,5)
     self.freq_scale = 1.0/max(graphics.brush_size*2,10.0)
     self.speed = graphics.brush_size*7.0/38.0 + 1.76
     self.last_color_1 = graphics.get_line_color()
Example #6
0
 def draw_railroad_dna(self, x, y, angle, ds):
     self.spiral_angle = angle+math.pi/2
     if self.railroad:
         self.spiral_radius = max(graphics.brush_size*2,10)
     else:
         self.spiral_radius = max(graphics.brush_size*2,10)
         self.spiral_radius *= 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_line_color()
     graphics.set_color(color=self.last_color_1)
     self.draw_point(x1,y1,0.6)
     graphics.set_line_width(graphics.brush_size*0.6)
     draw.line(x1, y1, self.lastx1, self.lasty1)
     graphics.set_color(color=self.last_color_2)
     self.draw_point(x2,y2,0.6)
     graphics.set_line_width(graphics.brush_size*0.6)
     draw.line(x2, y2, self.lastx2, self.lasty2)
     self.state_flip += ds
     if self.railroad:
         x_add *= 1.3
         y_add *= 1.3
     if self.state_flip > graphics.brush_size * 2:
         rx1 = x + x_add
         ry1 = y + y_add
         rx2 = x - x_add
         ry2 = y - y_add
         self.state_flip = 0
         if self.railroad:
             draw.line(rx1,ry1,rx2,ry2)
         else:
             graphics.set_color(color=random.choice(graphics.rainbow_colors))
             draw.line(x,y,rx1,ry1)
             graphics.set_color(color=random.choice(graphics.rainbow_colors))
             draw.line(x,y,rx2,ry2)
     self.lastx1, self.lasty1 = x1, y1
     self.lastx2, self.lasty2 = x2, y2
Example #7
0
 def keep_drawing(self, x, y, dx, dy):
     ds = math.sqrt(dx*dx+dy*dy)
     self.iteration += ds
     if self.calligraphy:
         self.draw_calligraphy(x,y,ds)
     elif self.variable:
         self.draw_variable(x,y,ds)
     else:
         self.last_color_1 = graphics.get_line_color()
         graphics.set_color(color=self.last_color_1)
         self.draw_point(x,y)
         graphics.set_line_width(graphics.brush_size)
         draw.line(x, y, self.lastx, self.lasty)
     self.lastx, self.lasty = x, y
Example #8
0
 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
Example #9
0
 def draw_calligraphy(self, x, y, ds):
     brush_mult = max(1.5-min(ds/20.0,1.2),0)
     brush_mult = (self.last_brush_mult+brush_mult)/2
     self.last_brush_mult = brush_mult
     radius = max(graphics.brush_size,3) * brush_mult
     x_add = radius*self.x_mult
     y_add = radius*self.y_mult
     x1 = x + x_add
     y1 = y + y_add
     x2 = x - x_add
     y2 = y - y_add
     graphics.set_color(*graphics.get_line_color())
     draw.quad((x1,y1,self.lastx1,self.lasty1,self.lastx2,self.lasty2,x2,y2))
     self.lastx1, self.lasty1 = x1, y1
     self.lastx2, self.lasty2 = x2, y2
Example #10
0
 def start_drawing(self, x, y):
     self.lastx, self.lasty = x, y
     self.lastx1, self.lasty1 = x, y
     self.lastx2, self.lasty2 = x, y
     self.iteration = 0
     if self.calligraphy:
         self.x_mult = math.cos(math.pi/4)
         self.y_mult = math.sin(math.pi/4)
         self.last_brush_mult = 1.5
     elif self.variable:
         self.last_brush_mult = 0.0
     else:
         self.last_color_1 = graphics.get_line_color()
         graphics.set_color(color=self.last_color_1)
         graphics.set_line_width(graphics.brush_size)
         if graphics.brush_size > 1: draw.points((x,y))
Example #11
0
 def draw_shape_ellipse(self):
     graphics.enable_line_stipple()
     graphics.set_line_width(1.0)
     #graphics.set_color(0,0,0,1)
     graphics.set_color(color=graphics.get_line_color())
     old_line_size = graphics.user_line_size
     def temp1():
         graphics.user_line_size = 1.0
     def temp2():
         graphics.user_line_size = old_line_size
     graphics.call_twice(temp1)
     draw.ellipse_outline(
         self.img_x+1, self.img_y+1, self.img_x+abs(self.w)-1, self.img_y+abs(self.h)-1
     )
     graphics.disable_line_stipple()
     graphics.call_twice(temp2)
Example #12
0
 def draw_other(self, x, y, angle, ds):
     graphics.set_color(color=self.last_color_1)
     self.state_flip += ds
     if self.state_flip > graphics.brush_size*2:
         self.state_flip = 0
         self.dot_on = not self.dot_on
         if not self.dot_on:
             self.last_color_1 = graphics.get_line_color()
     if self.dot_on or not self.dotted:
         if self.state_flip == 0:
             self.draw_point(self.lastx1, self.lasty1)
         self.draw_point(x,y)
         graphics.set_line_width(graphics.brush_size)
         draw.line(x, y, self.lastx1, self.lasty1)
     if self.arrow_end:
         self.arrow_angle = self.arrow_angle*0.5 + angle*0.5
     self.lastx1, self.lasty1 = x, y
Example #13
0
 def draw_variable(self, x, y, ds):
     brush_mult = max(1.5-min(ds/20.0,1.2),0)
     brush_mult = (self.last_brush_mult+brush_mult)/2.0
     radius = max(graphics.brush_size,3)
     angle = math.atan2(y-self.lasty,x-self.lastx)+math.pi/2.0
     x_add1 = radius*math.cos(angle)*brush_mult*0.96
     y_add1 = radius*math.sin(angle)*brush_mult*0.96
     x_add2 = radius*math.cos(angle)*self.last_brush_mult*0.96
     y_add2 = radius*math.sin(angle)*self.last_brush_mult*0.96
     graphics.set_color(*graphics.get_line_color())
     self.draw_point(x,y,brush_mult*2.0)
     graphics.set_line_width(1.0)
     draw.quad((x+x_add1,           y+y_add1,
                         self.lastx+x_add2,  self.lasty+y_add2,
                         self.lastx-x_add2,  self.lasty-y_add2,
                         x-x_add1,           y-y_add1))
     self.last_brush_mult = brush_mult
Example #14
0
 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)
Example #15
0
 def keep_drawing(self, x, y, dx, dy):
     graphics.set_color(color=graphics.get_line_color())
     if self.scribble: x, y = self.scramble_coords(x, y)
     draw.line(self.x, self.y, x, y)
     self.x, self.y = x, y
Example #16
0
 def start_drawing(self, x, y):
     self.x1, self.y1 = x, y
     self.line_color = graphics.get_line_color()
Example #17
0
 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()