Skip to content
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,56 @@
using SplashKitSDK;

namespace BitmapLayerStudio
{
public class Program
{
public static void Main()
{
Window window = new Window("Bitmap Layer Studio", 960, 540);

// Scene setup: open window and load four bitmap layers.
Bitmap backgroundLayer = SplashKit.LoadBitmap("background_layer", "layer_background.png");
Bitmap midLayer = SplashKit.LoadBitmap("mid_layer", "layer_midground.png");
Bitmap propsLayer = SplashKit.LoadBitmap("props_layer", "layer_props.png");
Bitmap foregroundLayer = SplashKit.LoadBitmap("foreground_layer", "layer_foreground.png");

double alpha = 0.45;
int bgRed = 48;
int bgGreen = 88;
int bgBlue = 128;
int fgRed = 250;
int fgGreen = 216;
int fgBlue = 126;

// Formula layer: C_out = alpha * C_fg + (1 - alpha) * C_bg.
int outRed = (int)(alpha * fgRed + (1.0 - alpha) * bgRed);
int outGreen = (int)(alpha * fgGreen + (1.0 - alpha) * bgGreen);
int outBlue = (int)(alpha * fgBlue + (1.0 - alpha) * bgBlue);
Color blendGuide = SplashKit.RGBAColor(outRed, outGreen, outBlue, 255);
Color overlayGuide = SplashKit.RGBAColor(fgRed, fgGreen, fgBlue, (int)(alpha * 255));

while (!SplashKit.QuitRequested())
{
SplashKit.ProcessEvents();
SplashKit.ClearScreen();

// Layer pipeline: draw bitmaps back-to-front for stable compositing.
SplashKit.DrawBitmap(backgroundLayer, 0, 0);
SplashKit.DrawBitmap(midLayer, 0, 0);
SplashKit.DrawBitmap(propsLayer, 0, 0);
SplashKit.DrawBitmap(foregroundLayer, 0, 0);

// Visual pass: draw depth guides and decorative perspective lines.
SplashKit.DrawLine(blendGuide, 0, 370, 960, 370);
SplashKit.DrawLine(overlayGuide, 480, 120, 180, 520);
SplashKit.DrawLine(overlayGuide, 480, 120, 780, 520);
SplashKit.DrawLine(blendGuide, 120, 500, 840, 500);

SplashKit.RefreshScreen(60);
}

SplashKit.FreeAllBitmaps();
window.Close();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

OpenWindow("Bitmap Layer Studio", 960, 540);

// Scene setup: open window and load four bitmap layers.
Bitmap backgroundLayer = LoadBitmap("background_layer", "layer_background.png");
Bitmap midLayer = LoadBitmap("mid_layer", "layer_midground.png");
Bitmap propsLayer = LoadBitmap("props_layer", "layer_props.png");
Bitmap foregroundLayer = LoadBitmap("foreground_layer", "layer_foreground.png");

double alpha = 0.45;
int bgRed = 48;
int bgGreen = 88;
int bgBlue = 128;
int fgRed = 250;
int fgGreen = 216;
int fgBlue = 126;

// Formula layer: C_out = alpha * C_fg + (1 - alpha) * C_bg.
int outRed = (int)(alpha * fgRed + (1.0 - alpha) * bgRed);
int outGreen = (int)(alpha * fgGreen + (1.0 - alpha) * bgGreen);
int outBlue = (int)(alpha * fgBlue + (1.0 - alpha) * bgBlue);
Color blendGuide = RGBAColor(outRed, outGreen, outBlue, 255);
Color overlayGuide = RGBAColor(fgRed, fgGreen, fgBlue, (int)(alpha * 255));

while (!QuitRequested())
{
ProcessEvents();
ClearScreen();

// Layer pipeline: draw bitmaps back-to-front for stable compositing.
DrawBitmap(backgroundLayer, 0, 0);
DrawBitmap(midLayer, 0, 0);
DrawBitmap(propsLayer, 0, 0);
DrawBitmap(foregroundLayer, 0, 0);

// Visual pass: draw depth guides and decorative perspective lines.
DrawLine(blendGuide, 0, 370, 960, 370);
DrawLine(overlayGuide, 480, 120, 180, 520);
DrawLine(overlayGuide, 480, 120, 780, 520);
DrawLine(blendGuide, 120, 500, 840, 500);

RefreshScreen(60);
}

FreeAllBitmaps();
CloseAllWindows();
52 changes: 52 additions & 0 deletions public/usage-examples/graphics/bitmap_layer_studio-1-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "splashkit.h"

int main()
{
open_window("Bitmap Layer Studio", 960, 540);

// Scene setup: open window and load four bitmap layers.
bitmap background_layer = load_bitmap("background_layer", "layer_background.png");
bitmap mid_layer = load_bitmap("mid_layer", "layer_midground.png");
bitmap props_layer = load_bitmap("props_layer", "layer_props.png");
bitmap foreground_layer = load_bitmap("foreground_layer", "layer_foreground.png");

const double alpha = 0.45;
const int bg_red = 48;
const int bg_green = 88;
const int bg_blue = 128;
const int fg_red = 250;
const int fg_green = 216;
const int fg_blue = 126;

// Formula layer: C_out = alpha * C_fg + (1 - alpha) * C_bg.
int out_red = static_cast<int>(alpha * fg_red + (1.0 - alpha) * bg_red);
int out_green = static_cast<int>(alpha * fg_green + (1.0 - alpha) * bg_green);
int out_blue = static_cast<int>(alpha * fg_blue + (1.0 - alpha) * bg_blue);
color blend_guide = rgba_color(out_red, out_green, out_blue, 255);
color overlay_guide = rgba_color(fg_red, fg_green, fg_blue, static_cast<int>(alpha * 255));

while (!quit_requested())
{
process_events();
clear_screen();

// Layer pipeline: draw bitmaps back-to-front for stable compositing.
draw_bitmap(background_layer, 0, 0);
draw_bitmap(mid_layer, 0, 0);
draw_bitmap(props_layer, 0, 0);
draw_bitmap(foreground_layer, 0, 0);

// Visual pass: draw depth guides and decorative perspective lines.
draw_line(blend_guide, 0, 370, 960, 370);
draw_line(overlay_guide, 480, 120, 180, 520);
draw_line(overlay_guide, 480, 120, 780, 520);
draw_line(blend_guide, 120, 500, 840, 500);

refresh_screen(60);
}

free_all_bitmaps();
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.
45 changes: 45 additions & 0 deletions public/usage-examples/graphics/bitmap_layer_studio-1-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from splashkit import *

open_window("Bitmap Layer Studio", 960, 540)

# Scene setup: open window and load four bitmap layers.
background_layer = load_bitmap("background_layer", "layer_background.png")
mid_layer = load_bitmap("mid_layer", "layer_midground.png")
props_layer = load_bitmap("props_layer", "layer_props.png")
foreground_layer = load_bitmap("foreground_layer", "layer_foreground.png")

alpha = 0.45
bg_red = 48
bg_green = 88
bg_blue = 128
fg_red = 250
fg_green = 216
fg_blue = 126

# Formula layer: C_out = alpha * C_fg + (1 - alpha) * C_bg.
out_red = int(alpha * fg_red + (1.0 - alpha) * bg_red)
out_green = int(alpha * fg_green + (1.0 - alpha) * bg_green)
out_blue = int(alpha * fg_blue + (1.0 - alpha) * bg_blue)
blend_guide = rgba_color(out_red, out_green, out_blue, 255)
overlay_guide = rgba_color(fg_red, fg_green, fg_blue, int(alpha * 255))

while not quit_requested():
process_events()
clear_screen()

# Layer pipeline: draw bitmaps back-to-front for stable compositing.
draw_bitmap(background_layer, 0, 0)
draw_bitmap(mid_layer, 0, 0)
draw_bitmap(props_layer, 0, 0)
draw_bitmap(foreground_layer, 0, 0)

# Visual pass: draw depth guides and decorative perspective lines.
draw_line(blend_guide, 0, 370, 960, 370)
draw_line(overlay_guide, 480, 120, 180, 520)
draw_line(overlay_guide, 480, 120, 780, 520)
draw_line(blend_guide, 120, 500, 840, 500)

refresh_screen(60)

free_all_bitmaps()
close_all_windows()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Parallax Alley at Dusk
Layer four bitmap planes, blend overlay guides, and tune the scene depth pass.
4 changes: 2 additions & 2 deletions scripts/json-files/guides-groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"animations",
"audio",
"beyond-splashkit",
"camera",
"Camera",
"color",
"graphics",
"Graphics",
"input",
"interface",
"json",
Expand Down
Loading