Physics

SplashKit Collisions library allow you to perform tests between bitmaps, sprites and shapes to determin if a collision has occured.Provides matrix functions to work on 2d coordinates.Provides vector functions to work on vectors.

Functions

Bitmap Circle Collision

Bitmap Circle Collision

Tests if a bitmap drawn at Pt would intersect with a circle.

Return Type

Boolean

True if a drawn pixel in the cell of the bitmap will intersect with Circ when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Pt

Point 2D

The location where the bitmap is drawn

Circ

Circle

The circle to test

Signatures
bool bitmap_circle_collision(bitmap bmp, const point_2d &pt, const circle &circ)
public bool Bitmap.BitmapCircleCollision(Point2D pt, Circle circ);
public static bool SplashKit.BitmapCircleCollision(Bitmap bmp, Point2D pt, Circle circ);
function BitmapCircleCollision(bmp: Bitmap; const pt: Point2D; const circ: Circle): Boolean
def bitmap_circle_collision_at_point(bmp, pt, circ):

Bitmap Circle Collision

Tests if a bitmap drawn at X, Y would intersect with a circle.

Return Type

Boolean

True if a drawn pixel in the bitmap will intersect with Circ when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

X

Double

The x location where the bitmap is drawn

Y

Double

The y location where the bitmap is drawn

Circ

Circle

The circle to test

Signatures
bool bitmap_circle_collision(bitmap bmp, double x, double y, const circle &circ)
public bool Bitmap.BitmapCircleCollision(double x, double y, Circle circ);
public static bool SplashKit.BitmapCircleCollision(Bitmap bmp, double x, double y, Circle circ);
function BitmapCircleCollision(bmp: Bitmap; x: Double; y: Double; const circ: Circle): Boolean
def bitmap_circle_collision(bmp, x, y, circ):

Bitmap Circle Collision

Tests if a bitmap cell drawn using a passed in translation, will intersect with a circle. You can use this to detect collisions between bitmaps and circles.

Return Type

Boolean

True if a drawn pixel in the cell of the bitmap will intersect with Circ when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

Translation

Matrix 2D

The matrix used to transfrom the bitmap when drawing

Circ

Circle

The circle to test

Signatures
bool bitmap_circle_collision(bitmap bmp, int cell, const matrix_2d &translation, const circle &circ)
public bool Bitmap.BitmapCircleCollision(int cell, Matrix2D translation, Circle circ);
public static bool SplashKit.BitmapCircleCollision(Bitmap bmp, int cell, Matrix2D translation, Circle circ);
function BitmapCircleCollision(bmp: Bitmap; cell: Integer; const translation: Matrix2D; const circ: Circle): Boolean
def bitmap_circle_collision_for_cell_with_translation(bmp, cell, translation, circ):

Bitmap Circle Collision

Tests if a bitmap cell drawn at Pt would intersect with a circle.

Return Type

Boolean

True if a drawn pixel in the cell of the bitmap will intersect with Circ when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

Pt

Point 2D

The location where the bitmap is drawn

Circ

Circle

The circle to test

Signatures
bool bitmap_circle_collision(bitmap bmp, int cell, const point_2d &pt, const circle &circ)
public bool Bitmap.BitmapCircleCollision(int cell, Point2D pt, Circle circ);
public static bool SplashKit.BitmapCircleCollision(Bitmap bmp, int cell, Point2D pt, Circle circ);
function BitmapCircleCollision(bmp: Bitmap; cell: Integer; const pt: Point2D; const circ: Circle): Boolean
def bitmap_circle_collision_for_cell_at_point(bmp, cell, pt, circ):

Bitmap Circle Collision

Tests if a bitmap cell drawn at X, Y would intersect with a circle.

Return Type

Boolean

True if a drawn pixel in the bitmap will intersect with Circ when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

X

Double

The x location where the bitmap is drawn

Y

Double

The y location where the bitmap is drawn

Circ

Circle

The circle to test

Signatures
bool bitmap_circle_collision(bitmap bmp, int cell, double x, double y, const circle &circ)
public bool Bitmap.BitmapCircleCollision(int cell, double x, double y, Circle circ);
public static bool SplashKit.BitmapCircleCollision(Bitmap bmp, int cell, double x, double y, Circle circ);
function BitmapCircleCollision(bmp: Bitmap; cell: Integer; x: Double; y: Double; const circ: Circle): Boolean
def bitmap_circle_collision_for_cell(bmp, cell, x, y, circ):

Bitmap Collision

Bitmap Collision

Check if two bitmaps collide.

Return Type

Boolean

True if pixels in the two bitmaps would collide/overlap

Parameters
Name Type Description
Bmp1

Bitmap

The first bitmap

X1

Double

The x location where the first bitmap is drawn

Y1

Double

The y location where the first bitmap is drawn

Bmp2

Bitmap

The second bitmap

X2

Double

The x location where the second bitmap is drawn

Y2

Double

The y location where the second bitmap is drawn

Signatures
bool bitmap_collision(bitmap bmp1, double x1, double y1, bitmap bmp2, double x2, double y2)
public bool Bitmap.BitmapCollision(double x1, double y1, Bitmap bmp2, double x2, double y2);
public static bool SplashKit.BitmapCollision(Bitmap bmp1, double x1, double y1, Bitmap bmp2, double x2, double y2);
function BitmapCollision(bmp1: Bitmap; x1: Double; y1: Double; bmp2: Bitmap; x2: Double; y2: Double): Boolean
def bitmap_collision(bmp1, x1, y1, bmp2, x2, y2):

Bitmap Collision

Check if two bitmaps collide.

Return Type

Boolean

True if pixels in the two bitmaps would collide/overlap

Parameters
Name Type Description
Bmp1

Bitmap

The first bitmap

Pt1

Point 2D

The point where bitmap 1 is drawn

Bmp2

Bitmap

The second bitmap

Pt2

Point 2D

The point where bitmap 2 is drawn

Signatures
bool bitmap_collision(bitmap bmp1, const point_2d &pt1, bitmap bmp2, const point_2d &pt2)
public bool Bitmap.BitmapCollision(Point2D pt1, Bitmap bmp2, Point2D pt2);
public static bool SplashKit.BitmapCollision(Bitmap bmp1, Point2D pt1, Bitmap bmp2, Point2D pt2);
function BitmapCollision(bmp1: Bitmap; const pt1: Point2D; bmp2: Bitmap; const pt2: Point2D): Boolean
def bitmap_collision_at_points(bmp1, pt1, bmp2, pt2):

Bitmap Collision

Check if two bitmaps collide, based on their cell and transform matricies.

Return Type

Boolean

True if pixels in the two bitmaps would collide/overlap

Parameters
Name Type Description
Bmp1

Bitmap

The first bitmap

Cell1

Integer

The cell of the first bitmap.

Matrix1

