Line
The Line
class represents an SVG line element. It allows setting start and end coordinates and provides computed properties for its length and angle.
Info
This class inherits from SvgElement
.
pydreamplet.core.Line
Initializes a new line with specified start (x1, y1) and end (x2, y2) coordinates.
Parameters
x1
(float): The x-coordinate of the start point.y1
(float): The y-coordinate of the start point.x2
(float): The x-coordinate of the end point.y2
(float): The y-coordinate of the end point.**kwargs
: Additional attributes for the line.
from pydreamplet import SVG, Line
svg = SVG(200, 200)
svg.append(
Line(x1=10, y1=190, x2=190, y2=10, stroke="#a00344", stroke_width=5)
)
x1
, y1
, x2
, y2
Getters and Setters: Retrieve or update the line's coordinates.
length
Returns the length of the line calculated using the distance formula.
angle
Returns the angle (in degrees) of the line relative to the positive x-axis.