Files
prosperon/tests/surface.ce
2026-01-21 09:05:02 -06:00

37 lines
1.1 KiB
Plaintext

// Test SDL_Surface module
var Surface = use('sdl3/surface');
// Test creating a surface
var surf = Surface({width: 100, height: 100});
log.console("Created surface:", surf.width, "x", surf.height);
log.console(surf)
// Test fill
surf.fill([1, 0, 0, 1]); // Red
// Test dup
var surf2 = surf.dup();
log.console("Duplicated surface:", surf2.width, "x", surf2.height);
// Test scale
var surf3 = surf.scale([50, 50], "linear");
log.console("Scaled surface:", surf3.width, "x", surf3.height);
// Test format
log.console("Surface format:", surf.format);
// Test pixels
var pixels = surf.pixels();
log.console("Got pixels array buffer, length:", pixels.byteLength);
// Test creating surface with custom format
var surf4 = Surface({width: 64, height: 64, format: "rgb24"});
log.console("Created RGB24 surface:", surf4.width, "x", surf4.height, "format:", surf4.format);
// Test creating surface from pixels
var pixelData = ArrayBuffer(32 * 32 * 4); // 32x32 RGBA
var surf5 = Surface({width: 32, height: 32, pixels: pixelData});
log.console("Created surface from pixels:", surf5.width, "x", surf5.height);
log.console("Surface module test passed!");