PyCairo – Drawing different type of line Joins
In this article, we will learn how lines can be joined using different join styles like Bevel, Round, and Miter in python using PyCairo.
Pycairo is a Python module providing bindings for the Cairo graphics library. This library is used for creating SVG i.e vector files in python. The easiest and quickest way to open an SVG file to view it (read-only) is with a modern web browser like Chrome, Firefox, Edge, or Internet Explorer—nearly all of them should provide some sort of rendering support for the SVG format.
For install this module run this command into your terminal:
pip install pycairo
- Import the Pycairo module.
- Create a SVG surface object and add context to it.
- Setting color of the context & line width
- Creating a rectangular shape
- Setting of line joins style using set_line_join( )
There are three different Methods for line joins styles in PyCairo.
Method #1: With set_line_join ( cairo.LINE_JOIN_MITER ).
Method #2: With set_line_join ( cairo.LINE_JOIN_BEVEL ).
Method #3: With set_line_join ( cairo.LINE_JOIN_ROUND )
All three type of line joins can be seen in below python Example, and output of each line joins 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