31
31
#include < gf/Window.h>
32
32
33
33
int main () {
34
+ static constexpr float Scale = 2 .0f ;
34
35
static constexpr gf::Vector2i CharacterSize (12 , 12 );
35
36
static constexpr gf::Vector2i ConsoleSize (80 , 50 );
36
37
37
- const gf::Vector2i ScreenSize = CharacterSize * ConsoleSize;
38
+ const gf::Vector2i ScreenSize = CharacterSize * ConsoleSize * Scale ;
38
39
39
40
gf::Window window (" 27_console" , ScreenSize, ~gf::WindowHints::Resizable);
40
41
gf::RenderWindow renderer (window);
@@ -48,27 +49,35 @@ int main() {
48
49
gf::BitmapConsoleFont font (" assets/terminal.png" , { gf::ConsoleFontFormat::Grayscale, gf::ConsoleFontFormat::InRow, gf::ConsoleFontFormat::ModifiedCodePage437 });
49
50
assert (CharacterSize == font.getCharacterSize ());
50
51
52
+ gf::ConsoleStyle style;
53
+ style.background = gf::Color::Gray (0 .25f );
54
+
51
55
gf::Console console (font, ConsoleSize);
52
- console.setDefaultBackground (gf::Color::Gray (0 .25f ));
53
56
54
- console.putChar ({ 40 , 25 }, ' @' );
55
- console.putChar ({ 42 , 25 }, gf::ConsoleChar::WhiteSmilingFace);
57
+ console.putChar ({ 40 , 25 }, ' @' , style );
58
+ console.putChar ({ 42 , 25 }, gf::ConsoleChar::WhiteSmilingFace, style );
56
59
57
60
console.setColorControl (gf::ConsoleColorControl1, gf::Color::Red, gf::Color::Black);
58
- console.print ({ 1 , 1 }, " String with a %cred%c word." , gf::ConsoleColorControl1, gf::ConsoleColorControlStop);
61
+ console.print ({ 1 , 1 }, style, " String with a %cred%c word." , gf::ConsoleColorControl1, gf::ConsoleColorControlStop);
59
62
63
+ style.alignment = gf::ConsoleAlignment::Right;
60
64
console.setColorControl (gf::ConsoleColorControl2, gf::Color::Orange, gf::Color::Azure);
61
- console.print (ConsoleSize - 2 , gf::ConsoleEffect::Set, gf::ConsoleAlignment::Right , " Made with %cgf%c!" , gf::ConsoleColorControl2, gf::ConsoleColorControlStop);
65
+ console.print (ConsoleSize - 2 , style , " Made with %cgf%c!" , gf::ConsoleColorControl2, gf::ConsoleColorControlStop);
62
66
63
67
console.setColorControl (gf::ConsoleColorControl3, gf::Color::Black, gf::Color::Yellow);
64
68
const char *text = " This is a simple but long text with %cmultiple%c lines." ;
65
69
66
- console.printRect (gf::RectI::fromPositionSize ({ 2 , 5 }, { 16 , 5 }), gf::ConsoleEffect::Set, gf::ConsoleAlignment::Left, text, gf::ConsoleColorControl3, gf::ConsoleColorControlStop);
67
- console.printRect (gf::RectI::fromPositionSize ({ 2 , 15 }, { 16 , 5 }), gf::ConsoleEffect::Set, gf::ConsoleAlignment::Center, text, gf::ConsoleColorControl3, gf::ConsoleColorControlStop);
68
- console.printRect (gf::RectI::fromPositionSize ({ 2 , 25 }, { 16 , 5 }), gf::ConsoleEffect::Set, gf::ConsoleAlignment::Right, text, gf::ConsoleColorControl3, gf::ConsoleColorControlStop);
70
+ style.alignment = gf::ConsoleAlignment::Left;
71
+ console.printRect (gf::RectI::fromPositionSize ({ 2 , 5 }, { 16 , 5 }), style, text, gf::ConsoleColorControl3, gf::ConsoleColorControlStop);
72
+ style.alignment = gf::ConsoleAlignment::Center;
73
+ console.printRect (gf::RectI::fromPositionSize ({ 2 , 15 }, { 16 , 5 }), style, text, gf::ConsoleColorControl3, gf::ConsoleColorControlStop);
74
+ style.alignment = gf::ConsoleAlignment::Right;
75
+ console.printRect (gf::RectI::fromPositionSize ({ 2 , 25 }, { 16 , 5 }), style, text, gf::ConsoleColorControl3, gf::ConsoleColorControlStop);
76
+
77
+ console.drawFrame (gf::RectI::fromPositionSize ({ 30 , 5 }, { 16 , 5 }), style);
78
+ console.drawFrame (gf::RectI::fromPositionSize ({ 30 , 15 }, { 16 , 5 }), style, gf::Console::PrintAction::None, " Frame title" );
69
79
70
- console.drawFrame (gf::RectI::fromPositionSize ({ 30 , 5 }, { 16 , 5 }));
71
- console.drawFrame (gf::RectI::fromPositionSize ({ 30 , 15 }, { 16 , 5 }), gf::Console::PrintAction::None, gf::ConsoleEffect::Set, " Frame title" );
80
+ console.scale (Scale);
72
81
73
82
renderer.clear (gf::Color::White);
74
83
0 commit comments