def draw(self):
        self.xFactor = self.targetXheight / currentXheight

        drawBot.newDrawing()
        drawBot.newPage("LetterLandscape")

        pageWidth = drawBot.width()

        drawBot.fill(0, 0, 0, 0.5)
        drawBot.stroke(0, 0, 0, 1)

        drawBot.rect(.5 * dpi, .5 * dpi, pageWidth - (1 * dpi),
                     self.targetXheight)

        drawBot.translate(0.5 * dpi, .5 * dpi)
        drawBot.scale(self.xFactor)

        for g in self.text:
            pen = CocoaPen(f)
            f[g].draw(pen)
            drawBot.drawPath(pen.path)
            drawBot.translate(f[g].width, 0)

        pdf = drawBot.pdfImage()
        # set the pdf data in the canvas
        self.w.canvas.setPDFDocument(pdf)
Пример #2
0
    def _lineTo(self, pt):
        x0, y0 = self._getCurrentPoint()
        x, y = pt

        db.fill(None)
        db.stroke(r.random(), r.random(), r.random(), 1)
        db.strokeWidth(self.width)

        # db.newPath()
        db.moveTo((x0, y0))
        db.lineTo(pt)
        db.drawPath()

        # Or use line() instead of newPath, moveTo, lineTo, drawPath combo
        # line((x0, y0), (x, y))

        # Use rectangle below... still not sure why one over the other
        # angle = self.getAngle((x0, y0), (x, y))
        # distance = self.getDistance((x0, y0), (x, y))

        # fill(0, 0, 1, 1)

        # with savedState():
        #     rotate(angle, (x0, y0))
        #     rect(x0, y0 - self.width / 2, distance, self.width)

        self.pointsList.append(pt)
Пример #3
0
    def draw(self, origin, view):

        p = pointOffset(self.oPoint, origin)
        p = self._applyScale(p)
        px, py, _ = p = self._applyAlignment(p)  # Ignore z-axis for now.

        save()
        sh = 1.0 * self.h / self.ih
        transform((1, 0, 0, 1, px, py))
        scale(sh)
        if self.pathFilter is not None:
            self.pathFilter(self, self.glyph.path)
        if self.css('fill') != NO_COLOR or self.css('stroke') != NO_COLOR:
            setFillColor(self.css('fill'))
            print(self.css('strokeWidth') or 1), sh
            setStrokeColor(self.css('stroke', NO_COLOR),
                           (self.css('strokeWidth') or 20))
            fill(0)
            stroke(1, 0, 0)
            strokeWidth(20)
            drawPath(self.glyph.path)
        restore()

        # If there are child elements, draw them over the polygon.
        self._drawElements(p, view)

        # Draw optional bounding box.
        #self.drawFrame(origin, view)

        self._restoreScale()
        view.drawElementMetaInfo(
            self, origin)  # Depends on css flag 'showElementInfo'
Пример #4
0
    def pageSetup(self):
        drawBot.newDrawing()
        drawBot.newPage("LetterLandscape")
        
        pageWidth = drawBot.width()
        pageHeight = drawBot.height()
        
        #drawBot.fill(0,0,0, 0.5)
        drawBot.stroke(0,0,0,.5)
        drawBot.strokeWidth(0.5)
        
        #this needs major clean up
        drawBot.line((margin, pageHeight-margin), (pageWidth-dpi, pageHeight-margin)) #xHeight line
        drawBot.line((margin, pageHeight-margin-self.xHeightTarget), (pageWidth-dpi, pageHeight-margin-self.xHeightTarget)) #baseline
        
        drawBot.line((margin, pageHeight-margin-(2.5*self.xHeightTarget)), (pageWidth-dpi, pageHeight-margin-(2.5*self.xHeightTarget))) #xHeight line
        drawBot.line((margin, pageHeight-margin-self.xHeightTarget-(2.5*self.xHeightTarget)), (pageWidth-dpi, pageHeight-margin-self.xHeightTarget-(2.5*self.xHeightTarget))) #baseline
        
        drawBot.line((margin, pageHeight-margin-(5*self.xHeightTarget)), (pageWidth-dpi, pageHeight-margin-(5*self.xHeightTarget))) #xHeight line
        drawBot.line((margin, pageHeight-margin-self.xHeightTarget-(5*self.xHeightTarget)), (pageWidth-dpi, pageHeight-margin-self.xHeightTarget-(5*self.xHeightTarget))) #baseline

        #drawBot.rect(margin, pageHeight-margin, pageWidth-dpi, -self.xHeightTarget)
        
        pdf = drawBot.pdfImage()
        # set the pdf data in the canvas
        self.w.canvas.setPDFDocument(pdf)
