Пример #1
0
    def processLayer(self, thislayer, params):

        G.remove_overlap(thislayer)
        outlinedata = setGlyphCoords(
            ConvertPathsToSkeleton(thislayer.paths, 20))

        ClearPaths(thislayer)

        noisepaths = NoiseOutline(thislayer,
                                  outlinedata,
                                  noisevars=[0.05, 0, 35])
        noiseoutline = self.expandMonolineFromPathlist(noisepaths, self.pen)
        outlinedata2 = setGlyphCoords(ConvertPathsToSkeleton(noisepaths, 4))

        allscribbles = []
        for n in range(0, params["iterations"]):
            scribble = self.ScribblePath(thislayer, outlinedata2,
                                         params["walklen"])
            if scribble is not None:
                scribble = drawSimplePath(scribble, False, False)
                scribblemono = self.expandMonolineFromPathlist([scribble],
                                                               self.pen)
                AddAllPathsToLayer(scribblemono, thislayer)

        retractHandles(thislayer)
        AddAllPathsToLayer(noiseoutline, thislayer)
        G.remove_overlap(thislayer)
        self.CleanOutlines(thislayer,
                           remSmallPaths=True,
                           remSmallSegments=True,
                           remStrayPoints=True,
                           remOpenPaths=True,
                           keepshape=False)
Пример #2
0
    def processLayerLarge(self, thislayer, params):
        offset, gridsize = params["offset"], params["gridsize"]
        pathlist = ConvertPathsToSkeleton(thislayer.paths, 20)
        outlinedata = setGlyphCoords(pathlist)
        bounds = AllPathBounds(thislayer)

        offsetpaths = self.saveOffsetPaths(thislayer,
                                           offset,
                                           offset,
                                           removeOverlap=True)
        pathlist2 = ConvertPathsToSkeleton(offsetpaths, 4)
        outlinedata2 = setGlyphCoords(pathlist2)
        bounds2 = AllPathBoundsFromPathList(pathlist2)

        ClearPaths(thislayer)

        maxchain = 150

        newtris = self.SortCollageSpace(thislayer, outlinedata, outlinedata2,
                                        gridsize, bounds, "stick")
        groups = BreakUpSpace(thislayer, outlinedata, newtris, gridsize,
                              maxchain)
        self.ApplyGlitchCollage(thislayer, groups, self.linecomponents)

        G.remove_overlap(thislayer)
        self.CleanOutlines(thislayer,
                           remSmallPaths=True,
                           remSmallSegments=True,
                           remStrayPoints=True,
                           remOpenPaths=True,
                           keepshape=False)
Пример #3
0
    def ApplyGlitchCollage(self, layer, groups, linecomponents):

        for g in groups:
            if len(g) < 2:
                continue

            templayer = GSLayer()
            templayer.paths = g
            G.remove_overlap(templayer)

            linetype = False

            for p in templayer.paths:

                nodelen = len(p.nodes)
                if nodelen < 4:
                    continue

                roundedpath = RoundPath(p, "nodes")
                roundedpath = convertToFitpath(roundedpath, True)
                if not roundedpath:
                    continue

                if random.choice([0, 1, 2, 3]) == 1:
                    tr = random.choice([0, 2])
                    if tr == 1:
                        self.HalftoneShape(layer, p, "triangle")
                    elif tr == 0:
                        self.HalftoneShape(layer, p, "square")
                    else:
                        layer.paths.append(roundedpath)
                else:
                    if nodelen > 9:

                        if nodelen > 20:
                            noodlepaths = self.expandMonolineFromPathlist(
                                [roundedpath], 6)
                            AddAllPathsToLayer(noodlepaths, layer)
                        else:

                            if random.choice([0, 1]) == 0:

                                if linetype == False:
                                    direction = "vertical"
                                else:
                                    direction = "horizontal"

                                linetype = not linetype
                                linecomps = Fill_Drawlines(
                                    layer, roundedpath, direction, 15,
                                    linecomponents)
                                AddAllComponentsToLayer(linecomps, layer)

                            else:
                                self.Fill_Halftone(layer, roundedpath,
                                                   "circle")
                    else:
                        layer.paths.append(p)

            del templayer
