Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multicolor text support #42

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

henlo-birb
Copy link

adds support for drawing multicolor text in one call to C2D_DrawText using a new flag C2D_MultiColor

a u32 array must also be passed to C2D_DrawText formatted like: {start_idx0, color0, start_idx1, color1, ...} where the start_idx is the index of the character where the corresponding color starts in the string. This is kind of similar to the coloredtext format in the text drawing calls Love2D.

a u32 with the length of that array must be passed as well.

@fincs
Copy link
Member

fincs commented Jun 27, 2022

Good work, although indentation is a bit screwed up. This project uses hard tabs, not spaces.

@henlo-birb
Copy link
Author

henlo-birb commented Jun 27, 2022

I must've messed it up with autoformatting, oops, thanks tho!

@fincs
Copy link
Member

fincs commented Jun 29, 2022

Can you fix the formatting, please?

@henlo-birb
Copy link
Author

henlo-birb commented Jun 29, 2022

done! (assuming the only issue was the spaces instead of tabs) sorry, i got busy w/ other stuff

Copy link
Contributor

@LiquidFenrir LiquidFenrir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bug when a character is in the last range of colours and the next character also is.
You also don't properly reset to the default opaque black (or WithColor-provided value) when the first range doesn't start at the beginning of the text, instead drawing with the last drawn character's colour.

source/text.c Outdated Show resolved Hide resolved
source/text.c Outdated Show resolved Hide resolved
source/text.c Outdated Show resolved Hide resolved
source/text.c Outdated Show resolved Hide resolved
@henlo-birb
Copy link
Author

i think those should be fixed now, anything else?

@LiquidFenrir
Copy link
Contributor

Looks fine to me now, but I think cur-> charNo > colors[0] should be cur->charNo >= colors[0].
No space between the dereference and the field name (style problem), and imagining you start the range at character index 1, having greater than instead of greater or equal would make the if only be true at index 2 or more (logic problem).

@henlo-birb
Copy link
Author

fixed

@Fewnity
Copy link

Fewnity commented Dec 9, 2022

Hey! Any news about the pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants