Skip to content
Related Articles

Related Articles

Improve Article

Wand path_horizontal_line() function in Python

  • Last Updated : 11 May, 2020

The path_horizontal_line() is another function for path. path_horizontal_line() function generates a horizontal line from a destination point to a particular x point. It takes only x in arguments as a point upto which line is being drawn.

Syntax: wand.drawing.path_horizontal_line(to, relative)

Parameters:

ParameterInput TypeDescription
xRealx-axis point to draw to.
relativebooltreat given coordinates as relative to current point.

Example #1:




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')
    draw.path_start()
      
    # Start middle-left
    draw.path_move(to=(10, 50))
      
    # horizontal line to x=100
    draw.path_horizontal_line(100)
    draw.path_finish()
    with Image(width=200,
               height=200,
               background=Color('lightgreen')) as image:
          
        draw(image)
        image.save(filename="pathhline.png")

Output:



Example #2:




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')
    draw.path_start()
      
    # Start middle-left
    draw.path_move(to=(100, 50))
      
    # horizontal line to x=50
    draw.path_horizontal_line(50)
    draw.path_finish()
    with Image(width=200
               height=200,
               background=Color('lightgreen')) as image:
          
        draw(image)
        image.save(filename="pathhline.png")

Output:

 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




My Personal Notes arrow_drop_up
Recommended Articles
Page :