|
1 |
| -"""This module contain functions for automatic generation of geometry, for |
| 1 | +"""This module contain functions for automatic generation of geometry, for |
2 | 2 | example from an image.
|
3 | 3 |
|
4 | 4 | Example::
|
|
23 | 23 | >>> print(len(pl_set))
|
24 | 24 | 2
|
25 | 25 |
|
26 |
| -The information in segments can now be used to create geometry, for example as |
| 26 | +The information in segments can now be used to create geometry, for example as |
27 | 27 | a Pymunk Poly or Segment::
|
28 | 28 |
|
29 | 29 | >>> s = pymunk.Space()
|
30 | 30 | >>> for poly_line in pl_set:
|
31 | 31 | ... for i in range(len(poly_line) - 1):
|
32 | 32 | ... a = poly_line[i]
|
33 | 33 | ... b = poly_line[i + 1]
|
34 |
| - ... segment = pymunk.Segment(s.static_body, a, b, 1) |
| 34 | + ... segment = pymunk.Segment(s.static_body, a, b, 1) |
35 | 35 | ... s.add(segment)
|
36 | 36 |
|
37 | 37 |
|
38 | 38 | """
|
| 39 | + |
39 | 40 | __docformat__ = "reStructuredText"
|
40 | 41 |
|
41 | 42 | from typing import TYPE_CHECKING, Callable, List, Sequence, Tuple, Union, overload
|
|
47 | 48 | from ._chipmunk_cffi import ffi, lib
|
48 | 49 | from .vec2d import Vec2d
|
49 | 50 |
|
50 |
| -_SegmentFunc = Callable[[Tuple[float, float], Tuple[float, float]], None] |
51 | 51 | _SampleFunc = Callable[[Tuple[float, float]], float]
|
52 | 52 |
|
53 | 53 | _Polyline = Union[List[Tuple[float, float]], List[Vec2d]]
|
@@ -201,19 +201,19 @@ def __len__(self) -> int:
|
201 | 201 | return self._set.count
|
202 | 202 |
|
203 | 203 | @overload
|
204 |
| - def __getitem__(self, index: int) -> List[Vec2d]: |
205 |
| - ... |
| 204 | + def __getitem__(self, index: int) -> List[Vec2d]: ... |
206 | 205 |
|
207 | 206 | @overload
|
208 |
| - def __getitem__(self, index: slice) -> "PolylineSet": |
209 |
| - ... |
| 207 | + def __getitem__(self, index: slice) -> "PolylineSet": ... |
210 | 208 |
|
211 |
| - def __getitem__(self, key: Union[int, slice]) -> Union[List[Vec2d], "PolylineSet"]: |
212 |
| - assert not isinstance(key, slice), "Slice indexing not supported" |
213 |
| - if key >= self._set.count: |
| 209 | + def __getitem__( |
| 210 | + self, index: Union[int, slice] |
| 211 | + ) -> Union[List[Vec2d], "PolylineSet"]: |
| 212 | + assert not isinstance(index, slice), "Slice indexing not supported" |
| 213 | + if index >= self._set.count: |
214 | 214 | raise IndexError
|
215 | 215 | line = []
|
216 |
| - l = self._set.lines[key] |
| 216 | + l = self._set.lines[index] |
217 | 217 | for i in range(l.count):
|
218 | 218 | line.append(Vec2d(l.verts[i].x, l.verts[i].y))
|
219 | 219 | return line
|
|
0 commit comments