Matrix 2D

The transformation for the first matrix

Bmp2

Bitmap

The second bitmap

Cell2

Integer

The cell of the second bitmap.

Matrix2

Matrix 2D

The transformation for the second matrix

Signatures
bool bitmap_collision(bitmap bmp1, int cell1, const matrix_2d &matrix1, bitmap bmp2, int cell2, const matrix_2d &matrix2)
public bool Bitmap.BitmapCollision(int cell1, Matrix2D matrix1, Bitmap bmp2, int cell2, Matrix2D matrix2);
public static bool SplashKit.BitmapCollision(Bitmap bmp1, int cell1, Matrix2D matrix1, Bitmap bmp2, int cell2, Matrix2D matrix2);
function BitmapCollision(bmp1: Bitmap; cell1: Integer; const matrix1: Matrix2D; bmp2: Bitmap; cell2: Integer; const matrix2: Matrix2D): Boolean
def bitmap_collision_for_cells_with_translations(bmp1, cell1, matrix1, bmp2, cell2, matrix2):

Bitmap Collision

Check if two bitmaps collide.

Return Type

Boolean

True if pixels in the two bitmaps would collide/overlap

Parameters
Name Type Description
Bmp1

Bitmap

The first bitmap

Cell1

Integer

The cell of the first bitmap.

Pt1

Point 2D

The point where bitmap 1 is drawn

Bmp2

Bitmap

The second bitmap

Cell2

Integer

The cell of the second bitmap.

Pt2

Point 2D

The point where bitmap 2 is drawn

Signatures
bool bitmap_collision(bitmap bmp1, int cell1, const point_2d &pt1, bitmap bmp2, int cell2, const point_2d &pt2)
public bool Bitmap.BitmapCollision(int cell1, Point2D pt1, Bitmap bmp2, int cell2, Point2D pt2);
public static bool SplashKit.BitmapCollision(Bitmap bmp1, int cell1, Point2D pt1, Bitmap bmp2, int cell2, Point2D pt2);
function BitmapCollision(bmp1: Bitmap; cell1: Integer; const pt1: Point2D; bmp2: Bitmap; cell2: Integer; const pt2: Point2D): Boolean
def bitmap_collision_for_cells_at_points(bmp1, cell1, pt1, bmp2, cell2, pt2):

Bitmap Collision

Check if two bitmaps collide.

Return Type

Boolean

True if pixels in the two bitmaps would collide/overlap

Parameters
Name Type Description
Bmp1

Bitmap

The first bitmap

Cell1

Integer

The cell of the first bitmap.

X1

Double

The x location where the first bitmap is drawn

Y1

Double

The y location where the first bitmap is drawn

Bmp2

Bitmap

The second bitmap

Cell2

Integer

The cell of the second bitmap.

X2

Double

The x location where the second bitmap is drawn

Y2

Double

The y location where the second bitmap is drawn

Signatures
bool bitmap_collision(bitmap bmp1, int cell1, double x1, double y1, bitmap bmp2, int cell2, double x2, double y2)
public bool Bitmap.BitmapCollision(int cell1, double x1, double y1, Bitmap bmp2, int cell2, double x2, double y2);
public static bool SplashKit.BitmapCollision(Bitmap bmp1, int cell1, double x1, double y1, Bitmap bmp2, int cell2, double x2, double y2);
function BitmapCollision(bmp1: Bitmap; cell1: Integer; x1: Double; y1: Double; bmp2: Bitmap; cell2: Integer; x2: Double; y2: Double): Boolean
def bitmap_collision_for_cells(bmp1, cell1, x1, y1, bmp2, cell2, x2, y2):

Bitmap Point Collision

Bitmap Point Collision

Tests if a bitmap drawn using the passed in translation matrix would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.

Return Type

Boolean

True if drawing the bitmap, using the passed in translation, will draw a pixel at the indicated point.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test.

Translation

Matrix 2D

The translation matrix that represents the position, scale, and rotation of the bitmap when it is drawn.

Pt

Point 2D

The point in the resulting drawing that is being tested.

Signatures
bool bitmap_point_collision(bitmap bmp, const matrix_2d &translation, const point_2d &pt)
public bool Bitmap.BitmapPointCollision(Matrix2D translation, Point2D pt);
public static bool SplashKit.BitmapPointCollision(Bitmap bmp, Matrix2D translation, Point2D pt);
function BitmapPointCollision(bmp: Bitmap; const translation: Matrix2D; const pt: Point2D): Boolean
def bitmap_point_collision_with_translation(bmp, translation, pt):

Bitmap Point Collision

Tests if a bitmap drawn at the Bmp Pt point would draw a pixel at point Pt. Use to check collisions between a point and a bitmap.

Return Type

Boolean

True if drawing the bitmap, at Bmp Pt, will draw a pixel at the indicated point (Pt).

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test.

Bmp Pt

Point 2D

The point where the bitmap is drawn.

Pt

Point 2D

The point in the resulting drawing that is being tested.

Signatures
bool bitmap_point_collision(bitmap bmp, const point_2d &bmp_pt, const point_2d &pt)
public bool Bitmap.BitmapPointCollision(Point2D bmpPt, Point2D pt);
public static bool SplashKit.BitmapPointCollision(Bitmap bmp, Point2D bmpPt, Point2D pt);
function BitmapPointCollision(bmp: Bitmap; const bmpPt: Point2D; const pt: Point2D): Boolean
def bitmap_point_collision_at_point(bmp, bmp_pt, pt):

Bitmap Point Collision

Tests if a bitmap drawn at x,y would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.

Return Type

Boolean

True if drawing the bitmap, at the indicated location, will draw a pixel at the indicated point.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test.

Bmp X

Double

The x location where the bitmap is drawn

Bmp Y

Double

The y location where the bitmap is drawn

X

Double

The x location of the point to test

Y

Double

The y location of the point to test

Signatures
bool bitmap_point_collision(bitmap bmp, double bmp_x, double bmp_y, double x, double y)
public bool Bitmap.BitmapPointCollision(double bmpX, double bmpY, double x, double y);
public static bool SplashKit.BitmapPointCollision(Bitmap bmp, double bmpX, double bmpY, double x, double y);
function BitmapPointCollision(bmp: Bitmap; bmpX: Double; bmpY: Double; x: Double; y: Double): Boolean
def bitmap_point_collision(bmp, bmp_x, bmp_y, x, y):

Bitmap Point Collision

Tests if a bitmap cell drawn using the passed in translation matrix would draw a pixel at the passed in point.

Return Type

Boolean

True if drawing the bitmap, using the passed in translation, will draw a pixel at the indicated point.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test.

Cell

Integer

The cell of the bitmap to check.

Translation

Matrix 2D

The translation matrix that represents the position, scale, and rotation of the bitmap when it is drawn.

Pt

Point 2D

