Wand polyline() function in Python
Last Updated :
27 Mar, 2023
polyline() is another drawing function present in wand.drawing module of Wand. polyline() is similar to polygon() function the only difference is that, it will not close the stroke line b/w first and last point. Similar to polygon() it also takes a list of point tuples as an argument.
Syntax :
wand.drawing.polyline(points)
Parameters :
Parameter |
Input Type |
Description |
points |
list |
list of x, y tuples. |
Example #1
Python3
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.stroke_width = 2
draw.stroke_color = Color( 'black' )
draw.fill_color = Color( 'white' )
points = [( 25 , 25 ), ( 175 , 100 ), ( 25 , 175 )]
draw.polyline(points)
with Image(width = 200 , height = 200 , background = Color( 'lightgreen' )) as image:
draw(image)
image.save(filename = "polyline.png")
|
Output:
Example #2:
Python3
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.stroke_width = 2
draw.stroke_color = Color( 'black' )
draw.fill_color = Color( 'white' )
points = [( 25 , 150 ), ( 50 , 50 ), ( 150 , 50 ), ( 175 , 150 )]
draw.polyline(points)
with Image(width = 200 , height = 200 , background = Color( 'lightgreen' )) as image:
draw(image)
image.save(filename = "polyline2.png")
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...