Skip to content

Commit 7319c0b

Browse files
committed
Add stroke_line docs
Signed-off-by: martinRenou <[email protected]>
1 parent 500070f commit 7319c0b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

docs/source/drawing_shapes.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,32 @@ There are methods that draw arcs/circles on the canvas:
100100
101101
.. image:: images/arc.png
102102

103+
Drawing lines
104+
-------------
105+
106+
There is one command for drawing a straight line from one point to another:
107+
108+
- ``stroke_line(x1, y1, x2, y2)``: Draw a line from ``(x1, y1)`` to ``(x2, y2)``.
109+
110+
.. code:: Python
111+
112+
from ipycanvas import Canvas
113+
114+
canvas = Canvas(width=200, height=200)
115+
116+
canvas.stroke_style = 'blue'
117+
canvas.stroke_line(0, 0, 150, 150)
118+
119+
canvas.stroke_style = 'red'
120+
canvas.stroke_line(200, 0, 0, 200)
121+
122+
canvas.stroke_style = 'green'
123+
canvas.stroke_line(150, 150, 0, 200)
124+
125+
canvas
126+
127+
.. image:: images/lines.png
128+
103129
Drawing paths
104130
-------------
105131

@@ -108,7 +134,7 @@ of different width and of different color. A path can be closed. To make shapes
108134
extra steps:
109135

110136
- First, you create the path with ``begin_path``
111-
- Then you use drawing commands to draw into the path
137+
- Then you use drawing commands to add shapes into the path
112138
- Once the path has been created, you can ``stroke`` or ``fill`` the path to render it
113139

114140
Here are the functions used to perform these steps:

docs/source/images/lines.png

2.4 KB
Loading

0 commit comments

Comments
 (0)