Skip to content

Types

Functions

Types

Animation

Animations are created from an Animation Script. Each animation tracks the current frame for one animation sequence. You update this animation and draw with it. This allows you to have the one script being used to create lots of individual animations, where each animation is potentially at a different frame.


Animation Script

Animations in SplashKit are controlled by an animation script. This script tells SplashKit how long to play each frame, which cell in the bitmap the frame relates to, and which is the next frame. You load these scripts from file and can then use them to create animations that are used with the drawing options when you draw a bitmap.


Bitmap

Bitmaps represent image resources in SplashKit. You can load these from file, download them from the internet, or create and draw them yourself. Once created or loaded, you can draw the bitmap and you can draw onto the bitmap.


Circle

FieldTypeDescription
centerPoint 2dThe center point of the circle
radiusDoubleThe radius of the circle

Circles have a center point and a radius. This means that, unlike shapes like the Rectangle, the circle extends out both left and right, and up and down from the point you position it at.


Color

FieldTypeDescription
rFloatThe red component of the color (between 0 and 1.0)
gFloatThe green component of the color (between 0 and 1.0)
bFloatThe blue component of the color (between 0 and 1.0)
aFloatThe alpha component of the color (between 0 and 1.0)

Colors can be used when drawing shapes and clearing surfaces. Color in splashkit does include a alpha value used for opacity, which allows you to have partially transparent colors.


Display

Each display value represents a physical display attached to the computer. You can use this to query the displays position and size.


Drawing Dest

ConstantDescription
DRAW_TO_SCREENmeans camera has no affect.
DRAW_TO_WORLDmeans camera has an affect.
DRAW_DEFAULTmeans camera has an affect only if drawn to awindow.

Determines the effect of the camera on a drawing operation.


Drawing Options

FieldTypeDescription
destVoidThe destination of the drawing: a window or bitmap.
scale_xFloatHow much x values are scaled.
scale_yFloatHow much y values are scaled.
angleFloatA rotation angle for bitmap drawing.
anchor_offset_xFloatThe x location of the anchor point around whichbitmap drawing will rotate.
anchor_offset_yFloatThe y location of the anchor point around whichbitmap drawing will rotate.
flip_xBooleanShould bitmaps be flipped horizontally
flip_yBooleanShould bitmaps be flipped vertically
is_partBooleanIndicates that part of a bitmap should be drawn
partRectangleThe area of the bitmap to draw
draw_cellIntegerWhich cell of a bitmap to draw, or -1 for all. Overridesparts and animation settings.
cameraDrawing DestHow the current window camera affects the drawing
line_widthIntegerHow wide are lines (only lines at this stage)
animAnimationThe animation to use, which overrides the partoption

Drawing options allow you to customise drawing options. These should be initialised using the drawing option functions such as option_defaults.


Font

Fonts are used to draw text in SplashKit. These can be loaded from file or downloaded from the internet. Once you have a font you can use the draw text procedures to use that font when drawing.


Font Style

ConstantDescription
NORMAL_FONTNormal font.
BOLD_FONTBold font.
ITALIC_FONTItalic font.
UNDERLINE_FONTUnderlined font.

Use font styles to set the style of a font. Setting the style is time consuming, so create alternative font variables for each different style you want to work with. Note that these values can be logical ORed together to combine styles, e.g. BoldFont or ItalicFont = both bold and italic.


Http Status Code

ConstantDescription
HTTP_STATUS_OKThe server accepted the request.
HTTP_STATUS_CREATEDThe request has been fulfilled, resulting in the creation of a new resource.
HTTP_STATUS_NO_CONTENTThe server successfully processed the request and is not returning any content.
HTTP_STATUS_MOVED_PERMANENTLYThe URL of the requested resource has been changed permanently.
HTTP_STATUS_FOUNDThe URI of requested resource has been changed temporarily.
HTTP_STATUS_SEE_OTHERThe server sent this response to direct the client to get the requested resource at another URI with a GET request.
HTTP_STATUS_BAD_REQUESTThe server cannot or will not process the request due to an apparent client error.
HTTP_STATUS_UNAUTHORIZEDThe server requires authentication or has failed to process provided authentication.
HTTP_STATUS_FORBIDDENThe request was a valid request, but the server is refusing to respond to it.
HTTP_STATUS_NOT_FOUNDThe requested resource could not be found but may be available in the future.
HTTP_STATUS_METHOD_NOT_ALLOWEDThe request method is not support for the requested resource.
HTTP_STATUS_REQUEST_TIMEOUTThe server timed out waiting for the request.
HTTP_STATUS_CONFLICTThe request conflicts with current state of the server.
HTTP_STATUS_INTERNAL_SERVER_ERRORThe server encountered an unexpected condition.
HTTP_STATUS_NOT_IMPLEMENTEDThe server does not recognize or implement the request method.
HTTP_STATUS_SERVICE_UNAVAILABLEThe server is currently unavailable.

Defines the HTTP status codes supported by SplashKit. Refer to this article for a detailed description of each code.


Interface Style

