def _makeOvershoot(self, glyph: RGlyph, origin_x: int, origin_y: int, width: int, height: int, inside: int, outside: int, ty): ox = origin_x - outside oy = origin_y - outside width += outside height += outside pen = glyph.getPen() pen.moveTo((ox, oy)) pen.lineTo((ox + width + outside, oy)) pen.lineTo((ox + width + outside, oy + height + outside)) pen.lineTo((ox, oy + height + outside)) pen.closePath() ox = origin_x + inside oy = origin_y + inside width -= outside + inside height -= outside + inside pen.moveTo((ox, oy)) pen.lineTo((ox, oy + height - inside)) pen.lineTo((ox + width - inside, oy + height - inside)) pen.lineTo((ox + width - inside, oy)) pen.closePath() glyph.round() glyph.moveBy((0, ty)) self.elements.append((glyph, (0.4, .75, 1, .1), 'fill'))
def _makeVerGrid(self, glyph: RGlyph, x: int, y: int, w: int, h: int, ty: int, step: int): pen = glyph.getPen() dist = x + w / step for i in range(step - 1): pen.moveTo((dist, y)) pen.lineTo((dist, y + h)) pen.closePath() dist += w / step # db.drawGlyph(glyph) glyph.moveBy((0, ty)) self.elements.append((glyph, (.80, 0.56, .66, 1), 'stroke'))
def _makeVerSecLine(self, glyph: RGlyph, origin_x: int, origin_y: int, width: int, height: int, ty): pen = glyph.getPen() pen.moveTo((origin_x, origin_y)) pen.lineTo((origin_x, origin_y + height)) pen.closePath() pen.moveTo((width, origin_y)) pen.lineTo((width, origin_y + height)) pen.closePath() glyph.round() glyph.moveBy((0, ty)) self.elements.append((glyph, (.80, 0.56, .66, 1), 'stroke'))
def _getFrame(self, x: int, y: int, w: int, h: int, ty) -> tuple: glyph = RGlyph() pen = glyph.getPen() pen.moveTo((x, y)) pen.lineTo((w + x, y)) pen.lineTo((w + x, h + y)) pen.lineTo((x, h + y)) pen.closePath() glyph.round() glyph.moveBy((0, ty)) self.elements.append((glyph, (0, 0, 0, 1), 'stroke'))
def _getEmRatioFrame(self, frame: int, w: int, h: int, ty) -> tuple: charfaceW = w * frame / 100 charfaceH = h * frame / 100 x = (w - charfaceW) * .5 y = (h - charfaceH) * .5 glyph = RGlyph() pen = glyph.getPen() pen.moveTo((x, y)) pen.lineTo((charfaceW + x, y)) pen.lineTo((charfaceW + x, charfaceH + y)) pen.lineTo((x, charfaceH + y)) pen.closePath() glyph.round() glyph.moveBy((0, ty)) self.elements.append((glyph, (0, 0, 0, 1), 'stroke')) return x, y, charfaceW, charfaceH