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

Python shapes.Rect类代码示例

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

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



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

示例1: create_header

    def create_header(self):
        headerCanvas = Drawing()
        headerRect = Rect(0, 0, width=self.width, height=50)
        headerRect.fillColor = HexColor("#607D8B")
        headerRect.strokeColor = HexColor("#607D8B")
        headerCanvas.add(headerRect)
        renderPDF.draw(headerCanvas, self.c, 0, self.height - 50)

        _header_styles = ParagraphStyle(
            "Header",
            parent=self.styles["Heading1"],
            textColor=white,
            fontName='Helvetica'
        )
        p = Paragraph("Kit Trading Fund Report", style = _header_styles)

        p.wrapOn(self.c, self.width, self.height - 50)
        p.drawOn(self.c, *self.coord(75, 10, mm))

        _sub_header_styles = ParagraphStyle(
            "SubHeader",
            parent=self.styles["Heading4"],
            textColor=white,
            fontName='Helvetica'
        )
        p = Paragraph("Monthly Report: January 2016", style = _sub_header_styles)
        p.wrapOn(self.c, self.width, self.height - 50)
        p.drawOn(self.c, *self.coord(85, 16, mm))
开发者ID:denisvolokh,项目名称:reportlab-report-prototype,代码行数:28,代码来源:main2.py


示例2: 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


示例3: makeSwatchSample

    def makeSwatchSample(self,rowNo, x, y, width, height):
        baseStyle = self.lines
        styleIdx = rowNo % len(baseStyle)
        style = baseStyle[styleIdx]
        color = style.strokeColor
        yh2 = y+height/2.
        lineStyle = getattr(style,'lineStyle',None)
        if lineStyle=='bar':
            dash = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None))
            strokeWidth= getattr(style, 'strokeWidth', getattr(style, 'strokeWidth',None))
            L = Rect(x,y,width,height,strokeWidth=strokeWidth,strokeColor=color,strokeLineCap=0,strokeDashArray=dash,fillColor=getattr(style,'fillColor',color))
        elif self.joinedLines or lineStyle=='joinedLine':
            dash = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None))
            strokeWidth= getattr(style, 'strokeWidth', getattr(style, 'strokeWidth',None))
            L = Line(x,yh2,x+width,yh2,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.,yh2,color)
        if S and L:
            g = Group()
            g.add(L)
            g.add(S)
            return g
        return S or L
开发者ID:7o9,项目名称:stdm-plugin,代码行数:34,代码来源:linecharts.py


示例4: _draw_segment

    def _draw_segment(self, cur_drawing):
        """Draw the current chromosome segment.
        """
        # set the coordinates of the segment -- it'll take up the MIDDLE part
        # of the space we have.
        segment_y = self.end_y_position
        segment_width = (self.end_x_position - self.start_x_position) \
                        * self.chr_percent
        segment_height = self.start_y_position - self.end_y_position
        segment_x = self.start_x_position \
                  + 0.5 * (self.end_x_position - self.start_x_position - segment_width)

        # first draw the sides of the segment
        right_line = Line(segment_x, segment_y,
                          segment_x, segment_y + segment_height)
        left_line = Line(segment_x + segment_width, segment_y,
                         segment_x + segment_width, segment_y + segment_height)

        cur_drawing.add(right_line)
        cur_drawing.add(left_line)

        # now draw the box, if it is filled in
        if self.fill_color is not None:
            fill_rectangle = Rect(segment_x, segment_y,
                                  segment_width, segment_height)
            fill_rectangle.fillColor = self.fill_color
            fill_rectangle.strokeColor = None

            cur_drawing.add(fill_rectangle)
开发者ID:sip958,项目名称:biopython,代码行数:29,代码来源:BasicChromosome.py


示例5: colorTest

    def colorTest(self):
        from reportlab.graphics.shapes import Rect
        from reportlab.graphics.charts.textlabels import Label
        self.colorRangeStatic(130)

        dim=25
        width = self.PAGE_WIDTH-150
        inrow = 8 #int(width/dim)
        height = int(len(self.colors)/inrow)
        if len(self.colors)%inrow > 0:
            height +=1
        height *= dim
        drawing = Drawing(width, height)
        for i,col in enumerate(self.colors):
            x = (i%inrow)*dim
            y = int(i/inrow)*dim
            rec = Rect(x=x,y=y,width=dim,height=dim)
            rec.fillColor = col
            drawing.add(rec)
            lab = Label()
            lab.x=x+dim/2
            lab.y=y+dim/2
            lab.setText('%d'%i)
            drawing.add(lab)
        return drawing
开发者ID:jhuguetn,项目名称:WAD_Python,代码行数:25,代码来源:reporter.py


