Lines
Learn to draw lines at specific angles with Pycairo.
We'll cover the following
We can draw a line between two points, for instance points (x1, y1)
and (x2, y2)
, like this:
ctx.move_to(x1, y1)
ctx.line_to(x2, y2)
Now, we will look at a couple of other examples.
Drawing a line of given length and angle
In this case, we will see how to draw a line that:
- Starts from the point
(x1, y1),
- Is at an angle
a
radians from the x-axis, - And has a length
r
.
Here is how a line is drawn:
Get hands-on with 1400+ tech skills courses.