Пример #4
0
    def processLayer(self, thislayer, params):
        offset = params["offset"]
        if ContainsPaths(thislayer):
            offsetpaths = self.saveOffsetPaths(thislayer,
                                               offset,
                                               offset,
                                               removeOverlap=False)
            pathlist = ConvertPathsToSkeleton(offsetpaths, 4)
            outlinedata = setGlyphCoords(pathlist)

            bounds = AllPathBounds(thislayer)
            self.setupChecker(bounds)
            self.setAvailableSlots(thislayer, outlinedata)

            ClearPaths(thislayer)

            walkpaths = self.walkerLoop(thislayer)
            AddAllPathsToLayer(walkpaths, thislayer)

            self.expandMonoline(thislayer, 6)
            G.remove_overlap(thislayer)
            self.CleanOutlines(thislayer,
                               remSmallPaths=False,
                               remSmallSegments=True,
                               remStrayPoints=True,
                               remOpenPaths=True,
                               keepshape=False)
Пример #5
0
    def processLayer(self, thislayer, params):
        G.remove_overlap(thislayer)
        pathlist = ConvertPathsToSkeleton(thislayer.paths, params["stepsize"])
        outlinedata = setGlyphCoords(pathlist)
        originx = G.layer_bounds(thislayer)[0]
        ClearPaths(thislayer)

        allpaths = []
        size = params["stepsize"]
        offset = params["offset"]

        for _, structure in outlinedata:
            newpath = []

            for x1, y1 in structure:
                x2, y2 = int(x1 / size) * size, int(y1 / size) * size

                if len(newpath) > 0:
                    if x2 != newpath[-1][0] or y2 != newpath[-1][1]:
                        newpath.append([x2, y2])
                else:
                    newpath.append([x2, y2])

            allpaths.append(newpath)

        # shift and find lowest x in all paths
        lowestx = min([
            min([node[0] for node in path])  # Min x in path
            for path in allpaths
        ])

        # adjust x in paths by lowestx
        for path in allpaths:
            for node in path:
                node[0] = node[0] + (originx - lowestx)

        angularpaths = [drawSimplePath(path) for path in allpaths]
        AddAllPathsToLayer(angularpaths, thislayer)
        G.remove_overlap(thislayer)

        offsetpaths = self.saveOffsetPaths(thislayer,
                                           offset,
                                           offset,
                                           removeOverlap=True)
        pathlist = ConvertPathsToSkeleton(offsetpaths, 4)
        outlinedata = setGlyphCoords(pathlist)

        glitchpaths = self.Shapefit(thislayer, outlinedata)
        glitchopaths = ConvertPathlistDirection(glitchpaths, 1)
        AddAllPathsToLayer(glitchpaths, thislayer)

        self.CleanOutlines(thislayer,
                           remSmallPaths=False,
                           remSmallSegments=True,
                           remStrayPoints=True,
                           remOpenPaths=True,
                           keepshape=False)
Пример #6
0
 def saveOffsetPaths(self, Layer, hoffset, voffset, removeOverlap):
     glyph = Layer.parent
     templayer = G.copy_layer(Layer)
     templayer.name = "tempoutline"
     currentglyph = Layer.parent
     currentglyph.layers.append(templayer)
     tmplayer_id = templayer.layerId
     self.doOffset(templayer, hoffset, voffset)
     if removeOverlap:
         G.remove_overlap(templayer)
     #templayer.correctPathDirection() # doesn't seem to work when placed here
     offsetpaths = templayer.paths
     return offsetpaths
Пример #7
0
    def processLayer(self, thislayer, params):

        maxshift = params["maxshift"]
        G.remove_overlap(thislayer)
        paths = copy.copy(thislayer.paths)
        ClearPaths(thislayer)
       
        slicedpaths = self.returnSlicedPaths(paths, self.sliceheight)
        self.ShiftPathsNoise(slicedpaths, maxshift)
        AddAllPathsToLayer(slicedpaths, thislayer)
        G.remove_overlap(thislayer)

        self.CleanOutlines(thislayer, remSmallPaths=True, remSmallSegments=False, remStrayPoints=True, remOpenPaths=True, keepshape=False)
Пример #8
0
def removeOverlapPathlist(paths):
    Layer = GSLayer()
    G.add_paths(layer, paths)
    Layer = G.remove_overlap(Layer)
    newpaths = Layer.paths
    del Layer
    return newpaths
Пример #9
0
    def processLayer(self, thislayer, params):
        for n in range(0, params["iterations"]):
            pathlist = ConvertPathsToSkeleton(thislayer.paths,
                                              4)  # small seg size = quicker
            outlinedata = setGlyphCoords(pathlist)
            indices = self.getDrippableSegments(outlinedata)

            # Modifies outlinedata
            self.doDrip(thislayer, indices, outlinedata, params["maxdrip"])

            # draw updated outline
            for path in outlinedata:
                p = convertToFitpath(path[1], True)
                thislayer.paths.append(p)
        G.remove_overlap(thislayer)
        self.CleanOutlines(thislayer,
                           remSmallPaths=True,
                           remSmallSegments=True,
                           remStrayPoints=True,
                           remOpenPaths=True,
                           keepshape=True)
Пример #10
0
    def ApplyCollageGraphixxx(self, layer, groups, drawtype, linecomponents):

        for g in groups:
            if len(g) < 2:
                continue

            templayer = GSLayer()
            templayer.paths = g
            G.remove_overlap(templayer)

            for p in templayer.paths:
                nodelen = len(p.nodes)
                if nodelen < 4:
                    continue

                roundedpath = RoundPath(p, "nodes")
                roundedpath = convertToFitpath(roundedpath, True)
                if not roundedpath:
                    continue

                if drawtype == "vertical" or drawtype == "horizontal":

                    rw = roundedpath.bounds.size.width
                    rh = roundedpath.bounds.size.height
                    if (rw > 130 or rh > 130):
                        all_lines = Fill_Drawlines(layer, roundedpath,
                                                   drawtype, 20,
                                                   linecomponents)
                        AddAllComponentsToLayer(all_lines, layer)

                if drawtype == "blob":
                    # disallow small blobs
                    rw = roundedpath.bounds.size.width
                    rh = roundedpath.bounds.size.height
                    if (rw > 80 and rh > 80) and (rw < 180 or rh < 180):
                        ConvertPathDirection(roundedpath, -1)
                        layer.paths.append(roundedpath)

            del templayer
Пример #11
0
    def processLayer(self, thislayer, params):
        outlinedata = setGlyphCoords(
            ConvertPathsToSkeleton(thislayer.paths, 20))
        bounds = AllPathBounds(thislayer)

        offsetpaths = self.saveOffsetPaths(thislayer,
                                           params["offset"],
                                           params["offset"],
                                           removeOverlap=True)
        outlinedata2 = setGlyphCoords(ConvertPathsToSkeleton(offsetpaths, 4))

        ClearPaths(thislayer)

        newtris = self.SortCollageSpace(
            thislayer,
            outlinedata,
            outlinedata2,
            params["gridsize"],
            bounds,
            action="overlap",
            randomize=True,
        )
        maxchain = random.randrange(200, 400)
        groups = BreakUpSpace(thislayer, outlinedata, newtris,
                              params["gridsize"], maxchain)
        for g in groups:
            if len(g) > 2:
                G.add_paths(thislayer, g)

        G.remove_overlap(thislayer)
        roundedpathlist = returnRoundedPaths(thislayer.paths)
        ClearPaths(thislayer)
        AddAllPathsToLayer(roundedpathlist, thislayer)
        self.CleanOutlines(thislayer,
                           remSmallPaths=True,
                           remSmallSegments=True,
                           remStrayPoints=True,
                           remOpenPaths=True,
                           keepshape=False)
