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. Pixel Array

PixelArray

Represents a 2D pixel buffer for image manipulation and blitting operations.

Constructor

  • PixelArray(width: int, height: int) → PixelArrayPixelArray(width: int, height: int) → PixelArray
  • PixelArray(file_path: str | PathLike[str]) → PixelArrayPixelArray(file_path: str | PathLike[str]) → PixelArray

Represents a 2D pixel buffer for image manipulation and blitting operations.

Properties


NameDescriptionType
alpha_modThe alpha modulation value for the pixel array.int
color_keyThe color key for transparency.Color
heightThe height of the pixel array.int
sizeThe size of the pixel array as a Vec2.Vec2
widthThe width of the pixel array.int

Methods


Blit

blit(pixel_array: PixelArray, pos: Vec2, anchor: Vec2 = ..., src: Rect = ...) → Noneblit(pixel_array: PixelArray, pos: Vec2, anchor: Vec2 = ..., src: Rect = ...) → None

Blit (copy) another pixel array onto this pixel array at the specified position with anchor alignment.

Args

  • pixel_array : The source pixel array to blit from.
  • pos : The position to blit to.
  • anchor : The anchor point for positioning. Defaults to (0,0) TopLeft.
  • src : The source rectangle to blit from. Defaults to entire source pixel array.

Raises

  • RuntimeError : If the blit operation fails.

blit(pixel_array: PixelArray, dst: Rect, src: Rect = ...) → Noneblit(pixel_array: PixelArray, dst: Rect, src: Rect = ...) → None

Blit (copy) another pixel array onto this pixel array with specified destination and source rectangles.

Args

  • pixel_array : The source pixel array to blit from.
  • dst : The destination rectangle on this pixel array.
  • src : The source rectangle to blit from. Defaults to entire source pixel array.

Raises

  • RuntimeError : If the blit operation fails.

Copy

copy() → PixelArraycopy() → PixelArray

Create a copy of this pixel array.

Returns

PixelArray : A new PixelArray that is an exact copy of this one.

Raises

  • RuntimeError : If pixel array copying fails.

Fill

fill(color: Color) → Nonefill(color: Color) → None

Fill the entire pixel array with a solid color.

Args

  • color : The color to fill the pixel array with.

Get At

get_at(x: int, y: int) → Colorget_at(x: int, y: int) → Color

Get the color of a pixel at the specified coordinates.

Args

  • x : The x-coordinate of the pixel.
  • y : The y-coordinate of the pixel.

Returns

Color : The color of the pixel at the specified coordinates.

Raises

  • IndexError : If coordinates are outside the pixel array bounds.

Get Rect

get_rect() → Rectget_rect() → Rect

Get a rectangle representing the pixel array bounds.

Returns

Rect : A rectangle with position (0, 0) and the pixel array's dimensions.

Scroll

scroll(dx: int, dy: int, scroll_mode: ScrollMode) → Nonescroll(dx: int, dy: int, scroll_mode: ScrollMode) → None

Scroll the pixel array's contents by the specified offset.

Args

  • dx : Horizontal scroll offset in pixels.
  • dy : Vertical scroll offset in pixels.
  • scroll_mode : Behavior for pixels scrolled off the edge.
  • - REPEAT : Wrap pixels around to the opposite edge.
  • - ERASE : Fill scrolled areas with transparent pixels.
  • - SMEAR : Extend edge pixels into scrolled areas.

Set At

set_at(x: int, y: int, color: Color) → Noneset_at(x: int, y: int, color: Color) → None

Set the color of a pixel at the specified coordinates.

Args

  • x : The x-coordinate of the pixel.
  • y : The y-coordinate of the pixel.
  • color : The color to set the pixel to.

Raises

  • IndexError : If coordinates are outside the pixel array bounds.
PreviousOrchestrator
NextPolarCoordinate

On this page

ConstructorPropertiesMethodsBlitCopyFillGet AtGet RectScrollSet At