A circle patch.
| 2066 | |
| 2067 | |
| 2068 | class Circle(Ellipse): |
| 2069 | """ |
| 2070 | A circle patch. |
| 2071 | """ |
| 2072 | def __str__(self): |
| 2073 | pars = self.center[0], self.center[1], self.radius |
| 2074 | fmt = "Circle(xy=(%g, %g), radius=%g)" |
| 2075 | return fmt % pars |
| 2076 | |
| 2077 | @_docstring.interpd |
| 2078 | def __init__(self, xy, radius=5, **kwargs): |
| 2079 | """ |
| 2080 | Create a true circle at center *xy* = (*x*, *y*) with given *radius*. |
| 2081 | |
| 2082 | Unlike `CirclePolygon` which is a polygonal approximation, this uses |
| 2083 | Bezier splines and is much closer to a scale-free circle. |
| 2084 | |
| 2085 | Valid keyword arguments are: |
| 2086 | |
| 2087 | %(Patch:kwdoc)s |
| 2088 | """ |
| 2089 | super().__init__(xy, radius * 2, radius * 2, **kwargs) |
| 2090 | self.radius = radius |
| 2091 | |
| 2092 | def set_radius(self, radius): |
| 2093 | """ |
| 2094 | Set the radius of the circle. |
| 2095 | |
| 2096 | Parameters |
| 2097 | ---------- |
| 2098 | radius : float |
| 2099 | """ |
| 2100 | self.width = self.height = 2 * radius |
| 2101 | self.stale = True |
| 2102 | |
| 2103 | def get_radius(self): |
| 2104 | """Return the radius of the circle.""" |
| 2105 | return self.width / 2. |
| 2106 | |
| 2107 | radius = property(get_radius, set_radius) |
| 2108 | |
| 2109 | |
| 2110 | class Arc(Ellipse): |
no outgoing calls
searching dependent graphs…