Kraken Logo

Kraken Engine

DocumentationGuidesShowcaseCommunity
Ctrl
K
Navigating the Docs
Building Docs
Overview
Anchor
AnimationController
Audio
Batcher
Body
Camera
Capsule
CastHit
CharacterBody
Circle
Collision
Color
DistanceJoint
Effect
Event
FilterJoint
Flip (Texture)
Font
ImageLayer
InputAction
Joint
Layer
Line
Map
MapObject
Mask
MotorJoint
MouseJoint
ObjectGroup
Orchestrator
PixelArray
PolarCoordinate
Polygon
PrismaticJoint
Rect
RevoluteJoint
RigidBody
Sample
Sampler
Shader
SheetStrip
StaticBody
Stream
Style
Terrain (TileSet)
Text
TextProperties
Texture
Tile (TileLayer)
Tile (TileSet)
TileLayer
TileResult (TileLayer)
TileSet
Timer
Transform
Tween
Vec2
Vertex
WeldJoint
WheelJoint
World

Built bydurkisneer1.Kraken Engine is open source and available onGitHub.

  1. Docs
  2. Classes
  3. Line

Line

A 2D line segment defined by two points.

Constructor

  • Line() → LineLine() → Line
  • Line(ax: float, ay: float, bx: float, by: float) → LineLine(ax: float, ay: float, bx: float, by: float) → Line
  • Line(ax: float, ay: float, b: Vec2) → LineLine(ax: float, ay: float, b: Vec2) → Line
  • Line(a: Vec2, bx: float, by: float) → LineLine(a: Vec2, bx: float, by: float) → Line
  • Line(a: Vec2, b: Vec2) → LineLine(a: Vec2, b: Vec2) → Line

A 2D line segment defined by two points.

Properties


NameDescriptionType
aGet or set point A as a tuple or Vec2.Vec2
axX-coordinate of point A.float
ayY-coordinate of point A.float
bGet or set point B as a tuple or Vec2.Vec2
bxX-coordinate of point B.float
byY-coordinate of point B.float
lengthThe Euclidean length of the line segment.float

Methods


Copy

copy() → Linecopy() → Line

Return a copy of this line.

Get Angle

get_angle() → floatget_angle() → float

Get the angle of the line in radians.

Returns

float : The angle in radians.

Get Closest Point

get_closest_point(point: Vec2) → Vec2get_closest_point(point: Vec2) → Vec2

Get the closest point on the line to a given point.

Args

  • point : The point to find the closest point to.

Returns

Vec2 : The closest point on the line as a Vec2.

Get Midpoint

get_midpoint() → Vec2get_midpoint() → Vec2

Get the midpoint of the line segment.

Returns

Vec2 : The midpoint as a Vec2.

Get Perpendicular

get_perpendicular() → Lineget_perpendicular() → Line

Get a perpendicular bisector line from this line.

Returns

Line : A new perpendicular line.

Move

move(offset: Vec2) → Nonemove(offset: Vec2) → None

Move this line by a Vec2 offset.

Args

  • offset : The amount to move.

Moved

moved(offset: Vec2) → Linemoved(offset: Vec2) → Line

Return a new line moved by a Vec2 offset.

Args

  • offset : The amount to move.
PreviousLayer
NextMap

On this page

ConstructorPropertiesMethodsCopyGet AngleGet Closest PointGet MidpointGet PerpendicularMoveMoved