Esempio n. 1
0
def contourImage(file):
    sf = 0.5
    lines = linedraw.sketch(file)
    linecount = 0
    for group in lines:
        for (x0, y0, x1, y1) in linemaker(group):
            linecount += 1
            createLine(linecount, x0 * sf, y0 * sf, x1 * sf, y1 * sf)
Esempio n. 2
0
 def drawImage(self, path):
     lines = linedraw.sketch(path) 
     self.controller.position = (self.start_x, self.start_y)
     self.drawLine(lines[0])
     self.pre_line = lines[0]
     for line in lines[1:]:
         
         self.controller.move((line[0][0]-self.pre_line[-1][0])/self.ratio, (line[0][1]-self.pre_line[-1][1])/self.ratio)
         self.drawLine(line)
         self.pre_line = line
Esempio n. 3
0
def draw():
    linedraw.draw_contours = draw_contours
    linedraw.draw_hatch = draw_hatch
    linedraw.hatch_size = hatch_size
    linedraw.contour_simplify = contour_simplify

    cache_name = get_cache_name()

    print(cache_name, input_path)

    try:
        file = open(cache_name, 'r')
        fc = file.read()
        lines = json.loads(fc)
        file.close()
    except FileNotFoundError:
        print("Unexpected error:", sys.exc_info()[0])
        file = open(cache_name, 'w')
        lines = linedraw.sketch(input_path)
        file.write(json.dumps(lines))
        file.close()

    mouse = PyMouse()

    mouse_x, mouse_y = mouse.position()

    time.sleep(delay)

    scale = 1

    def get_x(_x):
        return (_x * scale) + mouse_x

    def get_y(_y):
        return (_y * scale) + mouse_y

    def drag(_x, _y):
        # print("drag: {},{}".format(_x, _y))
        mouse.drag(_x, _y)

    for line in lines:

        start_x, start_y = line[0]

        mouse.press(get_x(start_x), get_y(start_y), 1)

        for (x, y) in line:
            time.sleep(speed)
            drag(get_x(x), get_y(y))

        end_x, end_y = line[len(line) - 1]

        mouse.release(get_x(end_x), get_y(end_y), 1)

    mouse.move(mouse_x, mouse_y)
Esempio n. 4
0
import linedraw

lines = linedraw.sketch("peppers.png")  # return list of polylines, eg.
# [[(x,y),(x,y),(x,y)],[(x,y),(x,y),...],...]

linedraw.visualize(lines)  # simulates plotter behavior
# draw the lines in order using turtle graphics.
Esempio n. 5
0
            if dr < s:
                x, s, r = l[:], s, True

        clines.remove(x)
        if r == True:
            x = x[::-1]
        slines.append(x)
    return slines


def visualize(lines):
    import turtle
    wn = turtle.Screen()
    t = turtle.Turtle()
    t.speed(0)
    t.pencolor('red')
    t.pd()
    for i in range(0, len(lines)):
        for p in lines[i]:
            t.goto(p[0] * 640 / 1024 - 320, -(p[1] * 640 / 1024 - 320))
            t.pencolor('black')
        t.pencolor('red')
    turtle.mainloop()


if __name__ == "__main__":
    import linedraw
    #linedraw.draw_hatch = False
    lines = linedraw.sketch("tweety")
    #lines = sortlines(lines)
    visualize(lines)
Esempio n. 6
0
        clines.remove(x)
        if r is True:
            x = x[::-1]
        slines.append(x)
    return slines


def visualize(lines):
    import turtle
    # wn = turtle.Screen()
    t = turtle.Turtle()
    t.speed(0)
    t.pencolor('red')
    t.pd()
    for i in range(0, len(lines)):
        for p in lines[i]:
            t.goto(p[0] * 640 / 1024 - 320, -(p[1] * 640 / 1024 - 320))
            t.pencolor('black')
        t.pencolor('red')
    turtle.mainloop()


# for module test
if __name__ == "__main__":
    import linedraw
    # linedraw.draw_hatch = False
    lines = linedraw.sketch("cameraman")
    # lines = sortlines(lines)
    visualize(lines)
Esempio n. 7
0
import linedraw
lines = linedraw.sketch("input/rana.png")  # return list of polylines, eg.
                                            # [[(x,y),(x,y),(x,y)],[(x,y),(x,y),...],...]
                                            
linedraw.visualize(lines)                   # simulates plotter behavior
                                            # draw the lines in order using turtle graphics.

Esempio n. 8
0
                x,s,r = l[:],d,False
            if dr < s:
                x,s,r = l[:],s,True

        clines.remove(x)
        if r == True:
            x = x[::-1]
        slines.append(x)
    return slines

def visualize(lines):
    import turtle
    wn = turtle.Screen()
    t = turtle.Turtle()
    t.speed(0)
    t.pencolor('red')
    t.pd()
    for i in range(0,len(lines)):
        for p in lines[i]:
            t.goto(p[0]*640/1024-320,-(p[1]*640/1024-320))
            t.pencolor('black')
        t.pencolor('red')
    turtle.mainloop()

if __name__=="__main__":
    import linedraw
    #linedraw.draw_hatch = False
    lines = linedraw.sketch("Lenna")
    #lines = sortlines(lines)
    visualize(lines)