• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shapes.Group类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reportlab.graphics.shapes.Group的典型用法代码示例。如果您正苦于以下问题:Python Group类的具体用法?Python Group怎么用?Python Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Group类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _Flag_Japan

 def _Flag_Japan(self):
     s = _size
     g = Group()
     w = self._width = s*1.5
     g.add(Rect(0,0,w,s,fillColor=colors.mintcream,strokeColor=None, strokeWidth=0))
     g.add(Circle(cx=w/2,cy=s/2,r=0.3*w,fillColor=colors.red,strokeColor=None, strokeWidth=0))
     return g
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:7,代码来源:flags.py


示例2: makeSwatchSample

    def makeSwatchSample(self,rowNo, x, y, width, height):
        baseStyle = self.lines
        styleIdx = rowNo % len(baseStyle)
        style = baseStyle[styleIdx]
        color = style.strokeColor
        y = y+height/2.
        if self.joinedLines:
            dash = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None))
            strokeWidth= getattr(style, 'strokeWidth', getattr(style, 'strokeWidth',None))
            L = Line(x,y,x+width,y,strokeColor=color,strokeLineCap=0)
            if strokeWidth: L.strokeWidth = strokeWidth
            if dash: L.strokeDashArray = dash
        else:
            L = None

        if hasattr(style, 'symbol'):
            S = style.symbol
        elif hasattr(baseStyle, 'symbol'):
            S = baseStyle.symbol
        else:
            S = None

        if S: S = uSymbol2Symbol(S,x+width/2.,y,color)
        if S and L:
            g = Group()
            g.add(L)
            g.add(S)
            return g
        return S or L
开发者ID:wolf29,项目名称:EG-notifications,代码行数:29,代码来源:linecharts.py


示例3: draw

    def draw(self):
        self.qr.make()

        g = Group()

        color = self.barFillColor
        border = self.barBorder
        width = self.barWidth
        height = self.barHeight
        x = self.x
        y = self.y

        g.add(SRect(x, y, width, height, fillColor=None))

        moduleCount = self.qr.getModuleCount()
        minwh = float(min(width, height))
        boxsize = minwh / (moduleCount + border * 2.0)
        offsetX = (width - minwh) / 2.0
        offsetY = (minwh - height) / 2.0

        for r, row in enumerate(self.qr.modules):
            row = map(bool, row)
            c = 0
            for t, tt in itertools.groupby(row):
                isDark = t
                count = len(list(tt))
                if isDark:
                    x = (c + border) * boxsize
                    y = (r + border + 1) * boxsize
                    s = SRect(offsetX + x, offsetY + height - y, count * boxsize, boxsize)
                    g.add(s)
                c += count

        return g
开发者ID:Aeium,项目名称:dotStudio,代码行数:34,代码来源:qr.py


示例4: renderUse

    def renderUse(self, node, group=None, clipping=None):
        if group is None:
            group = Group()

        xlink_href = node.attrib.get('{http://www.w3.org/1999/xlink}href')
        if not xlink_href:
            return
        if xlink_href[1:] not in self.definitions:
            # The missing definition should appear later in the file
            self.waiting_use_nodes[xlink_href[1:]].append((node, group))
            return group

        if clipping:
            group.add(clipping)
        if len(node.getchildren()) == 0:
            # Append a copy of the referenced node as the <use> child (if not already done)
            node.append(copy.deepcopy(self.definitions[xlink_href[1:]]))
        self.renderNode(node.getchildren()[-1], parent=group)
        getAttr = node.getAttribute
        transform = getAttr("transform")
        x, y = map(getAttr, ("x", "y"))
        if x or y:
            transform += " translate(%s, %s)" % (x or '0', y or '0')
        if transform:
            self.shape_converter.applyTransformOnGroup(transform, group)
        return group
开发者ID:pacoqueen,项目名称:ginn,代码行数:26,代码来源:svglib.py


