PyCairo – Drawing different type of line caps
In this article, we will learn how we can draw different line caps types using PyCairo in python. The line caps are endpoints of lines.
Steps of Implementation :
- Import the Pycairo module.
- Create a SVG surface object and add context to it.
- Setting color of the context & line width
- Setting of line cap style using set_line_cap( )
- Creating a line.
There are three different types line cap styles in PyCairo.
1. set_line_cap ( cairo.LINE_CAP_BUTT )
2. set_line_cap ( cairo.LINE_CAP_ROUND )
3. set_line_cap ( cairo.LINE_CAP_SQUARE )
Note: A line with cairo.LINE_CAP_SQUARE cap used has a different size than a line with cairo.LINE_CAP_BUTT cap. If the line is z units wide, the line with cairo.LINE_CAP_SQUARE cap will be exactly z units greater in size; z/2 units at the beginning and z/2 units at the end.
All three type of line caps can be seen in the below python Example, and the output of each line cap can also be compared
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course