Пример #5
0
    def _drawGlyphMarker(self,
                         axisName,
                         mx,
                         my,
                         glyphName,
                         fontSize,
                         location,
                         strokeW=2):
        # Middle circle
        fill(1)
        stroke(0.7)
        strokeWidth(strokeW)
        oval(mx - fontSize / 2 * self.R, my - fontSize / 2 * self.R,
             fontSize * self.R, fontSize * self.R)

        variableFont = getVariableFont(self.font, location)
        # Show axis name below circle marker?
        if self.showAxisNames and axisName is not None:
            fs = newFS(axisName,
                       style=dict(font=variableFont.installedName,
                                  fontSize=fontSize / 4,
                                  textFill=0))
            tw, th = textSize(fs)
            text(fs, (mx - tw / 2, my - fontSize / 2 * self.R - th * 2 / 3))
        glyphPathScale = fontSize / self.font.info.unitsPerEm
        drawGlyphPath(variableFont,
                      glyphName,
                      mx,
                      my - fontSize / 3,
                      s=glyphPathScale,
                      fillColor=0)
Пример #6
0
def setStrokeColor(c, w=1, fs=None, cmyk=False):
    u"""Set global stroke color or the color of the formatted string."""
    if c is NO_COLOR:
        pass  # Color is undefined, do nothing.
    elif c is None or isinstance(
            c, (float, long, int)):  # Because None is a valid value.
        if cmyk:
            if fs is None:
                cmykStroke(c)
            else:
                fs.cmykStroke(c)
        else:
            if fs is None:
                stroke(c)
            else:
                fs.stroke(c)
    elif isinstance(c, (list, tuple)) and len(c) in (3, 4):
        if cmyk:
            if fs is None:
                cmykStroke(*c)
            else:
                fs.cmykStroke(*c)
        else:
            if fs is None:
                stroke(*c)
            else:
                fs.stroke(*c)
    else:
        raise ValueError('Error in color format "%s"' % c)
    if w is not None:
        strokeWidth(w)
Пример #7
0
    def drawContour(self):

        color = self.colorScheme.colorsRGB['contour']

        drawBot.save()
        drawBot.fontSize(self.captionSize)
        drawBot.font(self.captionFont)

        for char in self.txt:
            uni = ord(char)
            glyphName = UV2AGL.get(uni)

            # interpolate
            g1 = self.font[glyphName].getLayer('regular')
            g2 = self.font[glyphName].getLayer('bold')
            glyph = RGlyph()
            glyph.name = g1.name
            glyph.unicode = g1.unicode
            glyph.interpolate(self.interpolationFactor, g1, g2)

            # draw contours
            drawBot.stroke(*color)
            drawBot.strokeWidth(self.contourStrokeWidth)
            drawBot.fill(None)
            B = drawBot.BezierPath()
            for contour in glyph.contours:
                contour.draw(B)
            drawBot.drawPath(B)

            # done glyph
            drawBot.translate(glyph.width, 0)

        drawBot.restore()
Пример #8
0
 def stroke(self, c, strokeWidth=None):
     if strokeWidth is not None:
         self.strokeWidth(strokeWidth)
     if c is None:
         drawBot.stroke(None)
     else:
         r, g, b, a = c.rgba
         drawBot.stroke(r, g, b, a)
Пример #9
0
 def stroke(self, c, strokeWidth=None):
     if strokeWidth is not None:
         self.strokeWidth(strokeWidth)
     if c is None:
         drawBot.stroke(None)
     else:
         r, g, b, a = asRgbaColor(c)
         drawBot.stroke(r, g, b, a)
Пример #10
0
def typeQualities(isBold=False):
    fill(*BLACK)
    stroke(None)
    openTypeFeatures(tnum=True)
    if not isBold:
        font('.SFNS-Regular', 9)
    else:
        font('.SFNS-Bold', 9)
Пример #11
0
 def drawPageFrame(self, page, origin):
     u"""Draw the page frame if the the flag is on and  if there ie padding enough to show other meta info.
     Otherwise the padding is truncated to 0: no use to draw the frame."""
     if self.showPageFrame:  # Different from base View, no check on padding.
         fill(None)
         stroke(0.5)
         strokeWidth(0.5)
         rect(origin[0], origin[1], page.w, page.h)
Пример #12
0
 def __enter__(self):
     db.save()
     for k, v in self.style.items():
         db.fill(None)
         db.stroke(None)
         db.strokeWidth(1)
         getattr(db, k)(*v)
     return self
Пример #13
0
    def _drawGlyphMarker(self, mx, my, glyphName, markerSize, location, strokeW=2):
        # Middle circle 
        fill(1)
        stroke(0)
        strokeWidth(strokeW)
        oval(mx-markerSize/2, my-markerSize/2, markerSize, markerSize)

        glyphPathScale = markerSize/self.font.info.unitsPerEm*3/4
        drawGlyphPath(self.font.ttFont, glyphName, mx, my-markerSize/4, location, s=glyphPathScale, fillColor=0)
Пример #14
0
    def _drawGlyphMarker(self, mx, my, glyphName, fontSize, location, strokeW=2):
        # Middle circle 
        fill(1)
        stroke(0)
        strokeWidth(strokeW)
        oval(mx-fontSize*self.R, my-fontSize*self.R, fontSize*2*self.R, fontSize*2*self.R)

        glyphPathScale = fontSize/self.font.info.unitsPerEm
        drawGlyphPath(self.font.ttFont, glyphName, mx, my-fontSize/4, location, s=glyphPathScale, fillColor=0)
Пример #15
0
    def draw(self, page, x, y):

        if self.drawBefore is not None:  # Call if defined
            self.drawBefore(self, p, view)

        fillColor = self.style.get('fill')
        if fillColor is not None:
            setFillColor(fillColor)
            setStrokColor(None)

        #stroke(0.8)
        #strokeWidth(0.5)
        #fill(None)
        #rect(x, y, self.w, self.h)

        stroke(None)

        stepX = self.w / (self.sizeX + 1)
        stepY = self.h / (self.sizeY + 1)
        """Add more parametric layout behavior here."""
        for indexX in range(self.sizeX + 1):
            for indexY in range(self.sizeY + 1):
                ox = 30
                oy = 25
                px = ox + x + indexX * stepX
                py = oy + y + indexY * stepY
                if self.locations is not None:
                    location = choice(self.locations)
                else:
                    location = self.getRandomLocation()
                glyphPathScale = self.fontSize / self.font.info.unitsPerEm
                fillColor = self.style.get('textFill') or (0, 0, 0)
                drawGlyphPath(self.font.ttFont,
                              self.glyphNames[0],
                              px,
                              py,
                              location,
                              s=glyphPathScale,
                              fillColor=fillColor)
                if self.recipeAxes:
                    recipe = self.location2Recipe(location)
                    fs = FormattedString(recipe, fontSize=4, fill=0)
                    w, h = fs.size()
                    page.text(
                        fs, px - stepX / 4, py - 24
                    )  # Bit of hack, we need the width of the glyph here.
                    if len(self.recipeAxes) > 3:
                        recipe = self.location2Recipe(location, 3, 6)
                        fs = FormattedString(recipe, fontSize=4, fill=0)
                        w, h = fs.size()
                        page.text(
                            fs, point(px - stepX / 4 + 30, py - 24)
                        )  # Bit of hack, we need the width of the glyph here.

        if self.drawAfter is not None:  # Call if defined
            self.drawAfter(self, p, view)
Пример #16
0
    def draw(self, page, x, y):
        fillColor = self.style.get('fill')
        if fillColor is not None:
            setFillColor(fillColor)
            setStrokColor(None)

        stroke(0.8)
        strokeWidth(0.5)
        fill(None)
        rect(x, y, self.w, self.h)
        if len(self.dimensions) == 1:
            raise ValueError('Not supporting 1 axis now')
        if len(self.dimensions) > 2:
            raise ValueError('Not supporting >2 axis now')

        axisNames = sorted(self.dimensions.keys())
        axisX = axisNames[0]
        sizeX = self.dimensions[axisX]
        axisY = axisNames[1]
        sizeY = self.dimensions[axisY]
        stepX = self.w / (sizeX + 1)
        stepY = self.h / (sizeY + 1)
        """Add more parametric layout behavior here."""
        RANGE = 1000
        for indexX in range(sizeX + 1):
            for indexY in range(sizeY + 1):
                ox = 30
                oy = 25
                px = ox + x + indexX * stepX
                py = oy + y + indexY * stepY
                self.location[axisX] = indexX * RANGE / sizeX
                self.location[axisY] = indexY * RANGE / sizeY
                glyphPathScale = self.fontSize / self.font.info.unitsPerEm

                drawGlyphPath(self.font.ttFont,
                              self.glyphNames[0],
                              px,
                              py,
                              self.location,
                              s=glyphPathScale,
                              fillColor=(0, 0, 0))

                fs = FormattedString('%s %d\n%s %d' %
                                     (axisX, indexX * RANGE / sizeX, axisY,
                                      indexY * RANGE / sizeY),
                                     fontSize=6,
                                     fill=0)
                w, h = fs.size()
                page.text(
                    fs, px - stepX / 4, py -
                    16)  # Bit of hack, we need the width of the glyph here.
        fs = FormattedString('Other axes: %s' % self.location,
                             fontSize=6,
                             fill=0)
        w, h = fs.size()
        page.text(fs, x, y - 16)
