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. Polygon

Polygon

Represents a polygon shape defined by a sequence of points.

Constructor

  • Polygon() → PolygonPolygon() → Polygon
  • Polygon(points: Sequence[Vec2]) → PolygonPolygon(points: Sequence[Vec2]) → Polygon
  • Polygon(n: int, radius: float, centroid: Vec2 = ...) → PolygonPolygon(n: int, radius: float, centroid: Vec2 = ...) → Polygon

Represents a polygon shape defined by a sequence of points.

Properties


NameDescriptionType
areaGet the area of the polygon.float
centroidGet or set the centroid of the polygon.Vec2
is_concaveCheck if the polygon is concave.bool
is_convexCheck if the polygon is convex.bool
perimeterGet the perimeter of the polygon.float
pointsThe list of Vec2 points that define the polygon vertices.list[Vec2]

Methods


Copy

copy() → Polygoncopy() → Polygon

Return a copy of the polygon.

Returns

Polygon : A new polygon with the same points.

Get Rect

get_rect() → Rectget_rect() → Rect

Get the axis-aligned bounding rectangle of the polygon.

Returns

Rect : The bounding rectangle.

Move

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

Move the polygon by an offset.

Args

  • offset : The offset to move by.

Rotate

rotate(angle: float) → Nonerotate(angle: float) → None

Rotate the polygon around its centroid.

Args

  • angle : The rotation angle in radians.

Rotated

rotated(angle: float) → Polygonrotated(angle: float) → Polygon

Return a rotated copy of the polygon.

Args

  • angle : The rotation angle in radians.

Returns

Polygon : A new polygon that is a rotated version of this polygon.

Scale By

scale_by(factor: float) → Nonescale_by(factor: float) → None

Scale the polygon uniformly from its centroid.

Args

  • factor : The scaling factor.

scale_by(factor: Vec2) → Nonescale_by(factor: Vec2) → None

Scale the polygon non-uniformly from its centroid.

Args

  • factor : The scaling factors for x and y.

Scaled By

scaled_by(factor: float) → Polygonscaled_by(factor: float) → Polygon

Return a uniformly scaled copy of the polygon.

Args

  • factor : The scaling factor.

Returns

Polygon : A new polygon that is a scaled version of this polygon.


scaled_by(factor: Vec2) → Polygonscaled_by(factor: Vec2) → Polygon

Return a non-uniformly scaled copy of the polygon.

Args

  • factor : The scaling factors for x and y.

Returns

Polygon : A new polygon that is a scaled version of this polygon.

PreviousPolarCoordinate
NextPrismaticJoint

On this page

ConstructorPropertiesMethodsCopyGet RectMoveRotateRotatedScale ByScaled By