示例6: _draw_square

 def _draw_square(self, color):
     "draws a square"
     square = Drawing(5, 5)
     sqr = Rect(0, 2.5, 5, 5)
     sqr.fillColor = color
     sqr.strokeColor = color
     square.add(sqr)
     return square
开发者ID:aureg,项目名称:baruwa2,代码行数:8,代码来源:graphs.py


示例7: makeEmptySquare

def makeEmptySquare(x, y, size, color):
    "Make an empty square marker."

    d = size/2.0
    rect = Rect(x-d, y-d, 2*d, 2*d)
    rect.strokeColor = color
    rect.fillColor = None

    return rect
开发者ID:Dongminator,项目名称:CV-Management-tool,代码行数:9,代码来源:markers.py


示例8: makeFilledSquare

def makeFilledSquare(x, y, size, color):
    "Make a filled square marker."

    d = size/2.0
    rect = Rect(x-d, y-d, 2*d, 2*d)
    rect.strokeColor = color
    rect.fillColor = color

    return rect
开发者ID:Dongminator,项目名称:CV-Management-tool,代码行数:9,代码来源:markers.py


示例9: draw_square

def draw_square(color):
    "draws a square"
    from reportlab.graphics.shapes import Rect
    from reportlab.graphics.shapes import Drawing

    square = Drawing(5, 5)
    sqr = Rect(0, 2.5, 5, 5)
    sqr.fillColor = color
    sqr.strokeColor = color
    square.add(sqr)
    return square
开发者ID:sandroden,项目名称:baruwa,代码行数:11,代码来源:sendpdfreports.py


示例10: makeOuterRect

 def makeOuterRect(self):
     strokeColor = getattr(self,'rectStrokeColor',self.strokeColor)
     strokeWidth = getattr(self,'rectStrokeWidth',self.strokeWidth)
     if self.fillColor or (strokeColor and strokeWidth):
         rect = Rect(self.x, self.y, self.width, self.height)
         rect.fillColor = self.fillColor
         rect.strokeColor = strokeColor
         rect.strokeWidth = strokeWidth
         return rect
     else:
         return None
开发者ID:halimath,项目名称:taskcardmaker,代码行数:11,代码来源:grids.py


示例11: draw

    def draw(self):
        # general widget bits
        group = Group()
        x, y, w, h, c0, c1 = self._flipRectCorners()
        numShades = self.numShades
        if self.cylinderMode:
            if not numShades % 2: numShades = numShades + 1
            halfNumShades = (numShades - 1) / 2 + 1
        num = float(numShades)  # must make it float!
        vertical = self.orientation == 'vertical'
        if vertical:
            if numShades == 1:
                V = [x]
            else:
                V = frange(x, x + w, w / num)
        else:
            if numShades == 1:
                V = [y]
            else:
                V = frange(y, y + h, h / num)

        for v in V:
            stripe = vertical and Rect(v, y, w / num, h) or Rect(
                x, v, w, h / num)
            if self.cylinderMode:
                if V.index(v) >= halfNumShades:
                    col = colors.linearlyInterpolatedColor(
                        c1, c0, V[halfNumShades], V[-1], v)
                else:
                    col = colors.linearlyInterpolatedColor(
                        c0, c1, V[0], V[halfNumShades], v)
            else:
                col = colors.linearlyInterpolatedColor(c0, c1, V[0], V[-1], v)
            stripe.fillColor = col
            stripe.strokeColor = col
            stripe.strokeWidth = 1
            group.add(stripe)
        if self.strokeColor and self.strokeWidth >= 0:
            rect = Rect(x, y, w, h)
            rect.strokeColor = self.strokeColor
            rect.strokeWidth = self.strokeWidth
            rect.fillColor = None
            group.add(rect)
        return group
开发者ID:radical-software,项目名称:radicalspam,代码行数:44,代码来源:grids.py


示例12: create_risk_header

    def create_risk_header(self):
        _width = self.width / 2 - 10
        _height = 20
        headerCanvas = Drawing()
        headerRect = Rect(0, 0, width = _width, height = _height)
        headerRect.fillColor = HexColor("#607D8B")
        headerRect.strokeColor = HexColor("#607D8B")
        headerCanvas.add(headerRect)
        renderPDF.draw(headerCanvas, self.c, x = _width + 20, y = self.height - 75)

        _summary_styles = ParagraphStyle(
            "RISKS",
            parent=self.styles["Heading5"],
            textColor=white,
            fontName='Helvetica'
        )
        p = Paragraph("RISKS", style = _summary_styles)
        p.wrapOn(self.c, _width, _height)
        p.drawOn(self.c, *self.coord(115, 25, mm))
