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
Field | Type | Description |
---|---|---|
center | Point 2d | The center point of the circle |
radius | Double | The 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
Field | Type | Description |
---|---|---|
r | Float | The red component of the color (between 0 and 1.0) |
g | Float | The green component of the color (between 0 and 1.0) |
b | Float | The blue component of the color (between 0 and 1.0) |
a | Float | The 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
Constant | Value | Description |
---|---|---|
DRAW_TO_SCREEN | means camera has no affect. | |
DRAW_TO_WORLD | means camera has an affect. | |
DRAW_DEFAULT | means camera has an affect only if drawn to awindow. |
Determines the effect of the camera on a drawing operation.
Drawing Options
Field | Type | Description |
---|---|---|
dest | Void | The destination of the drawing: a window or bitmap. |
scale_x | Float | How much x values are scaled. |
scale_y | Float | How much y values are scaled. |
angle | Float | A rotation angle for bitmap drawing. |
anchor_offset_x | Float | The x location of the anchor point around whichbitmap drawing will rotate. |
anchor_offset_y | Float | The y location of the anchor point around whichbitmap drawing will rotate. |
flip_x | Boolean | Should bitmaps be flipped horizontally |
flip_y | Boolean | Should bitmaps be flipped vertically |
is_part | Boolean | Indicates that part of a bitmap should be drawn |
part | Rectangle | The area of the bitmap to draw |
draw_cell | Integer | Which cell of a bitmap to draw, or -1 for all. Overridesparts and animation settings. |
camera | Drawing Dest | How the current window camera affects the drawing |
line_width | Integer | How wide are lines (only lines at this stage) |
anim | Animation | The 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
Constant | Value | Description |
---|---|---|
NORMAL_FONT | 0 | Normal font. |
BOLD_FONT | 1 | Bold font. |
ITALIC_FONT | 2 | Italic font. |
UNDERLINE_FONT | 4 | Underlined 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
Constant | Value | Description |
---|---|---|
HTTP_STATUS_OK | 200 | The server accepted the request. |
HTTP_STATUS_CREATED | 201 | The request has been fulfilled, resulting in the creation of a new resource. |
HTTP_STATUS_NO_CONTENT | 204 | The server successfully processed the request and is not returning any content. |
HTTP_STATUS_MOVED_PERMANENTLY | 301 | The URL of the requested resource has been changed permanently. |
HTTP_STATUS_FOUND | 302 | The URI of requested resource has been changed temporarily. |
HTTP_STATUS_SEE_OTHER | 303 | The server sent this response to direct the client to get the requested resource at another URI with a GET request. |
HTTP_STATUS_BAD_REQUEST | 400 | The server cannot or will not process the request due to an apparent client error. |
HTTP_STATUS_UNAUTHORIZED | 401 | The server requires authentication or has failed to process provided authentication. |
HTTP_STATUS_FORBIDDEN | 403 | The request was a valid request, but the server is refusing to respond to it. |
HTTP_STATUS_NOT_FOUND | 404 | The requested resource could not be found but may be available in the future. |
HTTP_STATUS_METHOD_NOT_ALLOWED | 405 | The request method is not support for the requested resource. |
HTTP_STATUS_REQUEST_TIMEOUT | 408 | The server timed out waiting for the request. |
HTTP_STATUS_CONFLICT | 409 | The request conflicts with current state of the server. |
HTTP_STATUS_INTERNAL_SERVER_ERROR | 500 | The server encountered an unexpected condition. |
HTTP_STATUS_NOT_IMPLEMENTED | 501 | The server does not recognize or implement the request method. |
HTTP_STATUS_SERVICE_UNAVAILABLE | 503 | The 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
Constant | Value | Description |
---|---|---|
FLAT_DARK_STYLE | 0 | A flat, dark-mode interface. |
SHADED_DARK_STYLE | 1 | A dark-mode interface with shadows and depth. |
FLAT_LIGHT_STYLE | 2 | A flat, light-mode interface. |
SHADED_LIGHT_STYLE | 3 | A light-mode interface with shadows and depth. |
BUBBLE | 4 | A light-mode interface with a semi-transparent bubbly look. |
BUBBLE_MULTICOLORED | 5 | A 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
Field | Type | Description |
---|---|---|
start_point | Point 2d | The start of the line |
end_point | Point 2d | The end of the line |
A line goes from a start point to an end point.
Pin Modes
Constant | Value | Description |
---|---|---|
GPIO_INPUT | 0 | Input mode. |
GPIO_OUTPUT | 1 | Output mode. |
GPIO_ALT0 | 4 | Alternate function mode 0. |
GPIO_ALT1 | 5 | Alternate function mode 1. |
GPIO_ALT2 | 6 | Alternate function mode 2. |
GPIO_ALT3 | 7 | Alternate function mode 3. |
GPIO_ALT4 | 3 | Alternate function mode 4. |
GPIO_ALT5 | 2 | Alternate function mode 5. |
GPIO_DEFAULT_MODE | 1 | Default mode. |
GPIO Pin Modes:
Pin Values
Constant | Value | Description |
---|---|---|
GPIO_LOW | 0 | Logic low (0). |
GPIO_HIGH | 1 | Logic high (1). |
GPIO_DEFAULT_VALUE | 1 | Default value. |
GPIO Pin Values:
Pins
Constant | Value | Description |
---|---|---|
PIN_1 | 1 | 3.3V Power Supply |
PIN_2 | 2 | 5V Power Supply |
PIN_3 | 3 | GPIO2 / SDA (I2C) |
PIN_4 | 4 | 5V Power Supply |
PIN_5 | 5 | GPIO3 / SCL (I2C) |
PIN_6 | 6 | Ground |
PIN_7 | 7 | GPIO4 |
PIN_8 | 8 | GPIO14 / TXD (UART) |
PIN_9 | 9 | Ground |
PIN_10 | 10 | GPIO15 / RXD (UART) |
PIN_11 | 11 | GPIO17 |
PIN_12 | 12 | GPIO18 / PCM_CLK |
PIN_13 | 13 | GPIO27 |
PIN_14 | 14 | Ground |
PIN_15 | 15 | GPIO22 |
PIN_16 | 16 | GPIO23 |
PIN_17 | 17 | 3.3V Power Supply |
PIN_18 | 18 | GPIO24 |
PIN_19 | 19 | GPIO10 / MOSI (SPI) |
PIN_20 | 20 | Ground |
PIN_21 | 21 | GPIO9 / MISO (SPI) |
PIN_22 | 22 | GPIO25 |
PIN_23 | 23 | GPIO11 / SCLK (SPI) |
PIN_24 | 24 | GPIO8 / CE0 (SPI) |
PIN_25 | 25 | Ground |
PIN_26 | 26 | GPIO7 / CE1 (SPI) |
PIN_27 | 27 | ID_SD (I2C ID EEPROM) |
PIN_28 | 28 | ID_SC (I2C ID EEPROM) |
PIN_29 | 29 | GPIO5 |
PIN_30 | 30 | Ground |
PIN_31 | 31 | GPIO6 |
PIN_32 | 32 | GPIO12 |
PIN_33 | 33 | GPIO13 |
PIN_34 | 34 | Ground |
PIN_35 | 35 | GPIO19 / MISO (PCM) |
PIN_36 | 36 | GPIO16 / CE0 (PCM) |
PIN_37 | 37 | GPIO26 |
PIN_38 | 38 | GPIO20 / MOSI (PCM) |
PIN_39 | 39 | Ground |
PIN_40 | 40 | GPIO21 / SCLK (PCM) |
Raspberry Pi GPIO Board Pin Descriptions:
Point 2d
Field | Type | Description |
---|---|---|
x | Double | The distance from the left side of the bitmap or window (increasing as you go to the right) |
y | Double | The 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
Constant | Value | Description |
---|---|---|
PUD_OFF | 0 | No pull-up or pull-down resistor. |
PUD_DOWN | 1 | Enable pull-down resistor. |
PUD_UP | 2 | Enable pull-up resistor. |
GPIO Pull-up/Pull-down Configurations:
Quad
Field | Type | Description |
---|---|---|
points | Point 2d | The 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
Field | Type | Description |
---|---|---|
x | Double | The distance to the left edge of the rectangle |
y | Double | The distance to the top edge of the rectangle |
width | Double | The width of the rectangle |
height | Double | The 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
Field | Type | Description |
---|---|---|
points | Point 2d | The points of the triangle |
A triangle consists of three points, being the three points of the triangle.
Vector 2d
Field | Type | Description |
---|---|---|
x | Double | The distance to move horizontally |
y | Double | The 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.