Line
A brief reference to the Line class.
Initialization
You can initialize a Line in a few different ways:
line = Line(screen, x1, y1, x2, y2) # Pass two points
line = Line(screen, (x1, y1), (x2, y2)) # Two points as tuples
line = Line(screen, location1, location2) # Two points as LocationsMovement
You can move the Line using slightly modified methods from Object:
We can translate by a specified amount with:
line.move(dx, dy) # Move both points by dx, dy
line.move(dx, dy, point=1) # Move only the first point by dx, dyWe can move both positions to new locations with:
line.moveto(x1, y1, x2, y2)
line.moveto((x1, y1), (x2, y2))
line.moveto(location1, location2)We can change only one of the positions with either:
line.pos1(location)Location
Retrieve both positions in a tuple using the familiar:
Rotation
You can rotate lines just as you would expect:
Or we can pass a location in for the line to look at:
Color
You can change the Color of a Line just like a Renderable:
Thickness
You can modify the thickness of the line in pixels with:
Dashes
You may decide to change the line to a dotted line with:
Length
You can get the length of the line by calling:
Visibility
Visibility is accessed exactly as it is in Renderable:
Transform and Cloning
Transforms and cloning work as in Renderable:
Line's transform is a tuple with both positions and current angle.
Cloning works as expected:
Intersects (Overlaps)
The Line's version of Renderable's overlaps() is intersects(). It can take any Renderable or Line and will check if the line intersects with any of their lines.
Last updated
Was this helpful?