[examples] Potential for new example: text_styled_texts#4818
Closed
SultansOfCode wants to merge 3 commits intoraysan5:masterfrom
Closed
[examples] Potential for new example: text_styled_texts#4818SultansOfCode wants to merge 3 commits intoraysan5:masterfrom
text_styled_texts#4818SultansOfCode wants to merge 3 commits intoraysan5:masterfrom
Conversation
…oducing MeasureTextStyled and MeasureTextStyledEx functions
Owner
|
@SultansOfCode Thanks for the nice effect! I'm afraid this implementation is too custom to be added to raylib for all users, the styling mechanism should be a user-decision, not imposed by raylib. Still, it can be directly implemented into a single example intended for users looking for an implementation sample or as a base solution to implement their own. Please, could you review it to make it self-contained to the example? Also note that examples should follow some guidelines. |
text_styled_texts
text_styled_textstext_styled_texts
Owner
|
I'm not adding this functionality to raylib main library but I'll try to create a custom example from it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
I have added the ability to customize text color and background color with special characters inside the text (pretty much like mIRC does)
You can use the functions
DrawTextStyledandDrawTextStyledExalmost as you would useDrawTextandDrawTextExrespectivelyThe changes are: instead of passing the Color, you will pass an array of Colors and the size of this array
Inside the text you can use
\003to set the foreground color,\004to set the background color,\015to reset them to their default values (first color in array, if any, as foreground color [or black, if none], and transparent background) and\022to swap foreground and background colorsAlso added
MeasureTextStyledandMeasureTextStyledExto correctly measure them asMeasureTextandMeasureTextExwould for plain textsIf any adjustment is needed, either to the code or to the PR, please, let me know
Thank you