Line
pykraken.Line A 2D line segment defined by two points.
You can access or modify points using .a, .b, or directly via .ax, .ay, .bx, .by.
At a glance
15 membersReference
PYTHON APIOverloaded function.
Line()
Create a default line with all values set to 0.
Line(ax: float, ay: float, bx: float, by: float)
Create a line from two coordinate points.
Args
- ax (
float) — X-coordinate of point A. - ay (
float) — Y-coordinate of point A. - bx (
float) — X-coordinate of point B. - by (
float) — Y-coordinate of point B.
Line(ax: float, ay: float, b: Vec2)
Create a line from A coordinates and a Vec2 B point.
Args
- ax (
float) — X-coordinate of point A. - ay (
float) — Y-coordinate of point A. - b (
Vec2) — Point B.
Line(a: Vec2, bx: float, by: float)
Create a line from a Vec2 A point and B coordinates.
Args
- a (
Vec2) — Point A. - bx (
float) — X-coordinate of point B. - by (
float) — Y-coordinate of point B.
Line(a: Vec2, b: Vec2)
Create a line from two Vec2 points.
Args
- a (
Vec2) — Point A. - b (
Vec2) — Point B.
a
propertya: Vec2Get or set point A as a tuple or Vec2.
ax
propertyax: floatX-coordinate of point A.
ay
propertyay: floatY-coordinate of point A.
b
propertyb: Vec2Get or set point B as a tuple or Vec2.
bx
propertybx: floatX-coordinate of point B.
by
propertyby: floatY-coordinate of point B.
length
propertylength: floatThe Euclidean length of the line segment.
copy
methodcopy(self) -> LineReturn a copy of this line.
get_angle
methodget_angle(self) -> floatGet the angle of the line in radians.
Returns
- float — The angle in radians.
get_closest_point
methodGet the closest point on the line to a given point.
Args
- point (
Vec2) — The point to find the closest point to.
Returns
- Vec2 — The closest point on the line as a Vec2.
get_midpoint
methodget_midpoint(self) -> Vec2Get the midpoint of the line segment.
Returns
- Vec2 — The midpoint as a Vec2.
get_perpendicular
methodget_perpendicular(self) -> LineGet a perpendicular bisector line from this line.
Returns
- Line — A new perpendicular line.
move
methodmove(self, offset: Vec2) -> NoneMove this line by a Vec2 offset.
Args
- offset (
Vec2) — The amount to move.
moved
methodReturn a new line moved by a Vec2 offset.
Args
- offset (
Vec2) — The amount to move.