Draw the arc to the given *renderer*. Notes ----- Ellipses are normally drawn using an approximation that uses eight cubic Bezier splines. The error of this approximation is 1.89818e-6, according to this unverified source: Lancaster, Don.
(self, renderer)
| 2171 | |
| 2172 | @artist.allow_rasterization |
| 2173 | def draw(self, renderer): |
| 2174 | """ |
| 2175 | Draw the arc to the given *renderer*. |
| 2176 | |
| 2177 | Notes |
| 2178 | ----- |
| 2179 | Ellipses are normally drawn using an approximation that uses |
| 2180 | eight cubic Bezier splines. The error of this approximation |
| 2181 | is 1.89818e-6, according to this unverified source: |
| 2182 | |
| 2183 | Lancaster, Don. *Approximating a Circle or an Ellipse Using |
| 2184 | Four Bezier Cubic Splines.* |
| 2185 | |
| 2186 | https://www.tinaja.com/glib/ellipse4.pdf |
| 2187 | |
| 2188 | There is a use case where very large ellipses must be drawn |
| 2189 | with very high accuracy, and it is too expensive to render the |
| 2190 | entire ellipse with enough segments (either splines or line |
| 2191 | segments). Therefore, in the case where either radius of the |
| 2192 | ellipse is large enough that the error of the spline |
| 2193 | approximation will be visible (greater than one pixel offset |
| 2194 | from the ideal), a different technique is used. |
| 2195 | |
| 2196 | In that case, only the visible parts of the ellipse are drawn, |
| 2197 | with each visible arc using a fixed number of spline segments |
| 2198 | (8). The algorithm proceeds as follows: |
| 2199 | |
| 2200 | 1. The points where the ellipse intersects the axes (or figure) |
| 2201 | bounding box are located. (This is done by performing an inverse |
| 2202 | transformation on the bbox such that it is relative to the unit |
| 2203 | circle -- this makes the intersection calculation much easier than |
| 2204 | doing rotated ellipse intersection directly.) |
| 2205 | |
| 2206 | This uses the "line intersecting a circle" algorithm from: |
| 2207 | |
| 2208 | Vince, John. *Geometry for Computer Graphics: Formulae, |
| 2209 | Examples & Proofs.* London: Springer-Verlag, 2005. |
| 2210 | |
| 2211 | 2. The angles of each of the intersection points are calculated. |
| 2212 | |
| 2213 | 3. Proceeding counterclockwise starting in the positive |
| 2214 | x-direction, each of the visible arc-segments between the |
| 2215 | pairs of vertices are drawn using the Bezier arc |
| 2216 | approximation technique implemented in `.Path.arc`. |
| 2217 | """ |
| 2218 | if not self.get_visible(): |
| 2219 | return |
| 2220 | |
| 2221 | self._recompute_transform() |
| 2222 | |
| 2223 | self._update_path() |
| 2224 | # Get width and height in pixels we need to use |
| 2225 | # `self.get_data_transform` rather than `self.get_transform` |
| 2226 | # because we want the transform from dataspace to the |
| 2227 | # screen space to estimate how big the arc will be in physical |
| 2228 | # units when rendered (the transform that we get via |
| 2229 | # `self.get_transform()` goes from an idealized unit-radius |
| 2230 | # space to screen space). |
no test coverage detected