add coloring per text section in gizmos#23120
add coloring per text section in gizmos#23120alice-i-cecile merged 4 commits intobevyengine:mainfrom
Conversation
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
There was a problem hiding this comment.
Yeah this is pretty good, the only problem is the extra allocations, which should be avoidable if StrokeTextLayout's text: &str field is replaced with a slice or iterator. Then make a function, something like:
fn colored_chars(s: &[(&str, Color)]) -> impl Iterator<Item = (char, Color)> {
s.into_iter()
.map(|(t, color)| t.chars().map(|c| (c, *color)))
.flatten()
}that maps the sections to an iterator that yields the individual chars and their colors for rendering.
|
Sorry was really tired last night and my review comments were kind of rambling, hopefully you get the idea though. |
|
you're alright, gonna resolve them soon |
|
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
ccf1541 to
ed05f64
Compare
kfc35
left a comment
There was a problem hiding this comment.
I didn’t spot any problems
You can update your PR description if you’d like to remove the mention of the specialized render_with_color_fn function which has since been removed

Objective
bevy_gizmos: Multicolored text support. #23002Solution
StrokeTextLayout::render_with_color_fn()to return polyline and color pairingtext_sections()to build concat string consisting of sections of character-coloring pair(char, Color)textfield inStrokeTextLayoutwithsectionsthat is an iterable&'a [(&'a str, Color)]Testing
Showcase
Example Usage: