text-mode 0.0.11
Fast virtual text mode with 8x8 Unicode font.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
text-mode
The goal of the text-mode
DUB package is to be a virtual text-mode, like in older DOS machines, except with Unicode support instead of a single 8-bit code page. There is however a 16 color palette like in ancient text modes.
A secundary goal is to be efficient (everything is cached) and provide vintage looks.
0. Basic example
See examples/
to run a basic example (you will need SDL installed).
1. Setup a TM_Console
The following TM_Console
methods are necessary in order to use text-mode
:
size(int columns, int rows)
outbuf(void* p, int width, int height, int pitchBytes)
render()
Example:
TM_Console console;
void setup(MyImage image)
{
// Set number of columns and rows.
int columns = 40;
int rows = 20;
// .size clear the text buffer content and eventually resize it
console.size(columns, rows);
// set where to draw output, can be called every frame
console.outbuf(image.ptr, image.width, image.height, image.pitchBytes);
/* ...printing functions goes here... */
// display changes since the last .render, in output buffer
console.render();
}
**Key concept**: No font resampling is done. Pixels are scaled NxN depending to the room in output buffer, and letterboxed with "border" pixels.
### 2. Print some text
Example:
console.size(40, 22);
with (console)
{
cls();
print("Hello world! ");
println("Same, with line feed");
// Save state (colors, style, cursor position)
save();
// Change foreground color (0 to 15)
fg(TM_red);
print("This is red text ");
bg(TM_blue);
println("on blue background");
// Restore state. Warning: this restore cursor position!
restore();
// Set text cursor position (where text is drawn next)
locate(7, 5);
// There are 3 implemented styles:
// - bold
// - shiny (sort of bloom)
// - underline
style(TM_bold);
println("This is bold");
style(TM_shiny);
print("This is ");
fg(14);
println("shiny");
style(TM_underline);
fg(TM_lgreen);
println("This is underline");
render();
}
Result
**Key-concept**: if text must be printed in a line below the screen, the whole screen scrolls.
TO DOCUMENT
- raw char data access
- print some CCL text
- tweak options
- Registered by ponce
- 0.0.11 released 27 days ago
- p0nce/text-mode
- BSL-1.0
- Dependencies:
- intel-intrinsics
- Versions:
-
0.0.11 2024-Oct-16 0.0.10 2024-Sep-26 0.0.9 2024-Sep-24 0.0.8 2024-Sep-20 0.0.7 2024-Jul-22 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
4 downloads this month
-
24 downloads total
-
- Score:
- 0.1
- Short URL:
- text-mode.dub.pm