mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-11 14:08:48 +01:00
WARNING: **NEW** raylib code CONVENTION: Comments do not end with '.'
This commit is contained in:
@ -39,7 +39,7 @@ int main(void)
|
||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - codepoints loading");
|
||||
|
||||
// Convert each utf-8 character into its
|
||||
// corresponding codepoint in the font file.
|
||||
// corresponding codepoint in the font file
|
||||
int codepointCount = 0;
|
||||
int *codepoints = LoadCodepoints(text, &codepointCount);
|
||||
|
||||
|
||||
@ -6,12 +6,12 @@
|
||||
*
|
||||
* NOTE: Draw a 2D text in 3D space, each letter is drawn in a quad (or 2 quads if backface is set)
|
||||
* where the texture coodinates of each quad map to the texture coordinates of the glyphs
|
||||
* inside the font texture.
|
||||
* inside the font texture
|
||||
*
|
||||
* A more efficient approach, i believe, would be to render the text in a render texture and
|
||||
* map that texture to a plane and render that, or maybe a shader but my method allows more
|
||||
* flexibility...for example to change position of each letter individually to make somethink
|
||||
* like a wavy text effect.
|
||||
* like a wavy text effect
|
||||
*
|
||||
* Special thanks to:
|
||||
* @Nighten for the DrawTextStyle() code https://github.com/NightenDushi/Raylib_DrawTextStyle
|
||||
@ -71,7 +71,7 @@ static void DrawText3D(Font font, const char *text, Vector3 position, float font
|
||||
// Draw a 2D text in 3D space and wave the parts that start with '~~' and end with '~~'
|
||||
// This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle
|
||||
static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig *config, float time, Color tint);
|
||||
// Measure a text in 3D ignoring the `~~` chars.
|
||||
// Measure a text in 3D ignoring the `~~` chars
|
||||
static Vector3 MeasureTextWave3D(Font font, const char *text, float fontSize, float fontSpacing, float lineSpacing);
|
||||
// Generates a nice color with a random hue
|
||||
static Color GenerateRandomColor(float s, float v);
|
||||
@ -562,7 +562,7 @@ static void DrawText3D(Font font, const char *text, Vector3 position, float font
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`.
|
||||
// Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`
|
||||
// This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle
|
||||
static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig* config, float time, Color tint)
|
||||
{
|
||||
@ -625,7 +625,7 @@ static void DrawTextWave3D(Font font, const char *text, Vector3 position, float
|
||||
}
|
||||
}
|
||||
|
||||
// Measure a text in 3D ignoring the `~~` chars.
|
||||
// Measure a text in 3D ignoring the `~~` chars
|
||||
static Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing)
|
||||
{
|
||||
int len = TextLength(text);
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
* - Rectangles must be defined by a MAGENTA color background
|
||||
*
|
||||
* Following those constraints, a font can be provided just by an image,
|
||||
* this is quite handy to avoid additional font descriptor files (like BMFonts use).
|
||||
* this is quite handy to avoid additional font descriptor files (like BMFonts use)
|
||||
*
|
||||
* Example originally created with raylib 1.0, last time updated with raylib 1.0
|
||||
*
|
||||
|
||||
@ -63,7 +63,7 @@ int main(void)
|
||||
if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS))
|
||||
{
|
||||
name[letterCount] = (char)key;
|
||||
name[letterCount+1] = '\0'; // Add null terminator at the end of the string.
|
||||
name[letterCount+1] = '\0'; // Add null terminator at the end of the string
|
||||
letterCount++;
|
||||
}
|
||||
|
||||
|
||||
@ -179,9 +179,9 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec,
|
||||
|
||||
// NOTE: When wordWrap is ON we first measure how much of the text we can draw before going outside of the rec container
|
||||
// We store this info in startLine and endLine, then we change states, draw the text between those two variables
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container).
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container)
|
||||
// When wordWrap is OFF we don't need the measure state so we go to the drawing state immediately
|
||||
// and begin drawing on the next line before we can get outside the container.
|
||||
// and begin drawing on the next line before we can get outside the container
|
||||
if (state == MEASURE_STATE)
|
||||
{
|
||||
// TODO: There are multiple types of spaces in UNICODE, maybe it's a good idea to add support for more
|
||||
|
||||
@ -378,9 +378,9 @@ static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec,
|
||||
|
||||
// NOTE: When wordWrap is ON we first measure how much of the text we can draw before going outside of the rec container
|
||||
// We store this info in startLine and endLine, then we change states, draw the text between those two variables
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container).
|
||||
// and change states again and again recursively until the end of the text (or until we get outside of the container)
|
||||
// When wordWrap is OFF we don't need the measure state so we go to the drawing state immediately
|
||||
// and begin drawing on the next line before we can get outside the container.
|
||||
// and begin drawing on the next line before we can get outside the container
|
||||
if (state == MEASURE_STATE)
|
||||
{
|
||||
// TODO: There are multiple types of spaces in UNICODE, maybe it's a good idea to add support for more
|
||||
|
||||
Reference in New Issue
Block a user