示例5: convertPolyline

    def convertPolyline(self, node):
        getAttr = node.getAttribute
        points = getAttr("points")
        points = points.replace(',', ' ')
        points = points.split()
        points = list(map(self.attrConverter.convertLength, points))
        if len(points) % 2 != 0 or len(points) == 0:
            # Odd number of coordinates or no coordinates, invalid polyline
            return None

        polyline = PolyLine(points)
        self.applyStyleOnShape(polyline, node)
        has_fill = self.attrConverter.findAttr(node, 'fill') not in ('', 'none')

        if has_fill:
            # ReportLab doesn't fill polylines, so we are creating a polygon
            # polygon copy of the polyline, but without stroke.
            group = Group()
            polygon = Polygon(points)
            self.applyStyleOnShape(polygon, node)
            polygon.strokeColor = None
            group.add(polygon)
            group.add(polyline)
            return group

        return polyline
开发者ID:pacoqueen,项目名称:ginn,代码行数:26,代码来源:svglib.py


示例6: makeSwatchSample

    def makeSwatchSample(self,rowNo, x, y, width, height):
        styleCount = len(self.lines)
        styleIdx = rowNo % styleCount
        rowColor = self.lines[styleIdx].strokeColor

        if self.joinedLines:
            dash = getattr(self.lines[styleIdx], 'strokeDashArray', getattr(self.lines,'strokeDashArray',None))
            strokeWidth= getattr(self.lines[styleIdx], 'strokeWidth', getattr(self.lines[styleIdx], 'strokeWidth',None))
            L = Line(x,y,x+width,y+height,strokeColor=rowColor,strokeLineCap=0)
            if strokeWidth: L.strokeWidth = strokeWidth
            if dash: L.strokeDashArray = dash
        else:
            L = None

        if hasattr(self.lines[styleIdx], 'symbol'):
            S = self.lines[styleIdx].symbol
        elif hasattr(self.lines, 'symbol'):
            S = self.lines.symbol
        else:
            S = None

        if S: S = uSymbol2Symbol(S,x+width/2.,y+height/2.,rowColor)
        if S and L:
            g = Group()
            g.add(S)
            g.add(L)
            return g
        return S or L
开发者ID:eaudeweb,项目名称:naaya,代码行数:28,代码来源:lineplots.py


示例7: makeInnerTiles

    def makeInnerTiles(self):
        # inner grid lines
        group = Group()

        w, h = self.width, self.height

        # inner grid stripes (solid rectangles)
        if self.useRects == 1:
            cols = self.stripeColors

            if self.orientation == 'vertical':
                r = self.makeLinePosList(self.x, isX=1)
            elif self.orientation == 'horizontal':
                r = self.makeLinePosList(self.y, isX=0)

            dist = makeDistancesList(r)

            i = 0
            for j in range(len(dist)):
                if self.orientation == 'vertical':
                    x = r[j]
                    stripe = Rect(x, self.y, dist[j], h)
                elif self.orientation == 'horizontal':
                    y = r[j]
                    stripe = Rect(self.x, y, w, dist[j])
                stripe.fillColor = cols[i % len(cols)]
                stripe.strokeColor = None
                group.add(stripe)
                i = i + 1

        return group
开发者ID:halimath,项目名称:taskcardmaker,代码行数:31,代码来源:grids.py


示例8: rotatedEnclosingRect

def rotatedEnclosingRect(P, angle, rect):
    '''
    given P a sequence P of x,y coordinate pairs and an angle in degrees
    find the centroid of P and the axis at angle theta through it
    find the extreme points of P wrt axis parallel distance and axis
    orthogonal distance. Then compute the least rectangle that will still
    enclose P when rotated by angle.

    The class R
    '''
    from math import pi, cos, sin, tan
    x0, y0 = centroid(P)
    theta = (angle/180.)*pi
    s,c=sin(theta),cos(theta)
    def parallelAxisDist(xy,s=s,c=c,x0=x0,y0=y0):
        x,y = xy
        return (s*(y-y0)+c*(x-x0))
    def orthogonalAxisDist(xy,s=s,c=c,x0=x0,y0=y0):
        x,y = xy
        return (c*(y-y0)+s*(x-x0))
    L = map(parallelAxisDist,P)
    L.sort()
    a0, a1 = L[0], L[-1]
    L = map(orthogonalAxisDist,P)
    L.sort()
    b0, b1 = L[0], L[-1]
    rect.x, rect.width = a0, a1-a0
    rect.y, rect.height = b0, b1-b0
    g = Group(transform=(c,s,-s,c,x0,y0))
    g.add(rect)
    return g