ConstantDescription
FLAT_DARK_STYLEA flat, dark-mode interface.
SHADED_DARK_STYLEA dark-mode interface with shadows and depth.
FLAT_LIGHT_STYLEA flat, light-mode interface.
SHADED_LIGHT_STYLEA light-mode interface with shadows and depth.
BUBBLEA light-mode interface with a semi-transparent bubbly look.
BUBBLE_MULTICOLOREDA light-mode interface with a semi-transparent bubbly look - gives a multi-coloured result when provided a color.

Use these interface styles as a way to quickly customize your interface.


Line

FieldTypeDescription
start_pointPoint 2dThe start of the line
end_pointPoint 2dThe end of the line

A line goes from a start point to an end point.


Pin Modes

ConstantDescription
GPIO_INPUTInput mode.
GPIO_OUTPUTOutput mode.
GPIO_ALT0Alternate function mode 0.
GPIO_ALT1Alternate function mode 1.
GPIO_ALT2Alternate function mode 2.
GPIO_ALT3Alternate function mode 3.
GPIO_ALT4Alternate function mode 4.
GPIO_ALT5Alternate function mode 5.
GPIO_DEFAULT_MODEDefault mode.

GPIO Pin Modes:


Pin Values

ConstantDescription
GPIO_LOWLogic low (0).
GPIO_HIGHLogic high (1).
GPIO_DEFAULT_VALUEDefault value.

GPIO Pin Values:


Pins

ConstantDescription
PIN_13.3V Power Supply
PIN_25V Power Supply
PIN_3GPIO2 / SDA (I2C)
PIN_45V Power Supply
PIN_5GPIO3 / SCL (I2C)
PIN_6Ground
PIN_7GPIO4
PIN_8GPIO14 / TXD (UART)
PIN_9Ground
PIN_10GPIO15 / RXD (UART)
PIN_11GPIO17
PIN_12GPIO18 / PCM_CLK
PIN_13GPIO27
PIN_14Ground
PIN_15GPIO22
PIN_16GPIO23
PIN_173.3V Power Supply
PIN_18GPIO24
PIN_19GPIO10 / MOSI (SPI)
PIN_20Ground
PIN_21GPIO9 / MISO (SPI)
PIN_22GPIO25
PIN_23GPIO11 / SCLK (SPI)
PIN_24GPIO8 / CE0 (SPI)
PIN_25Ground
PIN_26GPIO7 / CE1 (SPI)
PIN_27ID_SD (I2C ID EEPROM)
PIN_28ID_SC (I2C ID EEPROM)
PIN_29GPIO5
PIN_30Ground
PIN_31GPIO6
PIN_32GPIO12
PIN_33GPIO13
PIN_34Ground
PIN_35GPIO19 / MISO (PCM)
PIN_36GPIO16 / CE0 (PCM)
PIN_37GPIO26
PIN_38GPIO20 / MOSI (PCM)
PIN_39Ground
PIN_40GPIO21 / SCLK (PCM)

Raspberry Pi GPIO Board Pin Descriptions:


Point 2d

FieldTypeDescription
xDoubleThe distance from the left side of the bitmap or window (increasing as you go to the right)
yDoubleThe distance from the top of a bitmap or window (increasingas you go down).

A Point2D represents an location in Cartesian coordinates (x,y). The x value represents the distance from the left edge of the window or bitmap, increasing in value as you travel right. The y value represents the distance from the top edge of the window or bitmap, and increases as you travel down toward the bottom.

Point2D is a great way to keep track of the location of something in a 2D space like a Window or Bitmap.


Pull Up Down

ConstantDescription
PUD_OFFNo pull-up or pull-down resistor.
PUD_DOWNEnable pull-down resistor.
PUD_UPEnable pull-up resistor.

GPIO Pull-up/Pull-down Configurations:


Quad

FieldTypeDescription
pointsPoint 2dThe array of points: top left, top right, bottom left,bottom right

Quads (quadrilaterals) are shapes with 4 sides, but unlike Rectangle, these shapes can have axis that do not line up with screen/bitmap axis.

Points should be constructed with the top left as the first point, top right as the second, bottom left as the third, and bottom right as the last point. Other orders may give unexpected outcomes.


Rectangle

FieldTypeDescription
xDoubleThe distance to the left edge of the rectangle
yDoubleThe distance to the top edge of the rectangle
widthDoubleThe width of the rectangle
heightDoubleThe height of the rectangle

Rectangles are simple rectangle shapes that exist at a point and have a set width and height. This means that the rectangle always has edges that follow the sides of the Window or Bitmap (so they are aligned with the x and y axes). The rectangle’s position is its top left corner - it then extends to the right and down from this position.


Triangle

FieldTypeDescription
pointsPoint 2dThe points of the triangle

A triangle consists of three points, being the three points of the triangle.


Vector 2d

FieldTypeDescription
xDoubleThe distance to move horizontally
yDoubleThe distance to move vertically

Vectors represent a direction and distance, and can be visualised as an arrow from one point to another in 2 dimensional space. Internally, the Vector 2d is stored as its x and y components.

Vector is a great way to represent movement or forces. You could use a Vector 2d to track how much a character moves each update (as the vector stores the direction and distance). Similarly, you could use a Vector 2d to represent gravity or other forces. You can then add a number of force vectors together to get a final force to be applied to a character.