Simple Usage Examples
Basic Blue Circle
The following code shows examples of using Fill Circle to show how to draw a filled-in blue circle.
open_window ( " Fill Circle " , 800 , 600 );
fill_circle (COLOR_BLUE, 300 , 300 , 200 );
using static SplashKitSDK . SplashKit;
OpenWindow ( " Fill Circle " , 800 , 600 );
FillCircle ( ColorBlue (), 300 , 300 , 200 );
Output :
Basic Blue Ellipse
The following code shows examples of using Fill Ellipse to show how to draw a filled-in blue ellipse.
open_window ( " Fill Ellipse " , 800 , 600 );
fill_ellipse (COLOR_BLUE, 200 , 200 , 400 , 200 );
// Added rectangle with same arguments as above for x, y, width and height
draw_rectangle (COLOR_RED, 200 , 200 , 400 , 200 );
using static SplashKitSDK . SplashKit;
OpenWindow ( " Fill Ellipse " , 800 , 600 );
FillEllipse ( ColorBlue (), 200 , 200 , 400 , 200 );
// Added rectangle with same arguments as above for x, y, width and height
DrawRectangle ( ColorRed (), 200 , 200 , 400 , 200 );
Output :
Background Color
The following code shows an example of using Clear Screen to change the background color to blue.
open_window ( " Blue Background " , 800 , 600 );
clear_screen (COLOR_BLUE);
using static SplashKitSDK . SplashKit;
OpenWindow ( " Blue Background " , 800 , 600 );
ClearScreen ( ColorBlue ());
Output :
House Drawing
The following code shows examples of using Refresh Screen to show how double buffering works.
open_window ( " House Drawing " , 800 , 600 );
clear_screen (COLOR_WHITE);
fill_ellipse (COLOR_BRIGHT_GREEN, 0 , 400 , 800 , 400 );
fill_rectangle (COLOR_GRAY, 300 , 300 , 200 , 200 );
fill_triangle (COLOR_RED, 250 , 300 , 400 , 150 , 550 , 300 );
using static SplashKitSDK . SplashKit;
OpenWindow ( " House Drawing " , 800 , 600 );
ClearScreen ( ColorWhite ());
FillEllipse ( ColorBrightGreen (), 0 , 400 , 800 , 400 );
FillRectangle ( ColorGray (), 300 , 300 , 200 , 200 );
FillTriangle ( ColorRed (), 250 , 300 , 400 , 150 , 550 , 300 );
public static void Main ()
SplashKit . OpenWindow ( " House Drawing " , 800 , 600 );
SplashKit . ClearScreen ( Color . White );
SplashKit . RefreshScreen ();
SplashKit . FillEllipse ( Color . BrightGreen , 0 , 400 , 800 , 400 );
SplashKit . RefreshScreen ();
SplashKit . FillRectangle ( Color . Gray , 300 , 300 , 200 , 200 );
SplashKit . RefreshScreen ();
SplashKit . FillTriangle ( Color . Red , 250 , 300 , 400 , 150 , 550 , 300 );
SplashKit . RefreshScreen ();
SplashKit . CloseAllWindows ();
open_window ( " House Drawing " , 800 , 600 )
clear_screen ( color_white ())
fill_ellipse ( color_bright_green () , 0 , 400 , 800 , 400 )
fill_rectangle ( color_gray () , 300 , 300 , 200 , 200 )
fill_triangle ( color_red () , 250 , 300 , 400 , 150 , 550 , 300 )
Output :
Basic Bitmap Drawing
The following code shows an example of using Draw Bitmap to display a Bitmap image of the SplashKit logo in a graphics Window.
open_window ( " Basic Bitmap Drawing " , 315 , 330 );
load_bitmap ( " skbox " , " skbox.png " ); // Load bitmap image
while ( ! quit_requested ())
clear_screen ( rgb_color ( 67 , 80 , 175 ));
draw_bitmap ( " skbox " , 50 , 50 ); // draw bitmap image
using static SplashKitSDK . SplashKit;
OpenWindow ( " Basic Bitmap Drawing " , 315 , 330 );
LoadBitmap ( " skbox " , " skbox.png " ); // Load bitmap image
ClearScreen ( RGBColor ( 67 , 80 , 175 ));
DrawBitmap ( " skbox " , 50 , 50 ); // draw bitmap image
namespace DrawBitmapNamed
public static void Main ()
Window window = new Window( " Basic Bitmap Drawing " , 315 , 330 );
SplashKit . LoadBitmap ( " skbox " , " skbox.png " ); // Load bitmap image
while ( ! window . CloseRequested )
SplashKit . ProcessEvents ();
SplashKit . ClearScreen ( Color . RGBColor ( 67 , 80 , 175 ));
SplashKit . DrawBitmap ( " skbox " , 50 , 50 ); // draw bitmap image
SplashKit . RefreshScreen ();
SplashKit . CloseAllWindows ();
open_window ( " Basic Bitmap Drawing " , 315 , 330 )
load_bitmap ( " skbox " , " skbox.png " ) # Load bitmap image
while ( not quit_requested ()):
clear_screen ( rgb_color ( 67 , 80 , 175 ))
draw_bitmap_named ( " skbox " , 50 , 50 ); # draw bitmap image
Output :
Basic Blue Rectangle
The following code shows examples of using Fill Rectangle to show how to draw a filled-in blue rectangle.
open_window ( " Fill rectangle " , 800 , 600 );
fill_rectangle (COLOR_BLUE, 200 , 200 , 200 , 100 );
using static SplashKitSDK . SplashKit;
OpenWindow ( " Fill rectangle " , 800 , 600 );
FillRectangle ( ColorBlue (), 200 , 200 , 200 , 100 );
Output :
Basic Red Triangle
The following code demonstrates how to use the Fill Triangle function to draw a simple red-colored filled triangle. It creates a triangle with specified coordinates and fills it with red color.
open_window ( " Fill triangle Example " , 800 , 600 );
fill_triangle (COLOR_RED, 100 , 100 , 200 , 200 , 300 , 100 );
using static SplashKitSDK . SplashKit;
OpenWindow ( " Fill Triangle Example " , 800 , 600 );
FillTriangle ( ColorRed (), 100 , 100 , 200 , 200 , 300 , 100 );
Output :
Hooray! A Red Hat
The following code shows an example of using the Fill Triangle On Bitmap function to draw a red triangle on a loaded bitmap.
open_window ( " Happy Hat " , 618 , 618 );
// Load the bitmaps for sad and smiling emojis (https://openmoji.org/library/#group=smileys-emotion)
bitmap sad_emoji = load_bitmap ( " sad_emoji " , " sad_emoji.png " );
bitmap smiling_emoji = load_bitmap ( " smiling_emoji " , " smiling_emoji.png " );
// Draw the sad emoji and add a hat
clear_screen (COLOR_BLACK);
draw_bitmap (sad_emoji, 0 , 0 );
// Draw a triangle hat on the smiling emoji
fill_triangle_on_bitmap (smiling_emoji, COLOR_RED, 100 , 200 , 309 , 20 , 520 , 200 );
// Clear screen and switch to the smiling emoji
clear_screen (COLOR_BLACK);
draw_bitmap (smiling_emoji, 0 , 0 );
// Spin the smiling emoji with the hat
for ( int i = 0 ; i < 360 ; i ++ )
clear_screen (COLOR_BLACK);
draw_bitmap (smiling_emoji, 0 , 0 , option_rotate_bmp (i));
// Free the bitmap resource
using static SplashKitSDK . SplashKit;
OpenWindow ( " Happy Hat " , 618 , 618 );
// Load the bitmaps for sad and smiling emojis
Bitmap sadEmoji = LoadBitmap ( " sad_emoji " , " sad_emoji.png " );
Bitmap smilingEmoji = LoadBitmap ( " smiling_emoji " , " smiling_emoji.png " );
// Draw the sad emoji and add a hat
ClearScreen ( ColorBlack ());
DrawBitmap (sadEmoji, 0 , 0 );
// Draw a triangle hat on the smiling emoji
FillTriangleOnBitmap (smilingEmoji, ColorRed (), 100 , 200 , 309 , 20 , 520 , 200 );
// Clear screen and switch to the smiling emoji
ClearScreen ( ColorBlack ());
DrawBitmap (smilingEmoji, 0 , 0 );
// Spin the smiling emoji with the hat
for ( int i = 0 ; i < 360 ; i ++ )
ClearScreen ( ColorBlack ());
DrawBitmap (smilingEmoji, 0 , 0 , OptionRotateBmp (i));
// Free the bitmap resource
Output :