开发者ID:halimath,项目名称:taskcardmaker,代码行数:31,代码来源:grids.py


示例9: getTalkRect

    def getTalkRect(self, startTime, duration, trackId, text):
        "Return shapes for a specific talk"
        g = Group()
        y_bottom = self.scaleTime(startTime + duration)
        y_top = self.scaleTime(startTime)
        y_height = y_top - y_bottom

        if trackId is None:
            #spans all columns
            x = self._colLeftEdges[1]
            width = self.width - self._colWidths[0]
        else:
            #trackId is 1-based and these arrays have the margin info in column
            #zero, so no need to add 1
            x = self._colLeftEdges[trackId]
            width = self._colWidths[trackId]

        lab = Label()
        lab.setText(text)
        lab.setOrigin(x + 0.5*width, y_bottom+0.5*y_height)
        lab.boxAnchor = 'c'
        lab.width = width
        lab.height = y_height
        lab.fontSize = 6

        r = Rect(x, y_bottom, width, y_height, fillColor=colors.cyan)
        g.add(r)
        g.add(lab)

        #now for a label
        # would expect to color-code and add text
        return g
开发者ID:tschalch,项目名称:pyTray,代码行数:32,代码来源:eventcal.py


示例10: ttf_ocr

def ttf_ocr(font, key=None):
    gs = font.getGlyphSet()
    keys = [key for key in gs.keys() if key.startswith("uni")] if key is None else [key]
    c = []
    for i, key in enumerate(keys):
        if key not in gs:
            logger.info("No this key: %s" % key)
            c.append("")
            continue
        pen = ReportLabPen(gs, Path(fillColor=colors.black, strokeWidth=0.01))
        g = gs[key]
        g.draw(pen)
        w, h = 50, 50
        g = Group(pen.path)
        g.translate(10, 10)
        g.scale(0.02, 0.02)
        d = Drawing(w, h)
        d.add(g)
        renderPM.drawToFile(d, png_file.name, fmt="PNG")
        result = os.popen("tesseract %s stdout -l chi_sim -psm 5" % png_file.name).read().strip().decode("utf-8",
                                                                                                         "ignore")
        if len(result) != 1:
            result = os.popen("tesseract %s stdout -l chi_sim -psm 8" % png_file.name).read().strip().decode("utf-8",
                                                                                                             "ignore")
        logger.info("key: %s, result: %s" % (key, result))
        c.append(result)
    if key is not None:
        return c[0]
    return c
开发者ID:a625687551,项目名称:Spyder,代码行数:29,代码来源:autogg.py


示例11: _Flag_Spain

 def _Flag_Spain(self):
     s = _size
     g = Group()
     w = self._width = s*1.5
     g.add(Rect(0, 0, width=w, height=s, fillColor = colors.red, strokeColor = None, strokeWidth=0))
     g.add(Rect(0, (s/4), width=w, height=s/2, fillColor = colors.yellow, strokeColor = None, strokeWidth=0))
     return g
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:7,代码来源:flags.py


示例12: makeSwatchSample

 def makeSwatchSample(self, rowNo, x, y, width, height):
     baseStyle = self.strands
     styleIdx = rowNo % len(baseStyle)
     style = baseStyle[styleIdx]
     strokeColor = getattr(style, 'strokeColor', getattr(baseStyle,'strokeColor',None))
     fillColor = getattr(style, 'fillColor', getattr(baseStyle,'fillColor',None))
     strokeDashArray = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None))
     strokeWidth = getattr(style, 'strokeWidth', getattr(baseStyle, 'strokeWidth',0))
     symbol = getattr(style, 'symbol', getattr(baseStyle, 'symbol',None))
     ym = y+height/2.0
     if fillColor is None and strokeColor is not None and strokeWidth>0:
         bg = Line(x,ym,x+width,ym,strokeWidth=strokeWidth,strokeColor=strokeColor,
                 strokeDashArray=strokeDashArray)
     elif fillColor is not None:
         bg = Rect(x,y,width,height,strokeWidth=strokeWidth,strokeColor=strokeColor,
                 strokeDashArray=strokeDashArray,fillColor=fillColor)
     else:
         bg = None
     if symbol:
         symbol = uSymbol2Symbol(symbol,x+width/2.,ym,color)
         if bg:
             g = Group()
             g.add(bg)
             g.add(symbol)
             return g
     return symbol or bg