开发者ID:denisvolokh,项目名称:reportlab-report-prototype,代码行数:19,代码来源:main2.py


示例13: create_performance_chart_header

    def create_performance_chart_header(self):
        _width = self.width
        _height = 20
        headerCanvas = Drawing()
        headerRect = Rect(0, 0, width = _width, height = _height)
        headerRect.fillColor = HexColor("#607D8B")
        headerRect.strokeColor = HexColor("#607D8B")
        headerCanvas.add(headerRect)
        renderPDF.draw(headerCanvas, self.c, 0, self.height - 217)

        _summary_styles = ParagraphStyle(
            "PERFORMANCE CHART",
            parent=self.styles["Heading5"],
            textColor=white,
            fontName='Helvetica'
        )
        p = Paragraph("PERFORMANCE", style = _summary_styles)
        p.wrapOn(self.c, _width, _height)
        p.drawOn(self.c, *self.coord(4, 75, mm))
开发者ID:denisvolokh,项目名称:reportlab-report-prototype,代码行数:19,代码来源:main2.py


示例14: _overdraw_subcomponents

    def _overdraw_subcomponents(self, cur_drawing):
        """Draw any annotated features on the chromosome segment.

        Assumes _draw_segment already called to fill out the basic shape,
        and assmes that uses the same boundaries.
        """
        # set the coordinates of the segment -- it'll take up the MIDDLE part
        # of the space we have.
        segment_y = self.end_y_position
        segment_width = (self.end_x_position - self.start_x_position) \
                        * self.chr_percent
        label_sep = (self.end_x_position - self.start_x_position) \
                        * self.label_sep_percent
        segment_height = self.start_y_position - self.end_y_position
        segment_x = self.start_x_position \
                  + 0.5 * (self.end_x_position - self.start_x_position - segment_width)

        left_labels = []
        right_labels = []
        for f in self.features:
            try:
                # Assume SeqFeature objects
                start = f.location.start
                end = f.location.end
                strand = f.strand
                try:
                    # Handles Artemis colour integers, HTML colors, etc
                    color = _color_trans.translate(f.qualifiers['color'][0])
                except Exception:  # TODO: ValueError?
                    color = self.default_feature_color
                fill_color = color
                name = ""
                for qualifier in self.name_qualifiers:
                    if qualifier in f.qualifiers:
                        name = f.qualifiers[qualifier][0]
                        break
            except AttributeError:
                # Assume tuple of ints, string, and color
                start, end, strand, name, color = f[:5]
                color = _color_trans.translate(color)
                if len(f) > 5:
                    fill_color = _color_trans.translate(f[5])
                else:
                    fill_color = color
            assert 0 <= start <= end <= self.bp_length
            if strand == +1:
                # Right side only
                x = segment_x + segment_width * 0.6
                w = segment_width * 0.4
            elif strand == -1:
                # Left side only
                x = segment_x
                w = segment_width * 0.4
            else:
                # Both or neither - full width
                x = segment_x
                w = segment_width
            local_scale = segment_height / self.bp_length
            fill_rectangle = Rect(x, segment_y + segment_height - local_scale * start,
                                  w, local_scale * (start - end))
            fill_rectangle.fillColor = fill_color
            fill_rectangle.strokeColor = color
            cur_drawing.add(fill_rectangle)
            if name:
                if fill_color == color:
                    back_color = None
                else:
                    back_color = fill_color
                value = (segment_y + segment_height - local_scale * start, color, back_color, name)
                if strand == -1:
                    self._left_labels.append(value)
                else:
                    self._right_labels.append(value)
开发者ID:sip958,项目名称:biopython,代码行数:73,代码来源:BasicChromosome.py


示例15: __init__

 def __init__(self, x, y, width, height, fillColor=colors.black):
     Rect.__init__(self, x, y, width, height, fillColor=fillColor,
                   strokeColor=None, strokeWidth=0)
开发者ID:Aeium,项目名称:dotStudio,代码行数:3,代码来源:qr.py