The point in the resulting drawing that is being tested.

Signatures
bool bitmap_point_collision(bitmap bmp, int cell, const matrix_2d &translation, const point_2d &pt)
public bool Bitmap.BitmapPointCollision(int cell, Matrix2D translation, Point2D pt);
public static bool SplashKit.BitmapPointCollision(Bitmap bmp, int cell, Matrix2D translation, Point2D pt);
function BitmapPointCollision(bmp: Bitmap; cell: Integer; const translation: Matrix2D; const pt: Point2D): Boolean
def bitmap_point_collision_for_cell_with_translation(bmp, cell, translation, pt):

Bitmap Point Collision

Tests if a cell of a bitmap drawn at x,y would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.

Return Type

Boolean

True if drawing the bitmap cell, at the indicated location, will draw a pixel at the indicated point.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to test

Bmp Pt

Point 2D

The point where the bitmap is drawn.

Pt

Point 2D

The point in the resulting drawing that is being tested.

Signatures
bool bitmap_point_collision(bitmap bmp, int cell, const point_2d &bmp_pt, const point_2d &pt)
public bool Bitmap.BitmapPointCollision(int cell, Point2D bmpPt, Point2D pt);
public static bool SplashKit.BitmapPointCollision(Bitmap bmp, int cell, Point2D bmpPt, Point2D pt);
function BitmapPointCollision(bmp: Bitmap; cell: Integer; const bmpPt: Point2D; const pt: Point2D): Boolean
def bitmap_point_collision_for_cell_at_point(bmp, cell, bmp_pt, pt):

Bitmap Point Collision

Tests if a cell of a bitmap drawn at x,y would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.

Return Type

Boolean

True if drawing the bitmap cell, at the indicated location, will draw a pixel at the indicated point.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to test

Bmp X

Double

The x location where the bitmap is drawn

Bmp Y

Double

The y location where the bitmap is drawn

X

Double

The x location of the point to test

Y

Double

The y location of the point to test

Signatures
bool bitmap_point_collision(bitmap bmp, int cell, double bmp_x, double bmp_y, double x, double y)
public bool Bitmap.BitmapPointCollision(int cell, double bmpX, double bmpY, double x, double y);
public static bool SplashKit.BitmapPointCollision(Bitmap bmp, int cell, double bmpX, double bmpY, double x, double y);
function BitmapPointCollision(bmp: Bitmap; cell: Integer; bmpX: Double; bmpY: Double; x: Double; y: Double): Boolean
def bitmap_point_collision_for_cell(bmp, cell, bmp_x, bmp_y, x, y):

Bitmap Rectangle Collision

Bitmap Rectangle Collision

Tests if a bitmap drawn at Pt would intersect with a rectangle.

Return Type

Boolean

True if a drawn pixel in the cell of the bitmap will intersect with Rect when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Pt

Point 2D

The location where the bitmap is drawn

Rect

Rectangle

The rectangle to test

Signatures
bool bitmap_rectangle_collision(bitmap bmp, const point_2d &pt, const rectangle &rect)
public bool Bitmap.BitmapRectangleCollision(Point2D pt, Rectangle rect);
public static bool SplashKit.BitmapRectangleCollision(Bitmap bmp, Point2D pt, Rectangle rect);
function BitmapRectangleCollision(bmp: Bitmap; const pt: Point2D; const rect: Rectangle): Boolean
def bitmap_rectangle_collision_at_point(bmp, pt, rect):

Bitmap Rectangle Collision

Tests if a bitmap drawn at X, Y would intersect with a rectangle.

Return Type

Boolean

True if a drawn pixel in the bitmap will intersect with Rect when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

X

Double

The x location where the bitmap is drawn

Y

Double

The y location where the bitmap is drawn

Rect

Rectangle

The rectangle to test

Signatures
bool bitmap_rectangle_collision(bitmap bmp, double x, double y, const rectangle &rect)
public bool Bitmap.BitmapRectangleCollision(double x, double y, Rectangle rect);
public static bool SplashKit.BitmapRectangleCollision(Bitmap bmp, double x, double y, Rectangle rect);
function BitmapRectangleCollision(bmp: Bitmap; x: Double; y: Double; const rect: Rectangle): Boolean
def bitmap_rectangle_collision(bmp, x, y, rect):

Bitmap Rectangle Collision

Tests if a bitmap cell drawn using a passed in translation, will intersect with a rectangle. You can use this to detect collisions between bitmaps and rectangles.

Return Type

Boolean

True if a drawn pixel in the cell of the bitmap will intersect with Rect when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

Translation

Matrix 2D

The matrix used to transfrom the bitmap when drawing

Rect

Rectangle

The rectangle to test

Signatures
bool bitmap_rectangle_collision(bitmap bmp, int cell, const matrix_2d &translation, const rectangle &rect)
public bool Bitmap.BitmapRectangleCollision(int cell, Matrix2D translation, Rectangle rect);
public static bool SplashKit.BitmapRectangleCollision(Bitmap bmp, int cell, Matrix2D translation, Rectangle rect);
function BitmapRectangleCollision(bmp: Bitmap; cell: Integer; const translation: Matrix2D; const rect: Rectangle): Boolean
def bitmap_rectangle_collision_for_cell_with_translation(bmp, cell, translation, rect):

Bitmap Rectangle Collision

Tests if a bitmap cell drawn at Pt would intersect with a rectangle.

Return Type

Boolean

True if a drawn pixel in the cell of the bitmap will intersect with Rect when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

Pt

Point 2D

The location where the bitmap is drawn

Rect

Rectangle

The rectangle to test

Signatures
bool bitmap_rectangle_collision(bitmap bmp, int cell, const point_2d &pt, const rectangle &rect)
public bool Bitmap.BitmapRectangleCollision(int cell, Point2D pt, Rectangle rect);
public static bool SplashKit.BitmapRectangleCollision(Bitmap bmp, int cell, Point2D pt, Rectangle rect);
function BitmapRectangleCollision(bmp: Bitmap; cell: Integer; const pt: Point2D; const rect: Rectangle): Boolean
def bitmap_rectangle_collision_for_cell_at_point(bmp, cell, pt, rect):

Bitmap Rectangle Collision

Tests if a cell of the bitmap drawn at X, Y would intersect with a rectangle.

Return Type

Boolean

True if a drawn pixel in the bitmap will intersect with Rect when drawn.

Parameters
Name Type Description
Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

X

Double

The x location where the bitmap is drawn

Y

Double

The y location where the bitmap is drawn

Rect

Rectangle

The rectangle to test

