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

ConstantValueDescription
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

ConstantValueDescription
NORMAL_FONT0Normal font.
BOLD_FONT1Bold font.
ITALIC_FONT2Italic font.
UNDERLINE_FONT4Underlined 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

ConstantValueDescription
HTTP_STATUS_OK200The server accepted the request.
HTTP_STATUS_CREATED201The request has been fulfilled, resulting in the creation of a new resource.
HTTP_STATUS_NO_CONTENT204The server successfully processed the request and is not returning any content.
HTTP_STATUS_MOVED_PERMANENTLY301The URL of the requested resource has been changed permanently.
HTTP_STATUS_FOUND302The URI of requested resource has been changed temporarily.
HTTP_STATUS_SEE_OTHER303The server sent this response to direct the client to get the requested resource at another URI with a GET request.
HTTP_STATUS_BAD_REQUEST400The server cannot or will not process the request due to an apparent client error.
HTTP_STATUS_UNAUTHORIZED401The server requires authentication or has failed to process provided authentication.
HTTP_STATUS_FORBIDDEN403The request was a valid request, but the server is refusing to respond to it.
HTTP_STATUS_NOT_FOUND404The requested resource could not be found but may be available in the future.
HTTP_STATUS_METHOD_NOT_ALLOWED405The request method is not support for the requested resource.
HTTP_STATUS_REQUEST_TIMEOUT408The server timed out waiting for the request.
HTTP_STATUS_CONFLICT409The request conflicts with current state of the server.
HTTP_STATUS_INTERNAL_SERVER_ERROR500The server encountered an unexpected condition.
HTTP_STATUS_NOT_IMPLEMENTED501The server does not recognize or implement the request method.
HTTP_STATUS_SERVICE_UNAVAILABLE503The 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

ConstantValueDescription
FLAT_DARK_STYLE0A flat, dark-mode interface.
SHADED_DARK_STYLE1A dark-mode interface with shadows and depth.
FLAT_LIGHT_STYLE2A flat, light-mode interface.
SHADED_LIGHT_STYLE3A light-mode interface with shadows and depth.
BUBBLE4A light-mode interface with a semi-transparent bubbly look.
BUBBLE_MULTICOLORED5A 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

ConstantValueDescription
GPIO_INPUT0Input mode.
GPIO_OUTPUT1Output mode.
GPIO_ALT04Alternate function mode 0.
GPIO_ALT15Alternate function mode 1.
GPIO_ALT26Alternate function mode 2.
GPIO_ALT37Alternate function mode 3.
GPIO_ALT43Alternate function mode 4.
GPIO_ALT52Alternate function mode 5.
GPIO_DEFAULT_MODE1Default mode.

GPIO Pin Modes:


Pin Values

ConstantValueDescription
GPIO_LOW0Logic low (0).
GPIO_HIGH1Logic high (1).
GPIO_DEFAULT_VALUE1Default value.

GPIO Pin Values:


Pins

ConstantValueDescription
PIN_113.3V Power Supply
PIN_225V Power Supply
PIN_33GPIO2 / SDA (I2C)
PIN_445V Power Supply
PIN_55GPIO3 / SCL (I2C)
PIN_66Ground
PIN_77GPIO4
PIN_88GPIO14 / TXD (UART)
PIN_99Ground
PIN_1010GPIO15 / RXD (UART)
PIN_1111GPIO17
PIN_1212GPIO18 / PCM_CLK
PIN_1313GPIO27
PIN_1414Ground
PIN_1515GPIO22
PIN_1616GPIO23
PIN_17173.3V Power Supply
PIN_1818GPIO24
PIN_1919GPIO10 / MOSI (SPI)
PIN_2020Ground
PIN_2121GPIO9 / MISO (SPI)
PIN_2222GPIO25
PIN_2323GPIO11 / SCLK (SPI)
PIN_2424GPIO8 / CE0 (SPI)
PIN_2525Ground
PIN_2626GPIO7 / CE1 (SPI)
PIN_2727ID_SD (I2C ID EEPROM)
PIN_2828ID_SC (I2C ID EEPROM)
PIN_2929GPIO5
PIN_3030Ground
PIN_3131GPIO6
PIN_3232GPIO12
PIN_3333GPIO13
PIN_3434Ground
PIN_3535GPIO19 / MISO (PCM)
PIN_3636GPIO16 / CE0 (PCM)
PIN_3737GPIO26
PIN_3838GPIO20 / MOSI (PCM)
PIN_3939Ground
PIN_4040GPIO21 / 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

ConstantValueDescription
PUD_OFF0No pull-up or pull-down resistor.
PUD_DOWN1Enable pull-down resistor.
PUD_UP2Enable 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.