示例16: draw

    def draw(self):
        g = Group()
        colorNamePairs = self.colorNamePairs
        thisx = upperleftx = self.x
        thisy = upperlefty = self.y - self.dy
        dx, dy, alignment, columnMaximum = self.dx, self.dy, self.alignment, self.columnMaximum
        deltax, deltay, dxTextSpace = self.deltax, self.deltay, self.dxTextSpace
        fontName, fontSize, fillColor = self.fontName, self.fontSize, self.fillColor
        strokeWidth, strokeColor = self.strokeWidth, self.strokeColor
        leading = fontSize*1.2
        if not deltay:
            deltay = max(dy,leading)+self.autoYPadding
        if not deltax:
            maxWidth = self._calculateMaxWidth(colorNamePairs)
            deltax = maxWidth+dx+dxTextSpace+self.autoXPadding
        else:
            if alignment=='left': maxWidth = self._calculateMaxWidth(colorNamePairs)

        def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor):
            t.fontName = fontName
            t.fontSize = fontSize
            t.fillColor = fillColor
            return g.add(t)

        ascent=getFont(fontName).face.ascent/1000.
        if ascent==0: ascent=0.718 # default (from helvetica)
        ascent=ascent*fontSize # normalize

        columnCount = 0
        count = 0
        callout = getattr(self,'callout',None)
        for col, name in colorNamePairs:
            T = string.split(name and str(name) or '','\n')
            S = []
            # thisy+dy/2 = y+leading/2
            y = thisy+(dy-ascent)*0.5
            if callout: callout(self,g,thisx,y,colorNamePairs[count])
            if alignment == "left":
                for t in T:
                    # align text to left
                    s = String(thisx+maxWidth,y,t)
                    s.textAnchor = "end"
                    S.append(s)
                    y = y-leading
                x = thisx+maxWidth+dxTextSpace
            elif alignment == "right":
                for t in T:
                    # align text to right
                    s = String(thisx+dx+dxTextSpace, y, t)
                    s.textAnchor = "start"
                    S.append(s)
                    y = y-leading
                x = thisx
            else:
                raise ValueError, "bad alignment"

            # Make a 'normal' color swatch...
            if isinstance(col, colors.Color):
                r = Rect(x, thisy, dx, dy)
                r.fillColor = col
                r.strokeColor = strokeColor
                r.strokeWidth = strokeWidth
                g.add(r)
            else:
                #try and see if we should do better.
                try:
                    c = copy.deepcopy(col)
                    c.x = x
                    c.y = thisy
                    c.width = dx
                    c.height = dy
                    g.add(c)
                except:
                    pass

            map(gAdd,S)

            if count%columnMaximum == columnMaximum-1:
                thisx = thisx+deltax
                thisy = upperlefty
                columnCount = columnCount + 1
            else:
                thisy = thisy-max(deltay,len(S)*leading)
            count = count+1

        return g
开发者ID:eaudeweb,项目名称:naaya,代码行数:86,代码来源:legends.py


示例17: Rect

    """
>>> from reportlab.graphics.shapes import Rect
>>> from reportlab.lib.colors import red, green
>>> r = Rect(5, 5, 200, 100)
>>> r.fillColor = red
>>> r.strokeColor = green
>>> r.strokeWidth = 3
>>>
"""
)

from reportlab.graphics.shapes import Rect
from reportlab.lib.colors import red, green

d = Drawing(220, 120)
r = Rect(5, 5, 200, 100)
r.fillColor = red
r.strokeColor = green
r.strokeWidth = 3
d.add(r)
draw(d, "red rectangle with green border")

disc(
    """
<i>Note: In future examples we will omit the import statements.</i>
"""
)

disc(
    """
All shapes have a number of properties which can be set.
开发者ID:jbacou,项目名称:myReportLab_installPackage,代码行数:31,代码来源:graph_shapes.py


示例18: Drawing

from reportlab.graphics.charts.lineplots import SimpleTimeSeriesPlot
from reportlab.graphics.charts.legends import Legend
from reportlab.graphics.charts.piecharts import Pie
from reportlab.lib.colors import PCMYKColor, HexColor
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, Rect

if __name__ == "__main__":


    c = canvas.Canvas("report.pdf", pagesize=letter)
    # move the origin up and to the left
    #c.translate(inch,inch)
    #c.setFillColorRGB(1,0,1)

    headerCanvas = Drawing()
    headerRect = Rect(0, 0, width=650, height=50)
    headerRect.fillColor = HexColor("#607D8B")
    headerRect.strokeColor = HexColor("#607D8B")
    headerCanvas.add(headerRect)
    renderPDF.draw(headerCanvas, c, 0, 750)


    c.drawImage("kit-logo.png", 50, 650, width=100, height=100)

    headerText = c.beginText(200, 750)
    headerText.textLine("Header Test Text")
    c.drawText(headerText)

    chartCanvas = Drawing()
    chartCanvas.hAlign = 'CENTER'
    chart = SimpleTimeSeriesPlot()
开发者ID:denisvolokh,项目名称:reportlab-report-prototype,代码行数:31,代码来源:main.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python shapes.String类代码示例发布时间:2022-05-26
下一篇:
Python shapes.Line类代码示例发布时间: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