Signatures
bool bitmap_rectangle_collision(bitmap bmp, int cell, double x, double y, const rectangle &rect)
public bool Bitmap.BitmapRectangleCollision(int cell, double x, double y, Rectangle rect);
public static bool SplashKit.BitmapRectangleCollision(Bitmap bmp, int cell, double x, double y, Rectangle rect);
function BitmapRectangleCollision(bmp: Bitmap; cell: Integer; x: Double; y: Double; const rect: Rectangle): Boolean
def bitmap_rectangle_collision_for_cell(bmp, cell, x, y, rect):

Sprite Bitmap Collision

Sprite Bitmap Collision

Tests if a sprite will collide with a bitmap drawn at the indicated location.

Return Type

Boolean

True if the sprite collides with the bitmap when drawn at the indicated location.

Parameters
Name Type Description
S

Sprite

The sprite to test

Bmp

Bitmap

The bitmap to test

X

Double

The x location where the bitmap is drawn

Y

Double

The y location where the bitmap is drawn

Signatures
bool sprite_bitmap_collision(sprite s, bitmap bmp, double x, double y)
public bool Sprite.SpriteBitmapCollision(Bitmap bmp, double x, double y);
public static bool SplashKit.SpriteBitmapCollision(Sprite s, Bitmap bmp, double x, double y);
function SpriteBitmapCollision(s: Sprite; bmp: Bitmap; x: Double; y: Double): Boolean
def sprite_bitmap_collision(s, bmp, x, y):

Sprite Bitmap Collision

Tests if a sprite will collide with a bitmap drawn at the indicated location.

Return Type

Boolean

True if the sprite collides with the bitmap cell when drawn at the indicated location.

Parameters
Name Type Description
S

Sprite

The sprite to test

Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

Pt

Point 2D

The point where the bitmap is drawn

Signatures
bool sprite_bitmap_collision(sprite s, bitmap bmp, int cell, const point_2d &pt)
public bool Sprite.SpriteBitmapCollision(Bitmap bmp, int cell, Point2D pt);
public static bool SplashKit.SpriteBitmapCollision(Sprite s, Bitmap bmp, int cell, Point2D pt);
function SpriteBitmapCollision(s: Sprite; bmp: Bitmap; cell: Integer; const pt: Point2D): Boolean
def sprite_bitmap_collision_with_cell_at_point(s, bmp, cell, pt):

Sprite Bitmap Collision

Tests if a sprite will collide with a bitmap drawn at the indicated location.

Return Type

Boolean

True if the sprite collides with the bitmap cell when drawn at the indicated location.

Parameters
Name Type Description
S

Sprite

The sprite to test

Bmp

Bitmap

The bitmap to test

Cell

Integer

The cell of the bitmap to check

X

Double

The x location where the bitmap is drawn

Y

Double

The y location where the bitmap is drawn

Signatures
bool sprite_bitmap_collision(sprite s, bitmap bmp, int cell, double x, double y)
public bool Sprite.SpriteBitmapCollision(Bitmap bmp, int cell, double x, double y);
public static bool SplashKit.SpriteBitmapCollision(Sprite s, Bitmap bmp, int cell, double x, double y);
function SpriteBitmapCollision(s: Sprite; bmp: Bitmap; cell: Integer; x: Double; y: Double): Boolean
def sprite_bitmap_collision_with_cell(s, bmp, cell, x, y):

Sprite Collision

Tests if two given sprites S1 and S2 are collided

Return Type

Boolean

return True if both S1 and S2 are colliding, false otherwise.

Parameters
Name Type Description
S1

Sprite

the first Sprite to test

S2

Sprite

the second Sprite to test

Signatures
bool sprite_collision(sprite s1, sprite s2)
public bool Sprite.SpriteCollision(Sprite s2);
public static bool SplashKit.SpriteCollision(Sprite s1, Sprite s2);
function SpriteCollision(s1: Sprite; s2: Sprite): Boolean
def sprite_collision(s1, s2):

Sprite Point Collision

Tests if a sprite is drawn at a given point.

Return Type

Boolean

True if the sprite it drawn at the indicated point

Parameters
Name Type Description
S

Sprite

The sprite to test

Pt

Point 2D

The point to check

Signatures
bool sprite_point_collision(sprite s, const point_2d &pt)
public bool Sprite.SpritePointCollision(Point2D pt);
public static bool SplashKit.SpritePointCollision(Sprite s, Point2D pt);
function SpritePointCollision(s: Sprite; const pt: Point2D): Boolean
def sprite_point_collision(s, pt):

Sprite Rectangle Collision

Tests if a sprite is drawn within an given area (rectangle).

Return Type

Boolean

True if the sprite it drawn in the rectangle area

Parameters
Name Type Description
S

Sprite

The sprite to test

Rect

Rectangle

The rectangle to check

Signatures
bool sprite_rectangle_collision(sprite s, const rectangle &rect)
public bool Sprite.SpriteRectangleCollision(Rectangle rect);
public static bool SplashKit.SpriteRectangleCollision(Sprite s, Rectangle rect);
function SpriteRectangleCollision(s: Sprite; const rect: Rectangle): Boolean
def sprite_rectangle_collision(s, rect):

Apply Matrix

Apply Matrix

Use a matrix to transform all of the points in a quad.

Parameters
Name Type Description
Matrix

Matrix 2D

The matrix with the transformations needed.

Q

Quad

The quad to transform.

Signatures
void apply_matrix(const matrix_2d &matrix, quad &q)
public static void Matrix2D.ApplyMatrix(Matrix2D matrix, ref Quad q);
public static void SplashKit.ApplyMatrix(Matrix2D matrix, ref Quad q);
procedure ApplyMatrix(const matrix: Matrix2D; var q: Quad)
def apply_matrix_to_quad(matrix, q):

Apply Matrix

Use a matrix to transform all of the points in a triangle.

Parameters
Name Type Description
M

Matrix 2D

The matrix to be applied to the triangle.

Tri

Triangle

The triangle to tranform.

Signatures
void apply_matrix(const matrix_2d &m, triangle &tri)
public static void Matrix2D.ApplyMatrix(Matrix2D m, ref Triangle tri);
public static void SplashKit.ApplyMatrix(Matrix2D m, ref Triangle tri);
procedure ApplyMatrix(const m: Matrix2D; var tri: Triangle)
def apply_matrix_to_triangle(m, tri):

Identity Matrix

Returns the identity matrix. When a matrix_2d or Vector is multiplied by the identity matrix the result is the original matrix or vector.

Return Type

Matrix 2D

An identify matrix.

Signatures
matrix_2d identity_matrix()
public static Matrix2D Matrix2D.IdentityMatrix();
public static Matrix2D SplashKit.IdentityMatrix();
function IdentityMatrix(): Matrix2D
def identity_matrix():

Matrix Inverse

Calculate the inverse of a matrix.

Return Type

Matrix 2D

A matrix that is the inverse of m

Parameters
Name Type Description
M

Matrix 2D

The matrix to invert.

