Skip to content

Commit 4d12a44

Browse files
committed
Add ellipse method
Signed-off-by: martinRenou <[email protected]>
1 parent 5368bf1 commit 4d12a44

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

docs/source/drawing_paths.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ Here are the available draw commands:
8383

8484
- ``move_to(x, y)``: Moves the pen to the coordinates specified by x and y. This does not actually draw anything.
8585
- ``line_to(x, y)``: Add a straight line to the current path by connecting the path’s last point to the specified (x, y) coordinates.
86-
- ``arc(x, y, radius, start_angle, end_angle, anticlockwise=False)``: Create a circular arc centered at (x, y) with a radius
87-
of ``radius``. The path starts at ``start_angle`` and ends at ``end_angle`` in radians, and travels in the direction given by
86+
- ``arc(x, y, radius, start_angle, end_angle, anticlockwise=False)``: Add a circular arc centered at (x, y) with a radius
87+
of ``radius`` to the current path. The path starts at ``start_angle`` and ends at ``end_angle`` in radians, and travels in the direction given by
8888
``anticlockwise`` (defaulting to clockwise: False).
8989
- ``arc_to(x1, y1, x2, y2, radius)``: Add a circular arc to the current path. Using the given control points (``x1``, ``y1``)
9090
and (``x2``, ``y2``) and the ``radius``.
91+
- ``ellipse(x, y, radius_x, radius_y, rotation, start_angle, end_angle, anticlockwise=False)``: Add an ellipse centered at ``(x, y)`` with
92+
the radii ``radius_x`` and ``radius_y`` to the current path.
9193
- ``quadratic_curve_to(cp1x, cp1y, x, y)``: Add a quadratic Bezier curve to the current path.
9294
It requires two points: the first one is a control point and the second one is the end point. The starting point is the latest point in the current path, which can be changed using ``move_to()`` before creating the quadratic Bezier curve.
9395
- ``bezier_curve_to(cp1x, cp1y, cp2x, cp2y, x, y)``: Add a cubic Bezier curve to the current path.

ipycanvas/canvas.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,17 +420,25 @@ def line_to(self, x, y):
420420
self._send_canvas_command('lineTo', (x, y))
421421

422422
def rect(self, x, y, width, height):
423-
"""Draw a rectangle of size ``(width, height)`` at the ``(x, y)`` position in the current path."""
423+
"""Add a rectangle of size ``(width, height)`` at the ``(x, y)`` position in the current path."""
424424
self._send_canvas_command('rect', (x, y, width, height))
425425

426426
def arc(self, x, y, radius, start_angle, end_angle, anticlockwise=False):
427-
"""Create a circular arc centered at ``(x, y)`` with a radius of ``radius``.
427+
"""Add a circular arc centered at ``(x, y)`` with a radius of ``radius`` to the current path.
428428
429429
The path starts at ``start_angle`` and ends at ``end_angle``, and travels in the direction given by
430430
``anticlockwise`` (defaulting to clockwise: ``False``).
431431
"""
432432
self._send_canvas_command('arc', (x, y, radius, start_angle, end_angle, anticlockwise))
433433

434+
def ellipse(self, x, y, radius_x, radius_y, rotation, start_angle, end_angle, anticlockwise=False):
435+
"""Add an ellipse centered at ``(x, y)`` with the radii ``radius_x`` and ``radius_y`` to the current path.
436+
437+
The path starts at ``start_angle`` and ends at ``end_angle``, and travels in the direction given by
438+
``anticlockwise`` (defaulting to clockwise: ``False``).
439+
"""
440+
self._send_canvas_command('ellipse', (x, y, radius_x, radius_y, rotation, start_angle, end_angle, anticlockwise))
441+
434442
def arc_to(self, x1, y1, x2, y2, radius):
435443
"""Add a circular arc to the current path.
436444

0 commit comments

Comments
 (0)