Skip to content

Commit 953b08b

Browse files
committed
Add docs for stroke_lines
Signed-off-by: martinRenou <[email protected]>
1 parent f90ea3c commit 953b08b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/source/drawing_shapes.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ There are methods that draw arcs/circles on the canvas:
161161
Drawing lines
162162
-------------
163163

164-
There is one command for drawing a straight line from one point to another:
164+
There are two commands for drawing a straight line from one point to another:
165165

166166
- ``stroke_line(x1, y1, x2, y2)``: Draw a line from ``(x1, y1)`` to ``(x2, y2)``.
167+
- ``stroke_lines(points)``: Draw a path of consecutive lines from a list of points ``[(x1, y1), (x2, y2), ..., (xn, yn)]``.
167168

168169
.. code:: Python
169170
@@ -184,6 +185,26 @@ There is one command for drawing a straight line from one point to another:
184185
185186
.. image:: images/lines.png
186187

188+
.. code:: Python
189+
190+
import numpy as np
191+
192+
from ipycanvas import Canvas
193+
194+
canvas = Canvas(width=200, height=200)
195+
196+
n = 50
197+
x = np.linspace(0, 200, n)
198+
y = np.random.randint(200, size=n)
199+
200+
points = np.stack((x, y), axis=1)
201+
202+
canvas.stroke_lines(points)
203+
204+
canvas
205+
206+
.. image:: images/stroke_lines.png
207+
187208

188209
Vectorized methods
189210
------------------
18.3 KB
Loading

0 commit comments

Comments
 (0)