当前位置: 首页>>代码示例>>Python>>正文


Python Group.rotate方法代码示例

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


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

示例1: makeCircularString

# 需要导入模块: from HealthNet.static.reportlab.graphics.shapes import Group [as 别名]
# 或者: from HealthNet.static.reportlab.graphics.shapes.Group import rotate [as 别名]
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:bellyflopp,项目名称:HealthNet,代码行数:33,代码来源:utils.py

示例2: draw

# 需要导入模块: from HealthNet.static.reportlab.graphics.shapes import Group [as 别名]
# 或者: from HealthNet.static.reportlab.graphics.shapes.Group import rotate [as 别名]
    def draw(self):
        s = float(self.size)  #abbreviate as we will use this a lot
        g = Group()

        # new algorithm from markers.StarFive
        R = float(self.size)/2
        r = R*sin(18*(pi/180.0))/cos(36*(pi/180.0))
        P = []
        angle = 90
        for i in range(5):
            for radius in R, r:
                theta = angle*(pi/180.0)
                P.append(radius*cos(theta))
                P.append(radius*sin(theta))
                angle = angle + 36
        # star specific bits
        star = Polygon(P,
                    fillColor = self.fillColor,
                    strokeColor = self.strokeColor,
                    strokeWidth=s/50)
        g.rotate(self.angle)
        g.shift(self.x+self.dx,self.y+self.dy)
        g.add(star)

        return g
开发者ID:bellyflopp,项目名称:HealthNet,代码行数:27,代码来源:flags.py

示例3: _rawDraw

# 需要导入模块: from HealthNet.static.reportlab.graphics.shapes import Group [as 别名]
# 或者: from HealthNet.static.reportlab.graphics.shapes.Group import rotate [as 别名]
    def _rawDraw(self):
        _text = self._text
        self._text = _text or ''
        self.computeSize()
        self._text = _text
        g = Group()
        g.translate(self.x + self.dx, self.y + self.dy)
        g.rotate(self.angle)

        y = self._top - self._leading*self._baselineRatio
        textAnchor = self._getTextAnchor()
        if textAnchor == 'start':
            x = self._left
        elif textAnchor == 'middle':
            x = self._left + self._ewidth*0.5
        else:
            x = self._right

        # paint box behind text just in case they
        # fill it
        if self.boxFillColor or (self.boxStrokeColor and self.boxStrokeWidth):
            g.add(Rect( self._left-self.leftPadding,
                        self._bottom-self.bottomPadding,
                        self._width,
                        self._height,
                        strokeColor=self.boxStrokeColor,
                        strokeWidth=self.boxStrokeWidth,
                        fillColor=self.boxFillColor)
                        )

        fillColor, fontName, fontSize = self.fillColor, self.fontName, self.fontSize
        strokeColor, strokeWidth, leading = self.strokeColor, self.strokeWidth, self._leading
        svgAttrs=getattr(self,'_svgAttrs',{})
        if strokeColor:
            for line in self._lines:
                s = _text2Path(line, x, y, fontName, fontSize, textAnchor)
                s.fillColor = fillColor
                s.strokeColor = strokeColor
                s.strokeWidth = strokeWidth
                g.add(s)
                y -= leading
        else:
            for line in self._lines:
                s = String(x, y, line, _svgAttrs=svgAttrs)
                s.textAnchor = textAnchor
                s.fontName = fontName
                s.fontSize = fontSize
                s.fillColor = fillColor
                g.add(s)
                y -= leading

        return g
开发者ID:bellyflopp,项目名称:HealthNet,代码行数:54,代码来源:textlabels.py

示例4: _Flag_Brazil