开发者ID:makinacorpus,项目名称:reportlab-ecomobile,代码行数:26,代码来源:spider.py


示例13: makeCircularString

def makeCircularString(x, y, radius, angle, text, fontName, fontSize, inside=0, G=None,textAnchor='start'):
    '''make a group with circular text in it'''
    if not G: G = Group()

    angle %= 360
    pi180 = pi/180
    phi = angle*pi180
    width = stringWidth(text, fontName, fontSize)
    sig = inside and -1 or 1
    hsig = sig*0.5
    sig90 = sig*90

    if textAnchor!='start':
        if textAnchor=='middle':
            phi += sig*(0.5*width)/radius
        elif textAnchor=='end':
            phi += sig*float(width)/radius
        elif textAnchor=='numeric':
            phi += sig*float(numericXShift(textAnchor,text,width,fontName,fontSize,None))/radius

    for letter in text:
        width = stringWidth(letter, fontName, fontSize)
        beta = float(width)/radius
        h = Group()
        h.add(String(0, 0, letter, fontName=fontName,fontSize=fontSize,textAnchor="start"))
        h.translate(x+cos(phi)*radius,y+sin(phi)*radius)    #translate to radius and angle
        h.rotate((phi-hsig*beta)/pi180-sig90)               # rotate as needed
        G.add(h)                                            #add to main group
        phi -= sig*beta                                     #increment

    return G
开发者ID:Aeium,项目名称:dotStudio,代码行数:31,代码来源:utils.py


示例14: annotation

 def annotation(self,xScale,yScale):
     x = xScale(xv)
     y = yScale(yv)
     g = Group()
     xA = xScale.im_self #the x axis
     g.add(Line(xA._x,y,xA._x+xA._length,y,strokeColor=strokeColor,strokeWidth=strokeWidth))
     yA = yScale.im_self #the y axis
     g.add(Line(x,yA._y,x,yA._y+yA._length,strokeColor=strokeColor,strokeWidth=strokeWidth))
     return g
开发者ID:SongJLG,项目名称:johan-doc,代码行数:9,代码来源:lineplots.py


示例15: _Flag_Cuba

    def _Flag_Cuba(self):
        s = _size
        g = Group()

        for i in range(5):
            stripe = Rect(0, i*s/5, width=s*2, height=s/5,
                fillColor = [colors.darkblue, colors.mintcream][i%2],
                strokeColor = None,
                strokeWidth=0)
            g.add(stripe)

        redwedge = Polygon(points = [ 0, 0, 4*s/5, (s/2), 0, s],
                    fillColor = colors.red, strokeColor = None, strokeWidth=0)
        g.add(redwedge)

        star = Star()
        star.x = 2.5*s/10
        star.y = s/2
        star.size = 3*s/10
        star.fillColor = colors.white
        g.add(star)

        box = Rect(0, 0, s*2, s,
            fillColor = None,
            strokeColor = colors.black,
            strokeWidth=0)
        g.add(box)

        return g
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:29,代码来源:flags.py


示例16: draw

 def draw(self):
     P = self.points
     P = list(map(lambda i, P=P: (P[i], P[i + 1]), range(0, len(P), 2)))
     path = definePath(
         [("moveTo",) + P[0]] + [("lineTo",) + x for x in P[1:]] + ["closePath"], fillColor=None, strokeColor=None
     )
     path.isClipPath = 1
     g = Group()
     g.add(path)
     angle = self.angle
     orientation = "vertical"
     if angle == 180:
         angle = 0
     elif angle in (90, 270):
         orientation = "horizontal"
         angle = 0
     rect = ShadedRect(strokeWidth=0, strokeColor=None, orientation=orientation)
     for k in "fillColorStart", "fillColorEnd", "numShades", "cylinderMode":
         setattr(rect, k, getattr(self, k))
     g.add(rotatedEnclosingRect(P, angle, rect))
     g.add(EmptyClipPath)
     path = path.copy()
     path.isClipPath = 0
     path.strokeColor = self.strokeColor
     path.strokeWidth = self.strokeWidth
     g.add(path)
     return g
开发者ID:FatihZor,项目名称:infernal-twin,代码行数:27,代码来源:grids.py