Signatures
matrix_2d matrix_inverse(const matrix_2d &m)
public static Matrix2D Matrix2D.MatrixInverse(Matrix2D m);
public static Matrix2D SplashKit.MatrixInverse(Matrix2D m);
function MatrixInverse(const m: Matrix2D): Matrix2D
def matrix_inverse(m):

Matrix Multiply

Matrix Multiply

Multiplies the Point 2D parameter V With Thematrix_2d`m and returns the result as a [Point 2D`](/api/types/#point-2d). Use this to transform the vector with the matrix (to apply scaling, rotation or translation effects).

Return Type

Point 2D

A new point, the result of applying the transformation to pt.

Parameters
Name Type Description
M

Matrix 2D

The matrix with the transformation to apply.

Pt

Point 2D

The point to be transformed.

Signatures
point_2d matrix_multiply(const matrix_2d &m, const point_2d &pt)
public static Point2D Matrix2D.MatrixMultiply(Matrix2D m, Point2D pt);
public static Point2D SplashKit.MatrixMultiply(Matrix2D m, Point2D pt);
function MatrixMultiply(const m: Matrix2D; const pt: Point2D): Point2D
def matrix_multiply_point(m, pt):

Matrix Multiply

Multiplies the two Matrix 2D parameters, M1 by M2, and returns the result as a new Matrix 2D. Use this to combine the effects to two matrix transformations.

Return Type

Matrix 2D

The result of multiplying m1 by m2

Parameters
Name Type Description
M1

Matrix 2D

The first matrix

M2

Matrix 2D

The second matrix

Signatures
matrix_2d matrix_multiply(const matrix_2d &m1, const matrix_2d &m2)
public static Matrix2D Matrix2D.MatrixMultiply(Matrix2D m1, Matrix2D m2);
public static Matrix2D SplashKit.MatrixMultiply(Matrix2D m1, Matrix2D m2);
function MatrixMultiply(const m1: Matrix2D; const m2: Matrix2D): Matrix2D
def matrix_multiply_matrix(m1, m2):

Matrix Multiply

Multiplies the Dynamic Array parameter V with the Matrix 2D M and returns the result as a Dynamic Array. Use this to transform the vector with the matrix (to apply scaling, rotation or translation effects).

Return Type

Vector 2D

A new vector, the result of applying the transformation to v.

Parameters
Name Type Description
M

Matrix 2D

The matrix with the transformation to apply.

V

Vector 2D

The vector to be transformed.

Signatures
vector_2d matrix_multiply(const matrix_2d &m, const vector_2d &v)
public static Vector2D Matrix2D.MatrixMultiply(Matrix2D m, Vector2D v);
public static Vector2D SplashKit.MatrixMultiply(Matrix2D m, Vector2D v);
function MatrixMultiply(const m: Matrix2D; const v: Vector2D): Vector2D
def matrix_multiply_vector(m, v):

Matrix To String

This function returns a string representation of a Matrix.

Return Type

String

A string representation of the matrix.

Parameters
Name Type Description
Matrix

Matrix 2D

The matrix to convert to a string.

Signatures
string matrix_to_string(const matrix_2d &matrix)
public static string Matrix2D.MatrixToString(Matrix2D matrix);
public static string SplashKit.MatrixToString(Matrix2D matrix);
function MatrixToString(const matrix: Matrix2D): String
def matrix_to_string(matrix):

Rotation Matrix

Returns a rotation matrix that rotates 2d points by the angle.

Return Type

Matrix 2D

A matrix that encodes the rotation by a number of degrees.

Parameters
Name Type Description
Deg

Double

The amount to rotate points

Signatures
matrix_2d rotation_matrix(double deg)
public static Matrix2D Matrix2D.RotationMatrix(double deg);
public static Matrix2D SplashKit.RotationMatrix(double deg);
function RotationMatrix(deg: Double): Matrix2D
def rotation_matrix(deg):

Scale Matrix

Scale Matrix

Create a scale matrix that scales x and y to different degrees.

Return Type

Matrix 2D

A matrix that will scale points based on scale parameter.

Parameters
Name Type Description
Scale

Point 2D

The amount to scale, with separate x and y components.

Signatures
matrix_2d scale_matrix(const point_2d &scale)
public static Matrix2D Matrix2D.ScaleMatrix(Point2D scale);
public static Matrix2D SplashKit.ScaleMatrix(Point2D scale);
function ScaleMatrix(const scale: Point2D): Matrix2D
def scale_matrix_from_point(scale):

Scale Matrix

Create a scale matrix that scales x and y to different degrees.

Return Type

Matrix 2D

A matrix that will scale points based on scale parameter.

Parameters
Name Type Description
Scale

Vector 2D

The amount to scale, with separate x and y components.

Signatures
matrix_2d scale_matrix(const vector_2d &scale)
public static Matrix2D Matrix2D.ScaleMatrix(Vector2D scale);
public static Matrix2D SplashKit.ScaleMatrix(Vector2D scale);
function ScaleMatrix(const scale: Vector2D): Matrix2D
def scale_matrix_from_vector(scale):

Scale Matrix

Returns a matrix that can be used to scale 2d points (both x and y).

Return Type

Matrix 2D

A matrix to scale points by.

Parameters
Name Type Description
Scale

Double

The amount to scale points by.

Signatures
matrix_2d scale_matrix(double scale)
public static Matrix2D Matrix2D.ScaleMatrix(double scale);
public static Matrix2D SplashKit.ScaleMatrix(double scale);
function ScaleMatrix(scale: Double): Matrix2D
def scale_matrix(scale):

Scale Rotate Translate Matrix

Create a matrix that can scale, rotate then translate geometry points.

Return Type

Matrix 2D

A matrix that will scale, rotate, and translate.

Parameters
Name Type Description
Scale

Point 2D

The amount to scale

Deg

Double

The amount to rotate

Translate

Point 2D

The amount to move

Signatures
matrix_2d scale_rotate_translate_matrix(const point_2d &scale, double deg, const point_2d &translate)
public static Matrix2D Matrix2D.ScaleRotateTranslateMatrix(Point2D scale, double deg, Point2D translate);
public static Matrix2D SplashKit.ScaleRotateTranslateMatrix(Point2D scale, double deg, Point2D translate);
function ScaleRotateTranslateMatrix(const scale: Point2D; deg: Double; const translate: Point2D): Matrix2D
def scale_rotate_translate_matrix(scale, deg, translate):

Translation Matrix

Translation Matrix

Returns a translation matric used to translate 2d points by the distance in the point_2d.

Return Type

Matrix 2D

A matrix that will move points by amount in pt

Parameters
Name Type Description
Pt

Point 2D

The point to translate to.

Signatures
matrix_2d translation_matrix(const point_2d &pt)
public static Matrix2D Matrix2D.TranslationMatrix(Point2D pt);
public static Matrix2D SplashKit.TranslationMatrix(Point2D pt);
function TranslationMatrix(const pt: Point2D): Matrix2D
def translation_matrix_to_point(pt):

Translation Matrix

Returns a translation matric used to translate 2d points by the distance in the vector_2d.

Return Type

Matrix 2D

A matrix that will move points by amount in pt

Parameters
Name Type Description
Pt

Vector 2D

The point to translate to.

Signatures
matrix_2d translation_matrix(const vector_2d &pt)
public static Matrix2D Matrix2D.TranslationMatrix(Vector2D pt);
public static Matrix2D SplashKit.TranslationMatrix(Vector2D pt);
function TranslationMatrix(const pt: Vector2D): Matrix2D
def translation_matrix_from_vector(pt):

Translation Matrix

Returns a matrix that can be used to translate 2d points. Moving them by dx and dy.

Return Type

Matrix 2D

A matrix that will move points by dx, dy

Parameters
Name Type Description
Dx

Double

The amount to move points along the x axis.

Dy

Double

The amount to move points along the y axis.

Signatures
matrix_2d translation_matrix(double dx, double dy)
public static Matrix2D Matrix2D.TranslationMatrix(double dx, double dy);
public static Matrix2D SplashKit.TranslationMatrix(double dx, double dy);
function TranslationMatrix(dx: Double; dy: Double): Matrix2D
def translation_matrix(dx, dy):

Angle Between

Calculates the angle from one vector to another.

Return Type

Double

The angle of the line from the end of V1 to the end of V2

Parameters
Name Type Description
V1

Vector 2D

The first vector

V2

Vector 2D

The second vector

Signatures
double angle_between(const vector_2d &v1, const vector_2d &v2)
public static double Vector2D.AngleBetween(Vector2D v1, Vector2D v2);
public static double SplashKit.AngleBetween(Vector2D v1, Vector2D v2);
function AngleBetween(const v1: Vector2D; const v2: Vector2D): Double
def angle_between(v1, v2):

Dot Product

Calculates the dot product (scalar product) between the two vector parameters provided (V1 and V2). It returns the result as a scalar value.

If the result is 0.0 it means that the vectors are orthogonal (at right angles to each other). If V1 and V2 are unit vectors (length of 1.0) and the dot product is 1.0, it means that V1 and V2 vectors are parallel.

Return Type

Double

The dot product of V1 . V2

Parameters
Name Type Description
V1

Vector 2D

The first vector

V2

Vector 2D

The other vector

Signatures
double dot_product(const vector_2d &v1, const vector_2d &v2)
public static double Vector2D.DotProduct(Vector2D v1, Vector2D v2);
public static double SplashKit.DotProduct(Vector2D v1, Vector2D v2);
function DotProduct(const v1: Vector2D; const v2: Vector2D): Double
def dot_product(v1, v2):

Is Zero Vector

Returns if the vector is a null/zero vector -- having no size or direction.

Return Type

Boolean

True if V has no magnitude.

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
bool is_zero_vector(const vector_2d &v)
public static bool Vector2D.IsZeroVector(Vector2D v);
public static bool SplashKit.IsZeroVector(Vector2D v);
function IsZeroVector(const v: Vector2D): Boolean
def is_zero_vector(v):

Ray Intersection Point

Casts a ray in a heading and returns true is it intersects with a line

Return Type

Boolean

True if the line and ray will intersect, in which case the value of Pt will be changed to be the point where the intersection occurs.

Parameters
Name Type Description
From Pt

Point 2D

The origin of the ray

Heading

Vector 2D

The direction the ray is heading (as a Vector 2D)

L

Line

The line to be checked

Pt

Point 2D

Outputs the point where the line and ray intersect

Signatures
bool ray_intersection_point(const point_2d &from_pt, const vector_2d &heading, const line &l, point_2d &pt)
public static bool Vector2D.RayIntersectionPoint(Point2D fromPt, Vector2D heading, Line l, ref Point2D pt);
public static bool SplashKit.RayIntersectionPoint(Point2D fromPt, Vector2D heading, Line l, ref Point2D pt);
function RayIntersectionPoint(const fromPt: Point2D; const heading: Vector2D; const l: Line; var pt: Point2D): Boolean
def ray_intersection_point(from_pt, heading, l, pt):

Unit Vector

Returns the unit vector of the parameter vector (v). The unit vector has a magnitude of 1, resulting in a vector that indicates the direction of the original vector.

Return Type

Vector 2D

The unit vector of V

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
vector_2d unit_vector(const vector_2d &v)
public static Vector2D Vector2D.UnitVector(Vector2D v);
public static Vector2D SplashKit.UnitVector(Vector2D v);
function UnitVector(const v: Vector2D): Vector2D
def unit_vector(v):

Vector Add

Adds the two passed in vectors returns the result as new Vector 2D.

Return Type

Vector 2D

The result of adding the movements of the two vectors together.

Parameters
Name Type Description
V1

Vector 2D

The first vector.

V2

Vector 2D

The other vector.

Signatures
vector_2d vector_add(const vector_2d &v1, const vector_2d &v2)
public static Vector2D Vector2D.VectorAdd(Vector2D v1, Vector2D v2);
public static Vector2D SplashKit.VectorAdd(Vector2D v1, Vector2D v2);
function VectorAdd(const v1: Vector2D; const v2: Vector2D): Vector2D
def vector_add(v1, v2):

Vector Angle

Calculates the angle of a vector

Return Type

Double

The angle of the vector in degrees

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
double vector_angle(const vector_2d v)
public static double Vector2D.VectorAngle(Vector2D v);
public static double SplashKit.VectorAngle(Vector2D v);
function VectorAngle(v: Vector2D): Double
def vector_angle(v):

Vector From Angle

Returns a Vector 2D from the supplied angle and distance.

Return Type

Vector 2D

A vector that will move things at that angle and magnitude

Parameters
Name Type Description
Angle

Double

The angle in degrees

Magnitude

Double

The length of the vector

Signatures
vector_2d vector_from_angle(double angle, double magnitude)
public static Vector2D Vector2D.VectorFromAngle(double angle, double magnitude);
public static Vector2D SplashKit.VectorFromAngle(double angle, double magnitude);
function VectorFromAngle(angle: Double; magnitude: Double): Vector2D
def vector_from_angle(angle, magnitude):

Vector From Line

Returns a vector that points from the start to the end of a line.

Return Type

Vector 2D

A vector that will move things from the start to the end of the line

Parameters
Name Type Description
L

Line

The line

Signatures
vector_2d vector_from_line(const line &l)
public static Vector2D Vector2D.VectorFromLine(Line l);
public static Vector2D SplashKit.VectorFromLine(Line l);
function VectorFromLine(const l: Line): Vector2D
def vector_from_line(l):

Vector From Point To Rect

Returns a vector from a point to a rectangle.

Return Type

Vector 2D

A vector representing the distance and direction from Pt to Rect

Parameters
Name Type Description
Pt

Point 2D

The point

Rect

Rectangle

The rectangle

Signatures
vector_2d vector_from_point_to_rect(const point_2d &pt, const rectangle &rect)
public static Vector2D Vector2D.VectorFromPointToRect(Point2D pt, Rectangle rect);
public static Vector2D SplashKit.VectorFromPointToRect(Point2D pt, Rectangle rect);
function VectorFromPointToRect(const pt: Point2D; const rect: Rectangle): Vector2D
def vector_from_point_to_rect(pt, rect):

Vector In Rect

Returns true if the resulting vector would end in the rectangle if placed at the origin.

Return Type

Boolean

True if the vector would end in the rectangle

Parameters
Name Type Description
V

Vector 2D

The vector

Rect

Rectangle

The rectangle

Signatures
bool vector_in_rect(const vector_2d &v, const rectangle &rect)
public static bool Vector2D.VectorInRect(Vector2D v, Rectangle rect);
public static bool SplashKit.VectorInRect(Vector2D v, Rectangle rect);
function VectorInRect(const v: Vector2D; const rect: Rectangle): Boolean
def vector_in_rect(v, rect):

Vector Invert

Returns a new Vector that is an inverted version of the parameter vector (v). In other words, the -/+ sign of the x and y values are changed.

Return Type

Vector 2D

The inverse (reverse) of V

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
vector_2d vector_invert(const vector_2d &v)
public static Vector2D Vector2D.VectorInvert(Vector2D v);
public static Vector2D SplashKit.VectorInvert(Vector2D v);
function VectorInvert(const v: Vector2D): Vector2D
def vector_invert(v):

Vector Limit

Returns a scaled vector that ensures the new vector points in the same direction as v, but has a magnitude that is limited to the length specified in the limit prameter.

Return Type

Vector 2D

A new vector in the same direction as v, but with a magnitude that is less than or equal to the limit.

Parameters
Name Type Description
V

Vector 2D

The vector

Limit

Double

Its maximum magnitude

Signatures
vector_2d vector_limit(const vector_2d &v, double limit)
public static Vector2D Vector2D.VectorLimit(Vector2D v, double limit);
public static Vector2D SplashKit.VectorLimit(Vector2D v, double limit);
function VectorLimit(const v: Vector2D; limit: Double): Vector2D
def vector_limit(v, limit):

Vector Magnitude

Returns the magnitude (or "length") of the vector.

Return Type

Double

Its magnitude

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
double vector_magnitude(const vector_2d &v)
public static double Vector2D.VectorMagnitude(Vector2D v);
public static double SplashKit.VectorMagnitude(Vector2D v);
function VectorMagnitude(const v: Vector2D): Double
def vector_magnitude(v):

Vector Magnitude Sqared

Returns the squared magnitude (or "length") of the vector.

Return Type

Double

Its squared magnitude

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
double vector_magnitude_sqared(const vector_2d &v)
public static double Vector2D.VectorMagnitudeSqared(Vector2D v);
public static double SplashKit.VectorMagnitudeSqared(Vector2D v);
function VectorMagnitudeSqared(const v: Vector2D): Double
def vector_magnitude_sqared(v):

Vector Multiply

Multiplies the vector by the passed in value.

Return Type

Vector 2D

A new vector

Parameters
Name Type Description
V1

Vector 2D

The original vector

S

Double

The amount to multiply by

Signatures
vector_2d vector_multiply(const vector_2d &v1, double s)
public static Vector2D Vector2D.VectorMultiply(Vector2D v1, double s);
public static Vector2D SplashKit.VectorMultiply(Vector2D v1, double s);
function VectorMultiply(const v1: Vector2D; s: Double): Vector2D
def vector_multiply(v1, s):

Vector Normal

Returns a new Vector 2D that is perpendicular ("normal") to the parameter vector V provided. The concept of a "normal" vector is usually extracted from (or associated with) a line.

Note: when passed a zero or null vector (a vector with no magnitude or direction) then this function returns a zero/null vector.

Return Type

Vector 2D

The normal of V

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
vector_2d vector_normal(const vector_2d &v)
public static Vector2D Vector2D.VectorNormal(Vector2D v);
public static Vector2D SplashKit.VectorNormal(Vector2D v);
function VectorNormal(const v: Vector2D): Vector2D
def vector_normal(v):

Vector Out Of Circle From Circle

Returns a vector to back one circle out of another, assuming the first circle was moving at a specified velocity.

Return Type

Vector 2D

A vector that can move the circle out of the bounds

Parameters
Name Type Description
Src

Circle

The circle that is moving

Bounds

Circle

The area you want to move the circle out of

Velocity

Vector 2D

The circle's velocity

Signatures
vector_2d vector_out_of_circle_from_circle(const circle &src, const circle &bounds, const vector_2d &velocity)
public static Vector2D Vector2D.VectorOutOfCircleFromCircle(Circle src, Circle bounds, Vector2D velocity);
public static Vector2D SplashKit.VectorOutOfCircleFromCircle(Circle src, Circle bounds, Vector2D velocity);
function VectorOutOfCircleFromCircle(const src: Circle; const bounds: Circle; const velocity: Vector2D): Vector2D
def vector_out_of_circle_from_circle(src, bounds, velocity):

Vector Out Of Circle From Point

Returns the vector out to move a point back out of a circle, given the point was moving at the specified velocity.

Return Type

Vector 2D

A vector that can move the point out of the circle

Parameters
Name Type Description
Pt

Point 2D

The point that is moving

C

Circle

The circle you want to move the point out of

Velocity

Vector 2D

The point's velocity

Signatures
vector_2d vector_out_of_circle_from_point(const point_2d &pt, const circle &c, const vector_2d &velocity)
public static Vector2D Vector2D.VectorOutOfCircleFromPoint(Point2D pt, Circle c, Vector2D velocity);
public static Vector2D SplashKit.VectorOutOfCircleFromPoint(Point2D pt, Circle c, Vector2D velocity);
function VectorOutOfCircleFromPoint(const pt: Point2D; const c: Circle; const velocity: Vector2D): Vector2D
def vector_out_of_circle_from_point(pt, c, velocity):

Vector Out Of Rect From Circle

Returns a vector that can be used to move a circle back out of a rectangle, given that the circle is moving at the specified velocity.

Return Type

Vector 2D

A vector that will move the circle out of the rectangle

Parameters
Name Type Description
C

Circle

The circle that is moving

Rect

Rectangle

The area you wan to move the circle out of

Velocity

Vector 2D

The circle's velocity

Signatures
vector_2d vector_out_of_rect_from_circle(const circle &c, const rectangle &rect, const vector_2d &velocity)
public static Vector2D Vector2D.VectorOutOfRectFromCircle(Circle c, Rectangle rect, Vector2D velocity);
public static Vector2D SplashKit.VectorOutOfRectFromCircle(Circle c, Rectangle rect, Vector2D velocity);
function VectorOutOfRectFromCircle(const c: Circle; const rect: Rectangle; const velocity: Vector2D): Vector2D
def vector_out_of_rect_from_circle(c, rect, velocity):

Vector Out Of Rect From Point

Determines the vector needed to move back from point Pt out of rectangle Rect given the point was moving at the velocity specified.

Return Type

Vector 2D

A vector that can move the point outside of the rectangle.

Parameters
Name Type Description
Pt

Point 2D

The point you want to move out of a rectangle

Rect

Rectangle

The rectangle to move out of

Velocity

Vector 2D

The velocity of the point. This is used to determine where the point should return to.

Signatures
vector_2d vector_out_of_rect_from_point(const point_2d &pt, const rectangle &rect, const vector_2d &velocity)
public static Vector2D Vector2D.VectorOutOfRectFromPoint(Point2D pt, Rectangle rect, Vector2D velocity);
public static Vector2D SplashKit.VectorOutOfRectFromPoint(Point2D pt, Rectangle rect, Vector2D velocity);
function VectorOutOfRectFromPoint(const pt: Point2D; const rect: Rectangle; const velocity: Vector2D): Vector2D
def vector_out_of_rect_from_point(pt, rect, velocity):

Vector Out Of Rect From Rect

Returns the vector needed to move rectangle Src back out of rectangle Bounds assuming the rectangle was moving at the velocity specified.

Return Type

Vector 2D

A vector that can move the rectangle out of the bounds

Parameters
Name Type Description
Src

Rectangle

The rectangle you want to move.

Bounds

Rectangle

The area you want to move the rectangle out of

Velocity

Vector 2D

The velocity of the Src rectangle

Signatures
vector_2d vector_out_of_rect_from_rect(const rectangle &src, const rectangle &bounds, const vector_2d &velocity)
public static Vector2D Vector2D.VectorOutOfRectFromRect(Rectangle src, Rectangle bounds, Vector2D velocity);
public static Vector2D SplashKit.VectorOutOfRectFromRect(Rectangle src, Rectangle bounds, Vector2D velocity);
function VectorOutOfRectFromRect(const src: Rectangle; const bounds: Rectangle; const velocity: Vector2D): Vector2D
def vector_out_of_rect_from_rect(src, bounds, velocity):

Vector Point To Point

Returns a Vector 2D created from the difference from the P1 to the second P2 points (Point2d).

Return Type

Vector 2D

A vector that will move things from the starting point to the ending point

Parameters
Name Type Description
Start

Point 2D

The starting point

End Pt

Point 2D

The ending point

Signatures
vector_2d vector_point_to_point(const point_2d &start, const point_2d &end_pt)
public static Vector2D Vector2D.VectorPointToPoint(Point2D start, Point2D endPt);
public static Vector2D SplashKit.VectorPointToPoint(Point2D start, Point2D endPt);
function VectorPointToPoint(const start: Point2D; const endPt: Point2D): Vector2D
def vector_point_to_point(start, end_pt):

Vector Subtract

Subtracts the second vector parameter (V2) from the first vector (V1) and returns the result as new Vector 2D.

Return Type

Vector 2D

The result of subtracting the movements of V2 from V1.

Parameters
Name Type Description
V1

Vector 2D

The first vector.

V2

Vector 2D

The other vector.

Signatures
vector_2d vector_subtract(const vector_2d &v1, const vector_2d &v2)
public static Vector2D Vector2D.VectorSubtract(Vector2D v1, Vector2D v2);
public static Vector2D SplashKit.VectorSubtract(Vector2D v1, Vector2D v2);
function VectorSubtract(const v1: Vector2D; const v2: Vector2D): Vector2D
def vector_subtract(v1, v2):

Vector To

This function is overloaded. The following versions exist.

Vector To

Returns a new Vector 2D using the x and y value of a Point 2D parameter. This is a vector from the origin to that point.

Return Type

Vector 2D

A vector from the origin to P1

Parameters
Name Type Description
P1

Point 2D

The point

Signatures
vector_2d vector_to(const point_2d &p1)
public static Vector2D Vector2D.VectorTo(Point2D p1);
public static Vector2D SplashKit.VectorTo(Point2D p1);
function VectorTo(const p1: Point2D): Vector2D
def vector_to_point(p1):

Vector To

Returns a vector to the indicated point.

Return Type

Vector 2D

A vector that will move things the indicated amount

Parameters
Name Type Description
X

Double

The amount to move horizontally

Y

Double

The amount to move vertically

Signatures
vector_2d vector_to(double x, double y)
public static Vector2D Vector2D.VectorTo(double x, double y);
public static Vector2D SplashKit.VectorTo(double x, double y);
function VectorTo(x: Double; y: Double): Vector2D
def vector_to(x, y):

Vector To String

Get a text description of the Vector 2D.

Return Type

String

A string representation of the vector

Parameters
Name Type Description
V

Vector 2D

The vector

Signatures
string vector_to_string(const vector_2d &v)
public static string Vector2D.VectorToString(Vector2D v);
public static string SplashKit.VectorToString(Vector2D v);
function VectorToString(const v: Vector2D): String
def vector_to_string(v):

Vectors Equal

Determines if two vectors are the same.

Return Type

Boolean

True if the two vectors are equal.

Parameters
Name Type Description
V1

Vector 2D

The first vector

V2

Vector 2D

The other vector

Signatures
bool vectors_equal(const vector_2d &v1, const vector_2d v2)
public static bool Vector2D.VectorsEqual(Vector2D v1, Vector2D v2);
public static bool SplashKit.VectorsEqual(Vector2D v1, Vector2D v2);
function VectorsEqual(const v1: Vector2D; v2: Vector2D): Boolean
def vectors_equal(v1, v2):

Vectors Not Equal

Determines if two vectors are not the same.

Return Type

Boolean

True if the two vectors are different.

Parameters
Name Type Description
V1

Vector 2D

The first vector

V2

Vector 2D

The other vector

Signatures
bool vectors_not_equal(const vector_2d &v1, const vector_2d v2)
public static bool Vector2D.VectorsNotEqual(Vector2D v1, Vector2D v2);
public static bool SplashKit.VectorsNotEqual(Vector2D v1, Vector2D v2);
function VectorsNotEqual(const v1: Vector2D; v2: Vector2D): Boolean
def vectors_not_equal(v1, v2):

Types

Matrix 2D

In SplashKit, matrices can be used to combine together a number of operations that need to be performed on Vector 2D values. You can translate, rotate and scale, and combine these together into a single matrix that can then be applied to vectors and points.

Fields
Name Type Description
Elements

Double

The elements of the matrix