# 需要导入模块: from HealthNet.static.reportlab.graphics.shapes import Group [as 别名]
# 或者: from HealthNet.static.reportlab.graphics.shapes.Group import rotate [as 别名]
    def _Flag_Brazil(self):
        s = _size  # abbreviate as we will use this a lot
        g = Group()

        m = s/14.0
        self._width = w = (m * 20)

        def addStar(x,y,size, g=g, w=w, s=s, m=m):
            st = Star()
            st.fillColor=colors.mintcream
            st.size = size*m
            st.x = (w/2.0) + (x * (0.35 * m))
            st.y = (s/2.0) + (y * (0.35 * m))
            g.add(st)

        g.add(Rect(0, 0, w, s, fillColor = colors.green, strokeColor = None, strokeWidth=0))
        g.add(Polygon(points = [ 1.7*m, (s/2.0), (w/2.0), s-(1.7*m), w-(1.7*m),(s/2.0),(w/2.0), 1.7*m],
                      fillColor = colors.yellow, strokeColor = None, strokeWidth=0))
        g.add(Circle(cx=w/2.0, cy=s/2.0, r=3.5*m,
                     fillColor=colors.blue,strokeColor=None, strokeWidth=0))
        g.add(Wedge((w/2.0)-(2*m), 0, 8.5*m, 50, 98.1, 8.5*m,
                    fillColor=colors.mintcream,strokeColor=None, strokeWidth=0))
        g.add(Wedge((w/2.0), (s/2.0), 3.501*m, 156, 352, 3.501*m,
                    fillColor=colors.mintcream,strokeColor=None, strokeWidth=0))
        g.add(Wedge((w/2.0)-(2*m), 0, 8*m, 48.1, 100, 8*m,
                    fillColor=colors.blue,strokeColor=None, strokeWidth=0))
        g.add(Rect(0, 0, w, (s/4.0) + 1.7*m,
                   fillColor = colors.green, strokeColor = None, strokeWidth=0))
        g.add(Polygon(points = [ 1.7*m,(s/2.0), (w/2.0),s/2.0 - 2*m,    w-(1.7*m),(s/2.0) , (w/2.0),1.7*m],
                      fillColor = colors.yellow, strokeColor = None, strokeWidth=0))
        g.add(Wedge(w/2.0, s/2.0, 3.502*m, 166, 342.1, 3.502*m,
                    fillColor=colors.blue,strokeColor=None, strokeWidth=0))

        addStar(3.2,3.5,0.3)
        addStar(-8.5,1.5,0.3)
        addStar(-7.5,-3,0.3)
        addStar(-4,-5.5,0.3)
        addStar(0,-4.5,0.3)
        addStar(7,-3.5,0.3)
        addStar(-3.5,-0.5,0.25)
        addStar(0,-1.5,0.25)
        addStar(1,-2.5,0.25)
        addStar(3,-7,0.25)
        addStar(5,-6.5,0.25)
        addStar(6.5,-5,0.25)
        addStar(7,-4.5,0.25)
        addStar(-5.5,-3.2,0.25)
        addStar(-6,-4.2,0.25)
        addStar(-1,-2.75,0.2)
        addStar(2,-5.5,0.2)
        addStar(4,-5.5,0.2)
        addStar(5,-7.5,0.2)
        addStar(5,-5.5,0.2)
        addStar(6,-5.5,0.2)
        addStar(-8.8,-3.2,0.2)
        addStar(2.5,0.5,0.2)
        addStar(-0.2,-3.2,0.14)
        addStar(-7.2,-2,0.14)
        addStar(0,-8,0.1)

        sTmp = "ORDEM E PROGRESSO"
        nTmp = len(sTmp)
        delta = 0.850848010347/nTmp
        radius = 7.9 *m
        centerx = (w/2.0)-(2*m)
        centery = 0
        for i in range(nTmp):
            rad = 2*pi - i*delta -4.60766922527
            x=cos(rad)*radius+centerx
            y=sin(rad)*radius+centery
            if i == 6:
                z = 0.35*m
            else:
                z= 0.45*m
            g2 = Group(String(x, y, sTmp[i], fontName='Helvetica-Bold',
                fontSize = z,strokeColor=None,fillColor=colors.green))
            g2.rotate(rad)
            g.add(g2)
        return g
开发者ID:bellyflopp,项目名称:HealthNet,代码行数:81,代码来源:flags.py


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