示例17: _Flag_France

    def _Flag_France(self):
        s = _size
        g = Group()

        box = Rect(0, 0, s * 2, s, fillColor=colors.navy, strokeColor=colors.black, strokeWidth=0)
        g.add(box)

        bluebox = Rect(0, 0, width=((s / 3.0) * 2.0), height=s, fillColor=colors.blue, strokeColor=None, strokeWidth=0)
        g.add(bluebox)

        whitebox = Rect(
            ((s / 3.0) * 2.0),
            0,
            width=((s / 3.0) * 2.0),
            height=s,
            fillColor=colors.mintcream,
            strokeColor=None,
            strokeWidth=0,
        )
        g.add(whitebox)

        redbox = Rect(
            ((s / 3.0) * 4.0),
            0,
            width=((s / 3.0) * 2.0),
            height=s,
            fillColor=colors.red,
            strokeColor=None,
            strokeWidth=0,
        )
        g.add(redbox)
        return g
开发者ID:ziberleon,项目名称:abejas,代码行数:32,代码来源:flags.py


示例18: _Flag_Palestine

    def _Flag_Palestine(self):
        s = _size
        g = Group()
        box = Rect(0, s/3, s*2, s/3,
            fillColor = colors.mintcream,
                        strokeColor = None,
            strokeWidth=0)
        g.add(box)

        greenbox = Rect(0, 0, width=s*2, height=s/3,
            fillColor = colors.limegreen,
            strokeColor = None,
            strokeWidth=0)
        g.add(greenbox)

        blackbox = Rect(0, 2*s/3, width=s*2, height=s/3,
            fillColor = colors.black,
            strokeColor = None,
            strokeWidth=0)
        g.add(blackbox)

        redwedge = Polygon(points = [ 0, 0, 2*s/3, (s/2), 0, s],
                    fillColor = colors.red, strokeColor = None, strokeWidth=0)
        g.add(redwedge)
        return g
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:25,代码来源:flags.py


示例19: draw

 def draw(self):
     P = self.points
     P = map(lambda i, P=P:(P[i],P[i+1]),xrange(0,len(P),2))
     path = definePath([('moveTo',)+P[0]]+map(lambda x: ('lineTo',)+x,P[1:])+['closePath'],
         fillColor=None, strokeColor=None)
     path.isClipPath = 1
     g = Group()
     g.add(path)
     angle = self.angle
     orientation = 'vertical'
     if angle==180:
         angle = 0
     elif angle in (90,270):
         orientation ='horizontal'
         angle = 0
     rect = ShadedRect(strokeWidth=0,strokeColor=None,orientation=orientation)
     for k in 'fillColorStart', 'fillColorEnd', 'numShades', 'cylinderMode':
         setattr(rect,k,getattr(self,k))
     g.add(rotatedEnclosingRect(P, angle, rect))
     g.add(EmptyClipPath)
     path = path.copy()
     path.isClipPath = 0
     path.strokeColor = self.strokeColor
     path.strokeWidth = self.strokeWidth
     g.add(path)
     return g
开发者ID:pediapress,项目名称:mwlib.ext,代码行数:26,代码来源:grids.py


示例20: _Flag_Turkey

    def _Flag_Turkey(self):
        s = _size
        g = Group()

        box = Rect(0, 0, s*2, s,
            fillColor = colors.red,
                        strokeColor = colors.black,
            strokeWidth=0)
        g.add(box)

        whitecircle = Circle(cx=((s*0.35)*2), cy=s/2, r=s*0.3,
            fillColor = colors.mintcream,
            strokeColor = None,
            strokeWidth=0)
        g.add(whitecircle)

        redcircle = Circle(cx=((s*0.39)*2), cy=s/2, r=s*0.24,
            fillColor = colors.red,
            strokeColor = None,
            strokeWidth=0)
        g.add(redcircle)

        ws = Star()
        ws.angle = 15
        ws.size = s/5
        ws.x = (s*0.5)*2+ws.size/2
        ws.y = (s*0.5)
        ws.fillColor = colors.mintcream
        ws.strokeColor = None
        g.add(ws)
        return g
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:31,代码来源:flags.py



注:本文中的reportlab.graphics.shapes.Group类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shapes.Line类代码示例发布时间:2022-05-26
下一篇:
Python shapes.Drawing类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap