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


Python Polygon.rotate方法代码示例

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


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

示例1: rackGear

# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import rotate [as 别名]
def rackGear(pos=(0,0), n=30, radius=5., phi=20., addendum=0.4, dedendum=0.5,
         fradius=0.1, rotate=0, scale=1.0, length=10*pi, res=1, bevel=0.05, depth=(0.4+0.6+0.1)):
        tooth = RackOutline(n, res, phi, radius, addendum, dedendum,
                        fradius, bevel)

        toothl = tooth[0][1] - tooth[-1][1]

        ntooth = int(length/toothl)
        flength = ntooth * toothl

        gear = []
        for i in range(0, ntooth):
            ntooth = []
            for (x, y) in tooth:
                nx = x + pos[0]
                ny = -i*toothl + y + pos[1]
                ntooth.append((nx,ny))
            gear.extend(ntooth)
        gear.append((gear[-1][0]-depth,gear[-1][1]))
        gear.append((gear[0][0]-depth,gear[0][1]))
        gear.append(gear[0])
        pp =  Polygon(gear)
        pp.shift(-pp.center()[0],-pp.center()[1])
        if rotate != 0.0: pp.rotate(rotate)
        if scale != 1.0 : pp.scale(scale,scale)
        return pp
开发者ID:Emma920,项目名称:visual,代码行数:28,代码来源:shapes.py

示例2: pointlist

# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import rotate [as 别名]
def pointlist(pos=[], rotate=0.0, roundness=0.0, invert=False,
              scale=1.0, xscale=1.0, yscale=1.0, path=False):
    # pos may be either a list of points or a Polygon object
    try:
        points = pos.contour(0)
        if len(pos) > 1:
            raise AttributeError("pointlist can deal with only a single contour.")
    except:
        points = pos[:]
    closed = (points[-1] == points[0])
    if not closed:
        points.append(points[0])
    pp = Polygon(points)
    if len(pp) and rotate != 0.0: pp.rotate(rotate)
    if scale != 1.0: xscale = yscale = scale
    if xscale != 1.0 or yscale != 1.0: pp.scale(xscale,yscale)
    if roundness > 0:
        cp = roundc(pp.contour(0), roundness=roundness, invert=invert)
        pp = Polygon(cp)
    if path:
        if closed:
            return list(pp)
        else:
            return list(pp)[:-1]
    else:
        return pp
开发者ID:Emma920,项目名称:visual,代码行数:28,代码来源:shapes.py

示例3: gear

# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import rotate [as 别名]
def gear(pos=(0,0), n=20, radius=5, phi=20, addendum=0.4, dedendum=0.5,
         fradius=0.1, rotate=0, scale=1.0, internal=False, res=1, bevel=0):
        tooth = ToothOutline(n, res, phi, radius, addendum, dedendum,
                        fradius, bevel=0.0)
        if internal:
                itooth = []
                for p in tooth:
                        px = p[0]
                        py = p[1]
                        driro = sqrt(px*px +py*py) - radius
                        ir = radius - driro
                        ro = radius + driro
                        ix = (ir/ro)*px
                        iy = (ir/ro)*py
                        itooth.append((ix,iy))

                tooth = itooth
        gear = []
        for i in range(0, n):
            rotan = -i*2*pi/n
            rtooth = []
            for (x, y) in tooth:
                rx = x*cos(rotan) - y*sin(rotan) + pos[0]
                ry = x*sin(rotan) + y*cos(rotan) + pos[1]
                rtooth.append((rx,ry))
            gear.extend(rtooth)
        #gear.append(gear[0])
        pp =  Polygon(gear)
        if rotate != 0.0: pp.rotate(rotate)
        if scale != 1.0 : pp.scale(scale,scale)
        return pp
开发者ID:Emma920,项目名称:visual,代码行数:33,代码来源:shapes.py

示例4: Ellipse

# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import rotate [as 别名]
img.blit( Ellipse(200,50,20,5).fill( Color(0, 255, 0) ) )

# The flag is constructed as such:
# ˆThe pole is a line with start and end points of (100,125) and (100,50).
line1 = Line(100, 125, 100, 50)

# ˆThe flag is a polygon with vertex points of (100,125), (100,95), and
# (60,110)
polygon1 = Polygon([(100,125), (100,95), (60,110)]).fill( Color(128, 0, 128) )

# ˆThe pole and flag are translated by (0,35), in order to fit in the right
# hand of the stick figure.
line1.translate(0,35)
polygon1.translate(0,35)

# ˆThe pole and flag are rotated by 45 degrees for a fix point of (100,100),
# so the flag and pole are tilted in the right hand of the stick figure.
line1.rotate(100,100,45)
polygon1.rotate(100,100,45)

# ˆThe pole and flag are scaled by 1.25 in the x and y values for a fix
# point of (100,100), to be larger in the right hand of the stick figure.
line1.scale(100,100,1.25,1.25)
polygon1.scale(100,100,1.25,1.25)

# Blit Rest
img.blit( line1 )
img.blit( polygon1 )

# Create/Write Image
img.save('test.ppm')
开发者ID:super3,项目名称:ClassDev,代码行数:33,代码来源:man.py

示例5: __init__

# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import rotate [as 别名]

#.........这里部分代码省略.........
        """Resize the shape by a proportion (e.g., 1 is unchanged), in-place.

        Parameters
        ----------
        factor : float or array-like
            If a scalar, the same factor will be applied in the x and y dimensions.
        center : array-like, optional
            Point around which to perform the scaling.
            If not passed, the center of the shape is used.

        """
        factor = np.asarray(factor)

        if len(factor.shape):
            args = list(factor)
        else:
            args = [factor, factor]
        if center is not None:
            args.extend(center)

        self.poly.scale(*args)
        return self

    def translate(self, vector):
        """Translate the shape along a vector, in-place.

        Parameters
        ----------
        vector : array-like

        """
        self.poly.shift(*vector)

    def rotate(self, angle, center=None):
        """Rotate the shape, in-place.

        Parameters
        ----------
        angle : float
            Angle to rotate, in radians counter-clockwise.
        center : array-like, optional
            Point about which to rotate.
            If not passed, the center of the shape will be used.

        """
        args = [angle]
        if center is not None:
            args.extend(center)
        self.poly.rotate(*args)
        return self

    def flip_x(self, center=None):
        """Flip the shape in the x direction, in-place.

        Parameters
        ----------
        center : array-like, optional
            Point about which to flip.
            If not passed, the center of the shape will be used.

         """
        if center is None:
            self.poly.flip()
        else:
            self.poly.flip(center[0])
开发者ID:hsharrison,项目名称:pyglet2d,代码行数:69,代码来源:pyglet2d.py


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