Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5 Usage Example for Graphics P1 #340

Open
wants to merge 1 commit into
base: usage-examples
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using SplashKitSDK;

public class Program
{
public static void Main()
{
// Open a new window with the title "Free All Front" and dimensions 800x600
SplashKit.OpenWindow("Free All Front", 800, 600);

// Load the "Arial" font from the file "arial.ttf"
SplashKit.LoadFont("Arial", "arial.ttf");

// Draw text using the "Arial" font with the color black at position (100, 100)
SplashKit.DrawText("Old Theme", Color.Black, "Arial", 24, 100, 100);

// Refresh the screen to display the text
SplashKit.RefreshScreen();

// Pause for 2000 milliseconds (2 seconds) to allow the text to be visible
SplashKit.Delay(2000);

// Free all loaded fonts to reset the theme
SplashKit.FreeAllFonts();

// Clear the screen to prepare for the new theme
SplashKit.ClearScreen();

// Load the "Verdana" font from the file "verdana.ttf"
SplashKit.LoadFont("Verdana", "verdana.ttf");

// Draw text using the "Verdana" font with the color blue at position (100, 100)
SplashKit.DrawText("New Theme", Color.Blue, "Verdana", 24, 100, 100);

// Refresh the screen to display the updated text
SplashKit.RefreshScreen();

// Pause for 3000 milliseconds (3 seconds) to allow the updated text to be visible
SplashKit.Delay(3000);

// Close all open windows
SplashKit.CloseAllWindows();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

// Open a new window with the title "Free All Front" and dimensions 800x600
OpenWindow("Free All Front", 800, 600);

// Load the "Arial" font from the file "arial.ttf"
LoadFont("Arial", "arial.ttf");

// Draw text using the "Arial" font with the color black at position (100, 100)
DrawText("Old Theme", Color.Black, "Arial", 24, 100, 100);

// Refresh the screen to display the text
RefreshScreen();

// Pause for 2000 milliseconds (2 seconds) to allow the text to be visible
Delay(2000);

// Free all loaded fonts to reset the theme
FreeAllFonts();

// Clear the screen to prepare for the new theme
ClearScreen();

// Load the "Verdana" font from the file "verdana.ttf"
LoadFont("Verdana", "verdana.ttf");

// Draw text using the "Verdana" font with the color blue at position (100, 100)
DrawText("New Theme", Color.Blue, "Verdana", 24, 100, 100);

// Refresh the screen to display the updated text
RefreshScreen();

// Pause for 3000 milliseconds (3 seconds) to allow the updated text to be visible
Delay(3000);

// Close all open windows
CloseAllWindows();
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "splashkit.h"

int main()
{
// Open a window with the title "Free All Front" and dimensions 800x600
open_window("Free All Front", 800, 600);

// Load the "Arial" font from the file "arial.ttf"
load_font("Arial", "arial.ttf");

// Draw text "Old Theme" in black color using the "Arial" font at position (100, 100)
draw_text("Old Theme", COLOR_BLACK, "Arial", 24, 100, 100);

// Refresh the screen to display the text
refresh_screen();

// Pause for 2000 milliseconds (2 seconds) to display the old theme
delay(2000);

// Free all fonts to reset the theme
void free_all_fonts();

// Clear the screen to prepare for the new theme
clear_screen();

// Load the "Verdana" font from the file "verdana.ttf"
load_font("Verdana", "verdana.ttf");

// Draw text "New Theme" in blue color using the "Verdana" font at position (100, 100)
draw_text("New Theme", COLOR_BLUE, "Verdana", 24, 100, 100);

// Refresh the screen to display the updated text
refresh_screen();

// Pause for 3000 milliseconds (3 seconds) to display the new theme
delay(3000);

return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from splashkit import *

# Open a window with the title "Free All Front" and dimensions 800x600
open_window("Free All Front", 800, 600)

# Load the "Arial" font from the file "arial.ttf"
font1 = load_font("Arial", "arial.ttf")

# Draw text using the "Arial" font with black color at position (100, 100)
draw_text("Old Theme", color_black(), font1, 24, 100, 100)

# Refresh the screen to display the text
refresh_screen()

# Pause for 2000 milliseconds (2 seconds) to display the old theme
delay(2000)

# Free all loaded fonts to reset the theme
free_all_fonts()

# Clear the screen and fill it with white color to prepare for the new theme
clear_screen(color_white())

# Load the "Verdana" font from the file "verdana.ttf"
font2 = load_font("Verdana", "verdana.ttf")

# Draw text using the "Verdana" font with blue color at position (100, 100)
draw_text("New Theme", color_blue(), font2, 24, 100, 100)

# Refresh the screen to display the updated text
refresh_screen()

# Pause for 3000 milliseconds (3 seconds) to display the new theme
delay(3000)

# Close all open windows
close_all_windows()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### FREE ALL FONTS

The following code shows an examples of using [Free all fonts](/api/graphics#free-all-fonts) to reset a program's theme by freeing all fonts and reloading a new font set.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using SplashKitSDK;

public class Program
{
public static void Main()
{
// Open a new window with the title "OptionFlipX" and dimensions 800x600
Window window = SplashKit.OpenWindow("Option Flip X ", 800, 600);

// Load a bitmap image named "Player" from the file "character.png"
Bitmap bmp = SplashKit.LoadBitmap("Player", "character.png");

// Draw the original bitmap image at position (100, 100) in the window
SplashKit.DrawBitmap(bmp, 100, 100);

// Draw the bitmap image flipped horizontally at position (300, 100)
SplashKit.DrawBitmap(bmp, 300, 100, SplashKit.OptionFlipX());

// Refresh the screen to display the drawings
SplashKit.RefreshScreen();

// Pause the program for 5000 milliseconds (5 seconds) to keep the window open
SplashKit.Delay(5000);

// Close all open windows
SplashKit.CloseAllWindows();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

// Open a new window with the title "OptionFlipX" and dimensions 800x600
Window window = OpenWindow("Option Flip X ", 800, 600);

// Load a bitmap image named "Player" from the file "character.png"
Bitmap bmp = LoadBitmap("Player", "character.png");

// Draw the original bitmap image at position (100, 100) in the window
DrawBitmap(bmp, 100, 100);

// Draw the bitmap image flipped horizontally at position (300, 100)
DrawBitmap(bmp, 300, 100, OptionFlipX());

// Refresh the screen to display the drawings
RefreshScreen();

// Pause the program for 5000 milliseconds (5 seconds) to keep the window open
Delay(5000);

// Close all open windows
CloseAllWindows();

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "splashkit.h"

int main()
{
// Open a window with the title "Option Flip X" and dimensions 800x600
open_window("Option Flip X", 800, 600);

// Load a bitmap image named "Player" from the file "character.png"
bitmap bmp = load_bitmap("Player", "character.png");

// Draw the original bitmap image at position (100, 100)
draw_bitmap(bmp, 100, 100);

// Draw the bitmap image flipped both horizontally and vertically at position (300, 100)
draw_bitmap(bmp, 300, 100, option_flip_x());

// Refresh the screen to display the drawings
refresh_screen();

// Wait for 5 seconds before closing the window
delay(5000);

// Close all open windows
close_all_windows();

return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from splashkit import *

# Open a new window with the title "Option Flip X" and dimensions 800x600
window = open_window("Option Flip X", 800, 600)

# Load a bitmap image named "Player" from the file "character.png"
bmp = load_bitmap("Player", "character.png")

# Draw the original bitmap image at position (100, 100) in the window
draw_bitmap(bmp, 100, 100)

# Draw the bitmap image flipped vertically at position (300, 100) in the specified window
draw_bitmap_on_window_with_options(window, bmp, 300, 100, option_flip_xy())

# Refresh the screen to display the drawings
refresh_screen()

# Pause the program for 5000 milliseconds (5 seconds) to keep the window open
delay(5000)

# Close all open windows
close_all_windows()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Option Flip X

The following code shows an examples of using [Option Flip X](/api/graphics#option-flip-x) to flipped version of a bitmap (e.g., a character image) along the X-axis, creating a mirror image effect next to the original.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using SplashKitSDK;

public class Program
{
public static void Main()
{
// Open a new window with the title "OptionFlipXY" and dimensions 800x600
Window window = SplashKit.OpenWindow("Option Flip XY ", 800, 600);

// Load a bitmap image named "House" from the file "house.png"
Bitmap bmp = SplashKit.LoadBitmap("House", "house.png");

// Draw the original bitmap image at position (100, 100) in the window
SplashKit.DrawBitmap(bmp, 100, 100);

// Draw the bitmap image flipped horizontally at position (300, 100)
SplashKit.DrawBitmap(bmp, 300, 100, SplashKit.OptionFlipXy());

// Refresh the screen to display the drawings
SplashKit.RefreshScreen();

// Pause the program for 5000 milliseconds (5 seconds) to keep the window open
SplashKit.Delay(5000);

// Close all open windows
SplashKit.CloseAllWindows();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

// Open a new window with the title "OptionFlipXY" and dimensions 800x600
Window window = OpenWindow("Option Flip XY ", 800, 600);

// Load a bitmap image named "House" from the file "house.png"
Bitmap bmp = LoadBitmap("House", "house.png");

// Draw the original bitmap image at position (100, 100) in the window
DrawBitmap(bmp, 100, 100);

// Draw the bitmap image flipped horizontally at position (300, 100)
DrawBitmap(bmp, 300, 100, OptionFlipXy());

// Refresh the screen to display the drawings
RefreshScreen();

// Pause the program for 5000 milliseconds (5 seconds) to keep the window open
Delay(5000);

// Close all open windows
CloseAllWindows();

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "splashkit.h"

int main()
{
// Open a window with the title "Option Flip XY" and dimensions 800x600
open_window("Option Flip X", 800, 600);

// Load a bitmap image named "House" from the file "house.png"
bitmap bmp = load_bitmap("House", "house.png");

// Draw the original bitmap image at position (100, 100)
draw_bitmap(bmp, 100, 100);

// Draw the bitmap image flipped both horizontally and vertically at position (300, 100)
draw_bitmap(bmp, 300, 100, option_flip_xy());

// Refresh the screen to display the drawings
refresh_screen();

// Wait for 5 seconds before closing the window
delay(5000);

// Close all open windows
close_all_windows();

return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from splashkit import *

# Open a new window with the title "Option Flip XY" and dimensions 800x600
window = open_window("Option Flip XY", 800, 600)

# Load a bitmap image named "House" from the file "house.png"
bmp = load_bitmap("House", "house.png")

# Draw the original bitmap image at position (100, 100) in the window
draw_bitmap(bmp, 100, 100)

# Draw the bitmap image flipped vertically at position (300, 100) in the specified window
draw_bitmap_on_window_with_options(window, bmp, 300, 100, option_flip_xy())

# Refresh the screen to display the drawings
refresh_screen()

# Pause the program for 5000 milliseconds (5 seconds) to keep the window open
delay(5000)

# Close all open windows
close_all_windows()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#### Option Flip XY

The following code shows an examples of using [Option Flip XY](/api/graphics#option-flip-xy) to draw a bitmap (e.g., a house image) with both X and Y flipped, creating an upside-down mirror version next to the original.

Binary file not shown.
Loading