Пример #12
0
 def processLayer(self, thislayer, params):
     G.remove_overlap(thislayer)
     offsetpaths = self.saveOffsetPaths(thislayer,
                                        params["offset"],
                                        params["offset"],
                                        removeOverlap=False)
     outlinedata = setGlyphCoords(ConvertPathsToSkeleton(offsetpaths, 30))
     microbepaths = moonrocks(thislayer,
                              outlinedata,
                              params["iterations"],
                              shapetype="blob",
                              maxgap=1,
                              maxsize=params["maxsize"])
     ClearPaths(thislayer)
     if microbepaths:
         AddAllPathsToLayer(microbepaths, thislayer)
     self.CleanOutlines(thislayer,
                        remSmallPaths=True,
                        remSmallSegments=True,
                        remStrayPoints=True,
                        remOpenPaths=True,
                        keepshape=False)
Пример #13
0
    def processLayer(self, thislayer, params):
        G.remove_overlap(thislayer)
        pathlist = ConvertPathsToSkeleton(thislayer.paths, 20)
        outlinedata = setGlyphCoords(pathlist)
        bounds = AllPathBounds(thislayer)

        offsetpaths = self.saveOffsetPaths(thislayer,
                                           params["offset"],
                                           params["offset"],
                                           removeOverlap=True)
        pathlist2 = ConvertPathsToSkeleton(offsetpaths, 4)
        outlinedata2 = setGlyphCoords(pathlist2)

        ClearPaths(thislayer)

        newtris = self.SortCollageSpace(thislayer,
                                        outlinedata,
                                        outlinedata2,
                                        params["gridsize"],
                                        bounds,
                                        action="overlap",
                                        snap=True)
        maxchain = random.randrange(200, 400)
        groups = BreakUpSpace(thislayer, outlinedata, newtris,
                              params["gridsize"], maxchain)
        for g in groups:
            if len(g) > 2:
                for path in g:
                    thislayer.paths.append(path)

        G.correct_path_direction(thislayer)
        self.CleanOutlines(thislayer,
                           remSmallPaths=True,
                           remSmallSegments=True,
                           remStrayPoints=True,
                           remOpenPaths=True,
                           keepshape=False)
Пример #14
0
    def processLayerLarge(self, thislayer, params):

        sliceheight = params["sliceheight"]
        G.remove_overlap(thislayer)

        bounds = AllPathBounds(thislayer)
        thislayercopy = G.copy_layer(thislayer)
        ClearPaths(thislayer)
       
        spaths = self.returnSlicedPaths(thislayer, thislayercopy, sliceheight, bounds)

        n=1
        maxshift = 20
        for sh, row in spaths:
            for p in row:
                if n%2==0: d=random.randrange(0,maxshift)
                else: d=random.randrange(maxshift*-1,0)
                self.shufflePaths(row, d)
            n+=1
            rounded = returnRoundedPaths(row)

            AddAllPathsToLayer(rounded, thislayer)
            retractHandles(thislayer)
            self.doclean(thislayer)
Пример #15
0
    def processLayer(self, thislayer, params):

        offset, depth = params["offset"], params["depth"]

        G.remove_overlap(thislayer)
        pathlist = ConvertPathsToSkeleton(thislayer.paths, 20)
        outlinedata = setGlyphCoords(pathlist)
        bounds = AllPathBounds(thislayer)

        offsetpaths = self.saveOffsetPaths(thislayer,
                                           offset,
                                           offset,
                                           removeOverlap=True)
        pathlist2 = ConvertPathsToSkeleton(offsetpaths, 4)
        outlinedata2 = setGlyphCoords(pathlist2)

        ClearPaths(thislayer)

        noisepaths = NoiseOutline(thislayer, outlinedata)
        noiseoutline = self.expandMonolineFromPathlist(noisepaths,
                                                       self.glyph_stroke_width)
        shadowpaths = DoShadow(thislayer, outlinedata, self.angle, depth,
                               "lines")
        shadowoutline = self.expandMonolineFromPathlist(
            shadowpaths, self.shadow_stroke_width)

        AddAllPathsToLayer(noiseoutline, thislayer)
        AddAllPathsToLayer(shadowoutline, thislayer)

        G.remove_overlap(thislayer)
        self.CleanOutlines(thislayer,
                           remSmallPaths=True,
                           remSmallSegments=True,
                           remStrayPoints=True,
                           remOpenPaths=True,
                           keepshape=False)
