#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <citro2d.h>
static const char teststring[] =
"Hello World - now with citro2d!\n"
"The quick brown fox jumps over the lazy dog.\n"
"\n"
"En français: Vous ne devez pas éteindre votre console.\n"
"日本語文章を見せるのも出来ますよ。\n"
"Un poco de texto en español nunca queda mal.\n"
"Πού είναι η τουαλέτα;\n"
"Я очень рад, ведь я, наконец, возвращаюсь домой\n";
C2D_TextBuf g_staticBuf, g_dynamicBuf;
C2D_Text g_staticText[4];
static void sceneInit(void)
{
g_staticBuf = C2D_TextBufNew(4096);
g_dynamicBuf = C2D_TextBufNew(4096);
C2D_TextParse(&g_staticText[0], g_staticBuf, teststring);
C2D_TextParse(&g_staticText[1], g_staticBuf, "I am red skinny text!");
C2D_TextParse(&g_staticText[2], g_staticBuf, "I am blue fat text!");
C2D_TextParse(&g_staticText[3], g_staticBuf, "I am justified text!");
C2D_TextOptimize(&g_staticText[0]);
C2D_TextOptimize(&g_staticText[1]);
C2D_TextOptimize(&g_staticText[2]);
C2D_TextOptimize(&g_staticText[3]);
}
static void sceneRender(float size)
{
C2D_TextBufClear(g_dynamicBuf);
C2D_DrawText(&g_staticText[0], 0, 8.0f, 8.0f, 0.5f, size, size);
C2D_DrawText(&g_staticText[1], C2D_AtBaseline | C2D_WithColor, 16.0f, 210.0f, 0.5f, 0.5f, 0.75f, C2D_Color32f(1.0f,0.0f,0.0f,1.0f));
C2D_DrawText(&g_staticText[2], C2D_AtBaseline | C2D_WithColor | C2D_AlignRight, 384.0f, 210.0f, 0.5f, 0.75f, 0.5f, C2D_Color32f(0.0f,0.0f,1.0f,0.625f));
C2D_DrawText(&g_staticText[3], C2D_AtBaseline | C2D_AlignJustified | C2D_WordWrap, 100.0f, 170.0f, 0.5f, 0.75f, 0.75f, 200.0f);
char buf[160];
C2D_Text dynText;
snprintf(buf, sizeof(buf), "Current text size: %f (Use to change)", size);
C2D_TextParse(&dynText, g_dynamicBuf, buf);
C2D_TextOptimize(&dynText);
C2D_DrawText(&dynText, C2D_AlignCenter, 200.0f, 220.0f, 0.5f, 0.5f, 0.5f);
}
static void sceneExit(void)
{
C2D_TextBufDelete(g_dynamicBuf);
C2D_TextBufDelete(g_staticBuf);
}
int main()
{
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
C2D_Prepare();
sceneInit();
float size = 0.5f;
{
break;
size -= 1.0f/128;
size += 1.0f/128;
size = 0.5f;
size = 1.0f;
if (size < 0.25f)
size = 0.25f;
else if (size > 2.0f)
size = 2.0f;
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(top, C2D_Color32(0x68, 0xB0, 0xD8, 0xFF));
C2D_SceneBegin(top);
sceneRender(size);
C3D_FrameEnd(0);
}
sceneExit();
C2D_Fini();
C3D_Fini();
return 0;
}
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
void gfxInitDefault(void)
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
@ GFX_TOP
Top screen.
Definition: gfx.h:26
void gfxExit(void)
Deinitializes and frees the LCD framebuffers.
@ GFX_LEFT
Left eye framebuffer.
Definition: gfx.h:37
@ KEY_X
X.
Definition: hid.h:22
@ KEY_Y
Y.
Definition: hid.h:23
@ KEY_START
Start.
Definition: hid.h:15
@ KEY_R
R.
Definition: hid.h:20
@ KEY_L
L.
Definition: hid.h:21
u32 hidKeysHeld(void)
Returns a bitmask of held buttons.
u32 hidKeysDown(void)
Returns a bitmask of newly pressed buttons, this frame.
void hidScanInput(void)
Scans HID for input data.
uint32_t u32
32-bit unsigned integer
Definition: types.h:23