Ellipse

class kurbopy.Ellipse(center, radii, x_rotation)

A Ellipse.

area()

Compute the signed area under the curve.

For a closed path, the signed area of the path is the sum of signed areas of the segments. This is a variant of the “shoelace formula.” See: <https://github.com/Pomax/bezierinfo/issues/44> and <http://ich.deanmcnamee.com/graphics/2016/03/30/CurveArea.html>

This can be computed exactly for Béziers thanks to Green’s theorem, and also for simple curves such as circular arcs. For more exotic curves, it’s probably best to subdivide to cubics. We leave that to the caller, which is why we don’t give an accuracy param here.

bounding_box()

The smallest rectangle that encloses the shape.

center
contains(pt)

Returns true if the [Point] is inside this shape.

This is only meaningful for closed shapes.

classmethod from_affine(affine)

Create an ellipse from an affine transformation of the unit circle.

classmethod from_rect(rect)

Returns the largest ellipse that can be bounded by this [Rect].

This uses the absolute width and height of the rectangle.

This ellipse is always axis-aligned; to apply rotation you can call [with_rotation] with the result.

[with_rotation]: Ellipse::with_rotation #[pyo3(text_signature = “(cls, p0, p1)”)]

is_finite()

Is this value finite?

is_nan()

Is this value NaN?

perimeter(accuracy)

Total length of perimeter.

radii
radii_and_rotation()

Returns the radii and the rotation of this ellipse.

Equivalent to (self.radii(), self.rotation()) but more efficient.

rotation
to_path(tolerance)

Convert to a Bézier path.

winding(pt)

The winding number of a point.

This method only produces meaningful results with closed shapes.

The sign of the winding number is consistent with that of area, meaning it is +1 when the point is inside a positive area shape and -1 when it is inside a negative area shape. Of course, greater magnitude values are also possible when the shape is more complex.

with_center(new_center)

Create a new Ellipse centered on the provided point.

with_radii(new_radii)

Create a new Ellipse with the provided radii.

with_rotation(rotation)

Create a new Ellipse, with the rotation replaced by rotation radians.

The rotation is clockwise, for a y-down coordinate system. For more on rotation, See [Affine::rotate].