mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
REVIEWED: Formatting to follow raylib conventions
This commit is contained in:
@ -231,7 +231,7 @@ int main(void)
|
||||
if (multicolor)
|
||||
{
|
||||
// Fill color array with random colors
|
||||
for (int i = 0; i < TEXT_MAX_LAYERS; ++i)
|
||||
for (int i = 0; i < TEXT_MAX_LAYERS; i++)
|
||||
{
|
||||
multi[i] = GenerateRandomColor(0.5f, 0.8f);
|
||||
multi[i].a = GetRandomValue(0, 255);
|
||||
@ -296,7 +296,7 @@ int main(void)
|
||||
rlRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
||||
rlRotatef(90.0f, 0.0f, 0.0f, -1.0f);
|
||||
|
||||
for (int i = 0; i < layers; ++i)
|
||||
for (int i = 0; i < layers; i++)
|
||||
{
|
||||
Color clr = light;
|
||||
if (multicolor) clr = multi[i];
|
||||
|
||||
@ -186,7 +186,7 @@ static void DrawTextStyled(Font font, const char *text, Vector2 position, float
|
||||
else increaseX += ((float)font.glyphs[index].advanceX*scaleFactor + spacing);
|
||||
|
||||
// Draw background rectangle color (if required)
|
||||
if (colBack.a > 0) DrawRectangleRec((Rectangle) { position.x + textOffsetX, position.y + textOffsetY - backRecPadding, increaseX, fontSize + 2 * backRecPadding }, colBack);
|
||||
if (colBack.a > 0) DrawRectangleRec((Rectangle) { position.x + textOffsetX, position.y + textOffsetY - backRecPadding, increaseX, fontSize + 2*backRecPadding }, colBack);
|
||||
|
||||
if ((codepoint != ' ') && (codepoint != '\t'))
|
||||
{
|
||||
|
||||
@ -210,7 +210,7 @@ int main(void)
|
||||
|
||||
// Draw random emojis in the background
|
||||
//------------------------------------------------------------------------------
|
||||
for (int i = 0; i < SIZEOF(emoji); ++i)
|
||||
for (int i = 0; i < SIZEOF(emoji); i++)
|
||||
{
|
||||
const char *txt = &emojiCodepoints[emoji[i].index];
|
||||
Rectangle emojiRect = { position.x, position.y, (float)fontEmoji.baseSize, (float)fontEmoji.baseSize };
|
||||
@ -316,7 +316,7 @@ static void RandomizeEmoji(void)
|
||||
hovered = selected = -1;
|
||||
int start = GetRandomValue(45, 360);
|
||||
|
||||
for (int i = 0; i < SIZEOF(emoji); ++i)
|
||||
for (int i = 0; i < SIZEOF(emoji); i++)
|
||||
{
|
||||
// 0-179 emoji codepoints (from emoji char array) each 4bytes + null char
|
||||
emoji[i].index = GetRandomValue(0, 179)*5;
|
||||
|
||||
@ -70,27 +70,32 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
if (IsKeyPressed(KEY_LEFT)) {
|
||||
if (IsKeyPressed(KEY_LEFT))
|
||||
{
|
||||
hAlign = hAlign - 1;
|
||||
if (hAlign < 0) hAlign = 0;
|
||||
}
|
||||
if (IsKeyPressed(KEY_RIGHT)) {
|
||||
|
||||
if (IsKeyPressed(KEY_RIGHT))
|
||||
{
|
||||
hAlign = hAlign + 1;
|
||||
if (hAlign > 2) hAlign = 2;
|
||||
}
|
||||
if (IsKeyPressed(KEY_UP)) {
|
||||
|
||||
if (IsKeyPressed(KEY_UP))
|
||||
{
|
||||
vAlign = vAlign - 1;
|
||||
if (vAlign < 0) vAlign = 0;
|
||||
}
|
||||
if (IsKeyPressed(KEY_DOWN)) {
|
||||
|
||||
if (IsKeyPressed(KEY_DOWN))
|
||||
{
|
||||
vAlign = vAlign + 1;
|
||||
if (vAlign > 2) vAlign = 2;
|
||||
}
|
||||
|
||||
// One word per second
|
||||
wordIndex = (int)GetTime() % wordCount;
|
||||
|
||||
wordIndex = (int)GetTime()%wordCount;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
@ -108,9 +113,9 @@ int main(void)
|
||||
Vector2 textSize = MeasureTextEx(font, words[wordIndex], fontSize, fontSize*.1f);
|
||||
|
||||
// Calculate the top-left text position based on the rectangle and alignment
|
||||
Vector2 textPos = (Vector2) {
|
||||
textContainerRect.x + Lerp(0.0f, textContainerRect.width - textSize.x, ((float)hAlign) * 0.5f),
|
||||
textContainerRect.y + Lerp(0.0f, textContainerRect.height - textSize.y, ((float)vAlign) * 0.5f)
|
||||
Vector2 textPos = (Vector2){
|
||||
textContainerRect.x + Lerp(0.0f, textContainerRect.width - textSize.x, ((float)hAlign)*0.5f),
|
||||
textContainerRect.y + Lerp(0.0f, textContainerRect.height - textSize.y, ((float)vAlign)*0.5f)
|
||||
};
|
||||
|
||||
// Draw the text
|
||||
|
||||
Reference in New Issue
Block a user