Пример #17
0
 def drawPageFrame(self, page, origin):
     u"""Draw the page frame if the the flag is on and  if there ie padding enough to show other meta info.
     Otherwise the padding is truncated to 0: no use to draw the frame."""
     if self.showPageFrame and \
             self.pl > self.MIN_PADDING and self.pr > self.MIN_PADDING and \
             self.pt > self.MIN_PADDING and self.pb > self.MIN_PADDING:
         fill(None)
         stroke(0, 0, 1)
         strokeWidth(0.5)
         rect(origin[0], origin[1], page.w, page.h)
Пример #18
0
 def drawDesignFrame():
     for e in self.designFrameViewer.elements:
         glyph, color, type = e
         if type == 'stroke':
             db.stroke(*color)
             db.fill(None)
         else:
             db.stroke(None)
             db.fill(*color)
         db.drawGlyph(glyph)
Пример #19
0
 def stroke(self, weight=1, color=None, dash=None):
     db.strokeWidth(weight)
     if dash:
         db.lineDash(dash)
     if color:
         if isinstance(color, Gradient):
             pass # possible?
         elif isinstance(color, Color):
             db.stroke(color.r, color.g, color.b, color.a)
     else:
         db.stroke(None)
Пример #20
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)
Пример #21
0
def draw_textile(mtx, tate_color, yoko_color, grid_size=10):

    for i in range(mtx.shape[0]):
        for j in range(mtx.shape[1]):
            if mtx[i][j] == 1:
                db.stroke(*tate_color)
                db.fill(*tate_color)
            elif mtx[i][j] == 0:
                db.stroke(*yoko_color)
                db.fill(*yoko_color)

            db.rect(i * grid_size, j * grid_size, grid_size, grid_size)
Пример #22
0
    def draw(self, pages: list, export=False):
        if not pages: return
        tbs = self.w.customPages.page.textBoxList.getSelection()
        db.newDrawing()
        for page in pages:
            if page is None: continue
            db.newPage(*page.size)

            db.save()
            db.fill(*page.backgroundColor)
            db.rect(0, 0, *page.size)
            db.restore()

            for i, textbox in enumerate(page.textBoxes):
                db.save()
                db.translate(*textbox.position[:2])
                if not export:
                    db.save()
                    db.fill(None)
                    if i in tbs:
                        db.stroke(1, 0, 0, 1)
                    if not textbox.text:
                        db.fill(.5, .5, .5, .5)
                    db.rect(0, 0, *textbox.position[2:])
                    db.restore()

                if textbox.type == "Text":
                    db.save()
                    db.fill(*textbox.color)
                    db.tracking(textbox.tracking)
                    db.font(textbox.font, textbox.fontSize)
                    db.textBox(textbox.text, (0, 0, *textbox.position[2:]),
                               textbox.align)
                    db.restore()

                elif textbox.type == "UfoText":
                    db.save()
                    db.fill(*textbox.color)

                    s = textbox.fontSize / 1000
                    db.scale(s, s)
                    for pos, glyph in textbox.glyphs:
                        db.save()
                        db.translate(*pos)
                        if export:
                            glyph.round()
                        db.drawGlyph(glyph)
                        db.restore()
                    db.restore()
                db.restore()

        pdfData = db.pdfImage()
        self.w.customPages.canvas.setPDFDocument(pdfData)
