Esempio n. 1
0
def drawCell(glyphName, cellWidth, cellHeight, cellLegendSize):

    # Cell outline
    db.fill(None)
    db.stroke(0)
    db.strokeWidth(0.25)
    db.rect(0, 0, cellWidth, cellHeight)

    charArea = cellWidth / 3.5
    fontSize = charArea * 0.7
    charStartingOffset = (cellWidth * 0.5) - (charArea * 1.5)

    # Glyph sample
    for iH, aH in enumerate(angles):
        for iV, aV in enumerate(reversed(angles)):
            locStr = "%s %s" % (aH, aV)

            f = instances[locStr]
            if glyphName in f:
                g = f[glyphName]

                with db.savedState():
                    db.translate(charStartingOffset, charStartingOffset
                                 )  # Center the nine glyphs in the cell
                    db.translate(
                        iH * charArea,
                        iV * charArea)  # Move to the current glyph in the cell
                    db.translate(charArea * 0.5,
                                 0)  # Offset to center glyph in cell
                    db.translate(0, cellLegendSize *
                                 3)  # Leave room for the legend
                    # Draw
                    db.fill(0)
                    db.stroke(None)
                    db.scale(fontSize / 1000)
                    drawGlyph(g)

                # Legend
                db.fill(None)
                db.stroke(0)
                db.strokeWidth(0.25)
                db.lineCap("round")
                db.line((cellLegendSize, cellLegendSize * 3),
                        (cellWidth - cellLegendSize, cellLegendSize * 3))
                unicodeValueStr = ""
                if g.unicode:
                    unicodeValueStr = hex(g.unicode)
                legendText = "%s\n%s" % (g.name, unicodeValueStr)
                fs = db.FormattedString(legendText,
                                        font="Tilt Neon",
                                        fontSize=cellLegendSize,
                                        tracking=1,
                                        lineHeight=cellLegendSize)
                db.text(fs, (cellLegendSize, cellLegendSize * 1.7))
Esempio n. 2
0
    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)
Esempio n. 5
0
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()
Esempio n. 6
0
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()