Пример #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
Пример #2
0
 def keep_drawing(self, x, y, dx, dy):
     self.x2, self.y2 = x, y
     graphics.set_color(1,1,1,1)
     draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y)
     graphics.set_line_width(graphics.user_line_size)
     graphics.set_color(color=self.line_color)
     draw.line(self.x1, self.y1, self.x2, self.y2)
Пример #3
0
 def draw_point(self,x,y,mult = 1):
     if graphics.brush_size*mult <= 1: return
     point_size = graphics.brush_size*mult*0.95
     if point_size < 10:
         graphics.set_line_width(point_size)
         draw.points((x,y))
     else:
         draw.ellipse(x-point_size/2.0,y-point_size/2.0,x+point_size/2.0,y+point_size/2.0)
Пример #4
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()
Пример #5
0
 def draw_fill(self):
     graphics.enter_canvas_mode()
     graphics.set_line_width(self.point_size)
     if not self.smooth_points: graphics.call_twice(pyglet.gl.glDisable, pyglet.gl.GL_POINT_SMOOTH)
     draw.points(self.pixels_old, self.pixel_colors_old)
     draw.points(self.pixels, self.pixel_colors)
     if not self.smooth_points: graphics.call_twice(pyglet.gl.glEnable, pyglet.gl.GL_POINT_SMOOTH)
     self.pixels_old, self.pixel_colors_old = self.pixels, self.pixel_colors
     self.pixels, self.pixel_colors = [], []
     graphics.exit_canvas_mode()
Пример #6
0
 def keep_drawing(self, x, y, dx, dy):
     self.x2, self.y2 = x, y
     graphics.set_color(1,1,1,1)
     draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y)
     
     if graphics.fill_shapes:
         draw.rect(self.x1, self.y1, self.x2, self.y2, self.fill_colors)
     if graphics.outline_shapes:
         graphics.set_line_width(graphics.user_line_size)
         graphics.set_color(color=self.line_color)
         draw.rect_outline(self.x1, self.y1, self.x2, self.y2)
Пример #7
0
 def keep_drawing(self, x, y, dx, dy):
     graphics.set_color(1,1,1,1)
     self.draw_point(self.lastx,self.lasty)
     self.draw_point(x,y)
     graphics.set_line_width(graphics.brush_size)
     draw.line(x, y, self.lastx, self.lasty)
     graphics.set_color(0.5,0.5,0.5,1)
     graphics.set_line_width(0.8)
     radius = graphics.brush_size*0.8/2
     draw.ellipse_outline(x-radius,y-radius,x+radius,y+radius)
     self.lastx, self.lasty = x, y
Пример #8
0
 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)
Пример #9
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
Пример #10
0
 def keep_drawing(self, x, y, dx, dy):
     self.rx, self.ry = x, y
     radius = math.sqrt(
         (self.rx - self.x)*(self.rx - self.x)+(self.ry - self.y)*(self.ry - self.y)
     )
     theta = math.atan2(self.ry-self.y, self.rx-self.x)
     graphics.set_color(1,1,1,1)
     draw.image(self.canvas_pre,graphics.canvas_x,graphics.canvas_y)
     if graphics.fill_shapes:
             #graphics.set_color(color=self.fill_color)
             draw.ngon(self.x,self.y,radius,self.sides,theta, self.fill_colors)
     if graphics.outline_shapes:
         graphics.set_line_width(graphics.user_line_size)
         graphics.set_color(color=self.line_color)
         draw.ngon_outline(self.x, self.y, radius, self.sides, theta)
Пример #11
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))
Пример #12
0
    def keep_drawing(self, x, y, dx, dy):
        self.x2, self.y2 = x, y
        graphics.set_color(1, 1, 1, 1)
        draw.image(self.canvas_pre, graphics.canvas_x, graphics.canvas_y)

        if (
            graphics.fill_shapes
            and abs(self.x2 - self.x1) >= graphics.user_line_size
            and abs(self.y2 - self.y1) >= graphics.user_line_size
        ):
            graphics.set_color(color=self.fill_color)
            draw.ellipse(self.x1, self.y1, self.x2, self.y2)
        if graphics.outline_shapes:
            graphics.set_line_width(graphics.user_line_size)
            graphics.set_color(color=self.line_color)
            draw.ellipse_outline(self.x1, self.y1, self.x2, self.y2)
Пример #13
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)
Пример #14
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
Пример #15
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
Пример #16
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)
Пример #17
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
Пример #18
0
 def draw_point(self,x,y):
     graphics.set_line_width(graphics.brush_size*0.95)
     if graphics.brush_size > 1: draw.points((x,y))