Пример #16
0
    def processLayer(self, thislayer, params):

        offset, it, depthmin, depthmax = params["offset"], params["it"], params["depthmin"], params["depthmax"]

        G.remove_overlap(thislayer)
        pathlist = ConvertPathsToSkeleton(thislayer.paths, 10)
        outlinedata = setGlyphCoords(pathlist)
        bounds = AllPathBounds(thislayer)

        offsetpaths = self.saveOffsetPaths(
            thislayer, offset, offset, removeOverlap=True
        )
        pathlist2 = ConvertPathsToSkeleton(offsetpaths, 4)
        outlinedata2 = setGlyphCoords(pathlist2)

        ClearPaths(thislayer)

        shadowpaths = []
        for n in range(0, it):
            depth = random.randrange(depthmin, depthmax)
            angle = random.randrange(0, 360)
            shadowpaths.extend( DoShadow(thislayer, outlinedata, angle, depth, "paths") )
            AddAllPathsToLayer(shadowpaths, thislayer)
        
        G.remove_overlap(thislayer)

        roundpaths = RoundPaths(thislayer.paths, "nodes")
        blobs = []
        for p in roundpaths: blobs.append ( convertToFitpath(p, True) )

        ClearPaths(thislayer)

        AddAllPathsToLayer(blobs, thislayer)
       
        G.remove_overlap(thislayer)

        self.CleanOutlines(thislayer, remSmallPaths=True, remSmallSegments=True, remStrayPoints=True, remOpenPaths=True, keepshape=False)
Пример #17
0
    def processLayer(self, thislayer, params):
        offset = params["offset"]
        G.remove_overlap(thislayer)
        offsetpaths = self.saveOffsetPaths(thislayer,
                                           offset,
                                           offset,
                                           removeOverlap=False)
        pathlist = ConvertPathsToSkeleton(offsetpaths, 4)
        outlinedata = setGlyphCoords(pathlist)
        ClearPaths(thislayer)

        for direction, structure in outlinedata:
            nodelen = len(structure)
            bubble = GSPath()
            n = 0

            while n < nodelen:
                x1, y1 = structure[n]
                minstep, maxstep = params["minstep"], params["maxstep"]
                minpush, maxpush = params["minpush"], params["maxpush"]

                if direction == Direction.CLOCKWISE:
                    minstep = int(minstep * 0.7)
                    maxstep = int(maxstep * 0.7)
                step = random.randrange(minstep, maxstep)

                if n + step >= nodelen - 1:
                    n = nodelen
                    break

                if n < nodelen - 1:
                    x2, y2 = structure[n + step]
                    n += step
                else:
                    x2, y2 = structure[0][0]

                a = atan2(y1 - y2, x1 - x2) + radians(90)
                pushdist = random.randrange(minpush, maxpush)

                # --- chech if there's space for a full bubble
                beamdist = 200
                searchblack = DistanceToNextBlack(thislayer, [x1, y1],
                                                  [x2, y2], outlinedata,
                                                  beamdist)
                if searchblack is not None and searchblack < beamdist:
                    pushdist *= 0.8

                linex, liney = pushdist * cos(a), pushdist * sin(a)

                if direction == Direction.CLOCKWISE:
                    linex *= 0.7
                    liney *= 0.7

                # DRAW THE POINTS
                bubble.nodes.append(
                    GSNode([x1 + linex, y1 + liney], type=GSOFFCURVE))
                bubble.nodes.append(
                    GSNode([x2 + linex, y2 + liney], type=GSOFFCURVE))
                bubble.nodes.append(GSNode([x2, y2], type=GSCURVE))

            bubble.closed = True
            thislayer.paths.append(bubble)
Пример #18
0
 def processLayerSmall(self, thislayer):
     G.remove_overlap(thislayer)
     roundedpathlist = returnRoundedPaths(thislayer.paths)
     ClearPaths(thislayer)
     AddAllPathsToLayer(roundedpathlist, thislayer)