MCPcopy Create free account
hub / github.com/ActiveState/code / Polygon

Class Polygon

recipes/Python/578004_processing/recipe-578004.py:8–35  ·  view source on GitHub ↗

Polygon(*vertices) -> Polygon

Source from the content-addressed store, hash-verified

6################################################################################
7
8class Polygon:
9
10 "Polygon(*vertices) -> Polygon"
11
12 __slots__ = 'vertices'
13
14 def __init__(self, *vertices):
15 "Initializes polygon with a list of vertices."
16 self.vertices = vertices
17
18 def translate(self, offset):
19 "Moves the polygon by the specified offset."
20 for vertex in self.vertices:
21 vertex += offset
22
23 def rotate(self, direction):
24 "Rotates the polygon by a vector's direction."
25 for vertex in self.vertices:
26 vertex.direction += direction
27
28 def scale(self, factor):
29 "Increases or decreases size of the polygon."
30 for vertex in self.vertices:
31 vertex *= factor
32
33 def copy(self):
34 "Copies the polygon by copying its vertices."
35 return Polygon(*(vertex.copy() for vertex in self.vertices))
36
37################################################################################
38

Callers 1

copyMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected