def removeOverlapPathlist(paths): Layer = GSLayer() G.add_paths(layer, paths) Layer = G.remove_overlap(Layer) newpaths = Layer.paths del Layer return newpaths
def CreateShapeComponent(font, sizex, sizey, shapetype, shapename): if font.glyphs[shapename]: del font.glyphs[shapename] ng = GSGlyph() ng.name = shapename ng.category = "Mark" ng.export = True font.glyphs.append(ng) mid = font.masters[0].id layer = GSLayer() layer.layerId = mid ng.layers[mid] = layer layer.width = 0 # add speck, blob, perhaps even a line? if shapetype == "circle": shape = drawCircle(0, 0, sizex, sizey) elif shapetype == "diamond": shape = drawDiamond(0, 0, sizex, sizey) elif shapetype == "rectangle": shape = drawRectangle(0, 0, sizex, sizey) elif shapetype == "triangle": shape = drawTriangle(0, 0, sizex, sizey) else: shape = drawDiamond(0, 0, sizex, sizey) G.add_paths(layer, [shape]) return ng
def Fill_Halftone(self, thislayer, shape, shapetype): t = shape shapelist = PathToNodeList(t) x = int(t.bounds.origin.x) y = int(t.bounds.origin.y) w = int(t.bounds.size.width) h = int(t.bounds.size.height) grid = 13 size = random.randrange(12, 24) size = 8 for row in range(y, y + h, grid): for col in range(x, x + w, grid): if point_inside_polygon(col, row, shapelist): nx = math.floor(col / grid) * grid ny = math.floor(row / grid) * grid if row % 2 == 0: adjust = grid / 2 else: adjust = 0 c = drawCircle(nx + adjust, ny, size, size) G.add_paths(thislayer, [c]) size += 0.1
def ApplyBurn(thislayer, groups): for g in groups: if len(g) > 2: shiftmax = random.randrange(1, 50) shiftype = random.choice(["x", "y", "xy"]) templayer = GSLayer() G.add_paths(templayer, g) templayer.removeOverlap() for p in templayer.paths: ShiftPath(p, shiftmax, shiftype) G.add_paths(thislayer, [p])
def CreateLineComponent(font, direction, size, shapename): if font.glyphs[shapename]: del font.glyphs[shapename] ng = GSGlyph() ng.name = shapename ng.category = "Mark" ng.export = True font.glyphs.append(ng) firstmaster = font.masters[0].id layer = GSLayer() layer.layerId = layer.associatedMasterId = firstmaster ng.layers[firstmaster] = layer layer.width = 0 #line = GSPath() if direction == "vertical": line = drawRectangle(0, 50, size, 100) if direction == "horizontal": line = drawRectangle(50, 0, 100, size) G.add_paths(layer, [line]) return ng
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)
def processLayer(self, thislayer, params): offsetpaths = self.saveOffsetPaths(thislayer, params["offset"], params["offset"], removeOverlap=False) pathlist = ConvertPathsToSkeleton(offsetpaths, 4) ClearPaths(thislayer) for path in pathlist: # only round shape if over certain size (for small forms) if isSizeBelowThreshold(path, 120, 120): structure = path else: structure = convertToFitpath(RoundPath(path, "nodes"), True) outlinedata = setGlyphCoords(ConvertPathsToSkeleton([structure], 7)) if not outlinedata: continue G.add_paths(thislayer, [self.makePathSpiky(outlinedata[0][1])])
def AddAllPathsToLayer(paths, thislayer): try: G.add_paths(thislayer, paths) except: print("Couldn't add all paths to layer", thislayer)