Ejemplo n.º 1
0
    def _drawStems(self, currentGlyph, scalingFactor, offset_X=0):
        if STEM_KEY not in currentGlyph.lib:
            return None

        stemData = calcStemsData(currentGlyph, STEM_KEY)
        for PTs, DIFFs, middlePoint in stemData:
            pt1, pt2 = PTs
            horDiff, verDiff = DIFFs

            dt.save()
            dt.translate(offset_X, 0)
            dt.stroke(*self.stemColor)
            dt.fill(None)
            dt.strokeWidth(1 * scalingFactor)

            dt.newPath()
            if horDiff > verDiff:  # ver
                rightPt, leftPt = PTs
                if pt1.x > pt2.x:
                    rightPt, leftPt = leftPt, rightPt
                dt.moveTo((leftPt.x, leftPt.y))
                dt.curveTo((leftPt.x - horDiff / 2, leftPt.y),
                           (rightPt.x + horDiff / 2, rightPt.y),
                           (rightPt.x, rightPt.y))

            else:  # hor
                topPt, btmPt = PTs
                if pt2.y > pt1.y:
                    btmPt, topPt = topPt, btmPt
                dt.moveTo((btmPt.x, btmPt.y))
                dt.curveTo((btmPt.x, btmPt.y + verDiff / 2),
                           (topPt.x, topPt.y - verDiff / 2),
                           (topPt.x, topPt.y))
            dt.drawPath()
            dt.restore()

            dt.save()
            dt.translate(offset_X, 0)
            textQualities(BODYSIZE_CAPTION * scalingFactor)
            dataToPlot = u'↑{:d}\n→{:d}'.format(int(verDiff), int(horDiff))
            textWidth, textHeight = dt.textSize(dataToPlot)
            textRect = (middlePoint[0] - textWidth / 2.,
                        middlePoint[1] - textHeight / 2., textWidth,
                        textHeight)
            dt.textBox(dataToPlot, textRect, align='center')
            dt.restore()
Ejemplo n.º 2
0
    def _drawException(self, aPair, correction):
        lftGlyphName, rgtGlyphName = aPair
        lftGlyph, rgtGlyph = self.fontObj[lftGlyphName], self.fontObj[
            rgtGlyphName]

        dt.save()
        dt.fill(None)
        dt.stroke(*LIGHT_GRAY)
        dt.strokeWidth(20)

        # calc wiggle line
        pt1 = Point(-lftGlyph.width, 0)
        pt2 = Point(rgtGlyph.width + correction, 0)
        wigglePoints = calcWiggle(pt1, pt2, 100, 100, .65)

        # draw wiggle line
        dt.newPath()
        dt.moveTo(wigglePoints[0])
        for eachBcpOut, eachBcpIn, eachAnchor in wigglePoints[1:]:
            dt.curveTo(eachBcpOut, eachBcpIn, eachAnchor)
        dt.drawPath()

        dt.restore()
Ejemplo n.º 3
0
 def buildShapePath(self, scale):
     # build the drawbot path, separated for preview and regular draw.
     ctx.newPath()
     ctx.moveTo((self._xMin, self._t2_v))
     ctx.curveTo((self._xMin, self._b2_v), (self._b1_h, self._yMax),
                 (self._t1_h, self._yMax))
     ctx.lineTo((self._t2_h, self._yMax))
     ctx.curveTo((self._b2_h, self._yMax), (self._xMax, self._b2_v),
                 (self._xMax, self._t2_v))
     ctx.lineTo((self._xMax, self._t1_v))
     ctx.curveTo((self._xMax, self._b1_v), (self._b2_h, self._yMin),
                 (self._t2_h, self._yMin))
     ctx.lineTo((self._t1_h, self._yMin))
     ctx.curveTo((self._b1_h, self._yMin), (self._xMin, self._b1_v),
                 (self._xMin, self._t1_v))
     ctx.closePath()
Ejemplo n.º 4
0
 def curveTo(self, pt1, pt2, pt3):
     curveTo(pt1, pt2, pt3)
Ejemplo n.º 5
0
 def _curveToOne(self, pt1, pt2, pt3):
     curveTo(pt1, pt2, pt3)
Ejemplo n.º 6
0
	def curveTo(self, pt1, pt2, pt3):
		curveTo(pt1, pt2, pt3)
Ejemplo n.º 7
0
    def a_magnet(self):
        ctx.newPath()
        ctx.fill(0, 0, 0, .75)
        ctx.moveTo((25, 15))
        ctx.curveTo((20.0, 15.0), (17, 16), (17, 20))
        ctx.lineTo((17, 45))
        ctx.curveTo((17.0, 48.0), (15, 50), (9, 50))
        ctx.curveTo((2, 50), (0, 48.0), (0, 45))
        ctx.lineTo((0, 22))
        ctx.curveTo((0, 6), (9, 0), (25, 0))
        ctx.curveTo((41.0, 0.0), (50, 6), (50, 22))
        ctx.lineTo((50, 45))
        ctx.curveTo((50, 48), (48, 50), (41, 50))
        ctx.curveTo((35, 50), (33, 48), (33, 45))
        ctx.lineTo((33, 20))
        ctx.curveTo((33, 16), (30, 15), (25, 15))
        ctx.closePath()
        ctx.drawPath()

        ctx.newPath()
        ctx.fill(1)
        ctx.moveTo((25, 3))
        ctx.curveTo((11.0, 3), (3, 8), (3, 22))
        ctx.lineTo((3, 34))
        ctx.lineTo((14, 34))
        ctx.lineTo((14, 20))
        ctx.curveTo((14.0, 14.0), (18, 12), (25, 12))
        ctx.curveTo((32.0, 12.0), (36.0, 14.0), (36, 20))
        ctx.lineTo((36, 34))
        ctx.lineTo((47, 34))
        ctx.lineTo((47, 22))
        ctx.curveTo((47, 8), (39, 3), (25, 3))
        ctx.closePath()
        ctx.drawPath()