def drawCurrentGlyph(self): db.newDrawing() db.translate(100, 100) db.scale(0.8) db.fill(None) db.stroke(0.2, 0.3, 1) db.rect(0, 0, 1000, 1000) db.stroke(None) db.translate( 0, 120 ) # Baseline at 120 from the bottom of the Ideographic Em Square db.fill(0, 1, 0, 0.3) db.stroke(0) db.lineJoin("round") dcSelection = set(self.w.deepComponentList.getSelection()) aeSelection = set(self.w.atomicElementList.getSelection()) if self._currentGlyphOutline is not None: drawOutline(self._currentGlyphOutline) if self._currentGlyphComponents: for dcIndex, (dcName, atomicElements) in enumerate( self._currentGlyphComponents ): for aeIndex, (aeName, atomicOutline) in enumerate(atomicElements): if dcIndex in dcSelection: if aeIndex in aeSelection: db.fill(1, 0, 0, 0.3) else: db.fill(0, 0, 1, 0.3) else: db.fill(0, 0.3) drawOutline(atomicOutline) db.endDrawing()
def stroke(self, isStroke, color, lineWidth, lineCap='round', lineJoin='round'): if not isStroke: ctx.stroke(None) return if type(color) is str and color.startswith('#'): color = hexToRGB(color) ctx.strokeWidth(lineWidth) ctx.stroke(*color) ctx.lineCap(lineCap) ctx.lineJoin(lineJoin)
def drawPlusMinus(sf, a): x, y = a.x, a.y x, y, ang = a.x, a.y, a.angle path = d.BezierPath() path.moveTo((-50, 0)) path.lineTo((50, 0)) if a.type == PLUS: path.moveTo((0, 50)) path.lineTo((0, -50)) path.closePath() path.scale(sf) d.lineCap("round") d.lineJoin("round") path.translate(x, y) d.fill(None) d.stroke(1, 0, 0, 0.5) d.strokeWidth(annoThickness / sf) d.drawPath(path)
def drawArrow(sf, a): x, y, ang = a.x, a.y, a.angle path = d.BezierPath() path.moveTo((50, 40)) path.lineTo((0, 0)) path.lineTo((50, -40)) path.moveTo((0, 0)) path.lineTo((120, 0)) path.closePath() path.scale(sf) d.lineCap("round") d.lineJoin("round") path.rotate(ang, center=(0, 0)) path.translate(x, y) d.fill(None) d.stroke(1, 0, 0, 0.5) d.strokeWidth(annoThickness / sf) d.drawPath(path)
import drawBot drawBot.size(200, 200) drawBot.newPath() drawBot.moveTo((20, 20)) drawBot.lineTo((20, 100)) drawBot.lineTo((100, 100)) drawBot.lineTo((100, 180)) drawBot.curveTo((150, 180), (180, 150), (180, 100)) drawBot.lineTo((180, 20)) drawBot.fill(1, 0, 0) drawBot.stroke(0) drawBot.strokeWidth(10) drawBot.drawPath() drawBot.closePath() drawBot.fill(None) drawBot.stroke(1) drawBot.translate(40, 15) drawBot.scale(0.7) drawBot.lineCap("round") drawBot.lineJoin("round") drawBot.drawPath()
db.translate(x + 0.3 * width, y) pig = sh.getGlyphPath(ufo_path, random.choice(glyphs)) db.fill(j / 15, i / 20, 0.7, 1) db.drawPath(pig) db.restore() db.restore() db.save() db.translate(-160, -400) db.scale(2.5) # db.stroke(0, 0, 0, 1) db.stroke(0.8, 0.8, 0.8, 1) db.fill(1, 1, 1, 1) db.strokeWidth(20) db.lineJoin('round') db.drawPath(sh.getGlyphPath(ufo_path, 'I')) # db.stroke(0.95, 0.95, 0.95, 1) db.drawPath(sh.getGlyphPath(ufo_path, 'J')) db.fill(0.8, 0.8, 0.8, 1) db.stroke(None) db.drawPath(sh.getGlyphPath(ufo_path, 'K')) db.restore() db.save() db.translate(-160, 1400) db.scale(2.5) # db.stroke(0, 0, 0, 1) db.stroke(0.8, 0.8, 0.8, 1) db.fill(1, 1, 1, 1) db.strokeWidth(20)
import drawBot drawBot.size(200, 200) drawBot.newPath() drawBot.moveTo((20, 20)) drawBot.lineTo((20, 100)) drawBot.lineTo((100, 100)) drawBot.lineTo((100, 180)) drawBot.curveTo((150, 180), (180, 150), (180, 100)) drawBot.lineTo((180, 50)) drawBot.qCurveTo((180, 20), (150, 20)) drawBot.fill(1, 0, 0) drawBot.stroke(0) drawBot.strokeWidth(10) drawBot.drawPath() drawBot.closePath() drawBot.fill(None) drawBot.stroke(1) drawBot.translate(40, 15) drawBot.scale(0.7) drawBot.lineCap("round") drawBot.lineJoin("round") drawBot.drawPath()