Пример #23
0
            def drawWeight(weight, text):

                db.newDrawing()
                self.designFrameViewer.draw()

                db.newPage(FRAMEX, FRAMEY)
                db.textBox(user, (0, FRAMEY - 85, FRAMEX, 55), align='center')
                db.textBox(text, (0, FRAMEY - 105, FRAMEX, 55), align='center')
                s = .11
                tx, ty = (FRAMEX / s - 1000 * 4) * .5, 1000 * 5.8
                db.save()
                db.scale(s, s)
                db.translate(tx, ty)
                db.fontSize(60)

                print(weight)
                for i, glyph in enumerate(weight):
                    drawDesignFrame()
                    if glyph[0].markColor:
                        db.fill(*glyph[0].markColor)
                    else:
                        db.fill(*INPROGRESS)
                    db.rect(0, 900, 250, 100)
                    db.fill(0, 0, 0, 1)
                    db.stroke(None)
                    db.textBox(glyph[0].name, (0, 900, 1000, 100),
                               align="center")

                    db.fill(0, 0, 0, 1)
                    db.stroke(None)
                    for c in glyph:
                        db.drawGlyph(c)
                    if (i + 1) % 4:
                        db.translate(1000, 0)
                    else:
                        db.translate(-1000 * 3, -1200)

                db.restore()
                pdfData = db.pdfImage()
                now = datetime.datetime.now()
                if not self.RCJKI.currentFont.mysql:
                    outputPath = os.path.join(
                        self.RCJKI.currentFont.fontPath, "Proofing", user,
                        '%s_%s_%s.pdf' % (date, str(pageIndex).zfill(2), text))
                else:
                    outputPath = os.path.join(
                        mysqlpath,
                        '%s_%s_%s.pdf' % (date, str(pageIndex).zfill(2), text))
                # os.rename(outputPath, outputPath[:-3]+'ai')
                files.makepath(outputPath)
                db.saveImage(outputPath)
                os.rename(outputPath, outputPath[:-3] + "ai")
Пример #24
0
    def _curveToOne(self, pt1, pt2, pt3):
        x0, y0 = self._getCurrentPoint()

        db.fill(None)
        db.stroke(r.random(), r.random(), r.random(), 1)
        db.strokeWidth(self.width)

        # db.newPath()
        db.moveTo((x0, y0))
        db.curveTo(pt1, pt2, pt3)
        db.drawPath()

        self.pointsList.append(pt3)
Пример #25
0
def draw(txt="a", variations={}, caption=""):
    db.newPage(w * scale, h * scale)
    db.scale(scale)
    db.fill(*BACKCOL)
    db.rect(0, 0, w, h)
    txt = db.FormattedString(txt, font="Handjet-Regular", fontSize=500, fontVariations=variations)
    db.fill(*TEXTCOL)
    db.stroke(None)
    path = db.BezierPath()
    path.text(txt, (w / 2, 95), align="center")
    db.drawPath(path)
    txt = db.FormattedString(caption, font="AdapterMonoPE-Regular", fontSize=11, fill=TEXTCOL)
    db.text(txt, (w / 2, 40), align="center")
Пример #26
0
    def drawCircles(self):
        """
        Draw circle at all points in pointsList
        """
        # db.blendMode("multiply")
        db.fill(1, 0, 0, 1)
        db.stroke(None)

        for point in self.pointsList:
            x, y = point
            db.newPath()
            db.oval(x - self.width / 2, y - self.width / 2, self.width,
                    self.width)
Пример #27
0
    def drawInfo(self):
        color = self.colorScheme.colorsRGB['info']
        drawBot.save()

        # font info
        if self.infoValuesDraw:
            drawBot.fill(*color)
            drawBot.fontSize(self.captionSizeLarge)
            h = self.captionSizeLarge * 2
            y = self.yTop
            txt  = '%s %s' % (self.font.info.familyName, self.font.info.styleName)
            drawBot.textBox(txt, (0, y, self.textLength, h))

        # blue zones
        # for i, y in enumerate(self.font.info.postscriptBlueValues):
        #     if not i % 2:
        #         yNext = self.font.info.postscriptBlueValues[i+1]
        #         h = yNext - y
        #         drawBot.fill(*color + (0.35,))
        #         drawBot.rect(0, y, self.textLength, h)

        # vertical dimensions
        yValues = set([
            0,
            self.font.info.xHeight,
            self.font.info.capHeight,
            self.font.info.descender,
            self.font.info.ascender,
        ])
        drawBot.font(self.captionFont)
        drawBot.fontSize(self.captionSize)
        for y in yValues:
            # draw guide
            drawBot.stroke(*color)
            drawBot.strokeWidth(self.infoStrokeWidth)
            if not self.infoLineDash:
                drawBot.lineDash(None)
            else:
                drawBot.lineDash(*self.infoLineDash)
            drawBot.line((0, y), (self.textLength, y))
            # draw y value
            if self.infoValuesDraw:
                w = 300
                m = 50
                drawBot.save()
                drawBot.stroke(None)
                drawBot.fill(*color)
                drawBot.textBox(str(int(y)), (-w-m, y-self.captionSize*0.5, w, self.captionSize*1.2), align='right')
                drawBot.restore()
        # done
        drawBot.restore()
