Exemple #1
0
def make_stride_figure(c, lowerstride, uperstride=1, nrentries=6):
    ht = 0.5
    wd = 2
    dist = 0.2
    textcolor = color.hsb(0.02, 1, 0.6)
    for n in range(nrentries):
        x = n * (wd + dist)
        c.stroke(path.rect(x, 0, wd, ht))
        c.text(x + 0.5 * wd, 0.5 * ht, str(n),
               [text.halign.center, text.valign.middle])

    for n in range(nrentries - 1):
        x = n * (wd + dist)
        c.stroke(
            path.curve(x - dist / 3, ht + 0.5 * dist, x + 0.3 * wd,
                       ht + 3 * dist, x + 0.7 * wd, ht + 3 * dist,
                       x + wd + dist / 3, ht + 0.5 * dist),
            [deco.earrow.large])
        c.text(x + 0.5 * wd, ht + 3.2 * dist, r'\Large 8',
               [text.halign.center, textcolor])

    if lowerstride:
        for n in range((nrentries - 1) // lowerstride):
            x = n * lowerstride * (wd + dist)
            c.stroke(
                path.curve(x - dist / 3, -0.5 * dist, x + 0.5 * wd, -5 * dist,
                           x + (lowerstride - 0.5) * wd + lowerstride * dist,
                           -5 * dist,
                           x + lowerstride * wd + (lowerstride - 0.7) * dist,
                           -0.5 * dist), [deco.earrow.large])
            c.text(x + 0.5 * lowerstride * wd + dist, -5.2 * dist,
                   r'\Large %i' % (lowerstride * 8),
                   [text.halign.center, text.valign.top, textcolor])
def make_stride_figure(c, lowerstride, uperstride=1, nrentries=6):
    ht = 0.5
    wd = 2
    dist = 0.2
    textcolor = color.hsb(0.02, 1, 0.6)
    for n in range(nrentries):
        x = n*(wd+dist)
        c.stroke(path.rect(x, 0, wd, ht))
        c.text(x+0.5*wd, 0.5*ht, str(n), [text.halign.center, text.valign.middle])

    for n in range(nrentries-1):
        x = n*(wd+dist)
        c.stroke(path.curve(x-dist/3, ht+0.5*dist,
                            x+0.3*wd, ht+3*dist,
                            x+0.7*wd, ht+3*dist,
                            x+wd+dist/3, ht+0.5*dist),
                 [deco.earrow.large])
        c.text(x+0.5*wd, ht+3.2*dist, r'\Large 8', [text.halign.center, textcolor])

    if lowerstride:
        for n in range((nrentries-1)//lowerstride):
            x = n*lowerstride*(wd+dist)
            c.stroke(path.curve(x-dist/3, -0.5*dist,
                                x+0.5*wd, -5*dist,
                                x+(lowerstride-0.5)*wd+lowerstride*dist, -5*dist,
                                x+lowerstride*wd+(lowerstride-0.7)*dist, -0.5*dist),
                     [deco.earrow.large])
            c.text(x+0.5*lowerstride*wd+dist,-5.2*dist, r'\Large %i' % (lowerstride*8),
                   [text.halign.center, text.valign.top, textcolor])
Exemple #3
0
    def rect(self, x, y, width, height, roundness=0.0, draw=True, **kwargs):
        """Draw a rectangle.

        :param x: top left x-coordinate
        :param y: top left y-coordinate
        :param width: rectangle width
        :param height: rectangle height
        :param roundness: rounded corner radius
        :param boolean draw: whether to draw the shape on the canvas or not
        :param fill: fill color
        :return: BezierPath representing the rectangle
        """
        path = self.BezierPath(**kwargs)
        path.rect(x, y, width, height, roundness, self.rectmode)
        if draw:
            path.draw()
        return path
Exemple #4
0
    def rect(self, x, y, width, height, roundness=0.0, draw=True, **kwargs):
        '''
        Draw a rectangle from x, y of width, height.

        :param startx: top left x-coordinate
        :param starty: top left y-coordinate

        :param width: height  Size of rectangle.
        :roundness: Corner roundness defaults to 0.0 (a right-angle).
        :draw: If True draws immediately.
        :fill: Optionally pass a fill color.

        :return: path representing the rectangle.

        '''
        path = self.BezierPath(**kwargs)
        path.rect(x, y, width, height, roundness, self.rectmode)
        if draw:
            path.draw()
        return path
Exemple #5
0
    def rect(self, x, y, width, height, roundness=0.0, draw=True, **kwargs):
        '''
        Draw a rectangle from x, y of width, height.

        :param startx: top left x-coordinate
        :param starty: top left y-coordinate

        :param width: height  Size of rectangle.
        :roundness: Corner roundness defaults to 0.0 (a right-angle).
        :draw: If True draws immediately.
        :fill: Optionally pass a fill color.

        :return: path representing the rectangle.

        '''
        path = self.BezierPath(**kwargs)
        path.rect(x, y, width, height, roundness, self.rectmode)
        if draw:
            path.draw()
        return path
Exemple #6
0
 def clipBox(self, x, y, width, height):
     path = self.c.beginPath()
     path.rect(x, y, width, height)
     self.c.clipPath(path, stroke = 1, fill = 0)