Пример #28
0
 def drawBackground(self, ox, oy, doc, page, parent):
     """Draw the background of the element. Default is to just draw the 
     rectangle with the fill color, if it is defined. This method should be 
     redefined by inheriting subclasses that need different foreground drawing.
     """
     if self.fill is not None:
         drawBot.stroke(None)  # Any stroke drawing is done in foreground
         r, g, b, a = asColor(self.fill)
         if r is None:
             drawBot.fill(None)
         else:
             drawBot.fill(r, g, b, a)
         if self.w is not None and self.h is not None:
             drawBot.rect(ox, oy, self.w, self.h)
Пример #29
0
def createPlaceholder(wdt, hgt, locationOnDisk):
    dB.newDrawing()
    dB.newPage(wdt, hgt)

    dB.fill(.5)
    dB.rect(0, 0, dB.width(), dB.height())

    dB.stroke(1)
    dB.strokeWidth(10)

    dB.line((0, 0), (dB.width(), dB.height()))
    dB.line((0, dB.height()), (dB.width(), 0))
    dB.saveImage(f'{locationOnDisk}')
    dB.endDrawing()
Пример #30
0
def circle(x, y, r, color='pink'):
    u"""
    >>> circle(100, 100, 5, color='green')
    """
    stroke(None)
    # Draws on/offcurve dots.
    if color == 'pink':
        fill(1, 0, 1, 0.5)
    elif color == 'green':
        fill(0, 1, 0, 0.5)
    elif color == 'blue':
        fill(0, 0.5, 1, 0.5)
    oval(x - r, y - r, r*2, r*2)
    stroke(1)
Пример #31
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.closePath()

drawBot.moveTo((40, 40))
drawBot.lineTo((160, 40))
drawBot.curveTo((160, 65), (145, 80), (120, 80))
drawBot.lineTo((40, 80))
drawBot.closePath()

drawBot.fill(0.5, 0, 0)
drawBot.stroke(None)
drawBot.strokeWidth(10)
drawBot.drawPath()
Пример #32
0
import drawBot
drawBot.newDrawing()
drawBot.size(200, 100)
p = drawBot.BezierPath()
p.oval(5, 5, 70, 70)
p.rect(25, 25, 70, 70)
drawBot.fill(0, 0.3)
drawBot.stroke(0)
drawBot.drawPath(p)
p.removeOverlap()
drawBot.translate(100, 0)
drawBot.drawPath(p)
Пример #33
0
import drawBot
drawBot.size(200, 200)
drawBot.text("hello world", (10, 10))
drawBot.fill(1, 0, 0)
drawBot.text("foo bar", (10, 30))
drawBot.fill(1, 0, 1)
drawBot.stroke(0, 1, 0)
drawBot.strokeWidth(4)
drawBot.font("Times", 50)
drawBot.text("foo bar", (10, 50))
drawBot.fill(None)
drawBot.stroke(0, 1, 0)
drawBot.strokeWidth(1)
drawBot.line((0, 50), (drawBot.width(), 50))
drawBot.stroke(None)
drawBot.fill(0, 1, 1)
drawBot.fontSize(20)
drawBot.text("foo bar", (drawBot.width()*.5, 100), align="right")
drawBot.text("foo bar", (drawBot.width()*.5, 120), align="center")
drawBot.text("foo bar", (drawBot.width()*.5, 140), align="left")
Пример #34
0
import drawBot
drawBot.size(200, 200)
drawBot.stroke(0, 0, 1)
drawBot.strokeWidth(5)
with drawBot.savedState():
    drawBot.fill(1, 0, 0)
    drawBot.translate(100, 100)
    drawBot.rect(0, 0, 100, 100)
drawBot.rect(0, 0, 100, 100)
with drawBot.savedState():
    drawBot.fill(0, 1, 0)
    drawBot.translate(100, 0)
    drawBot.rect(0, 0, 100, 100)
drawBot.rect(0, 100, 100, 100)