FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use `start` instead of 0 for the starting index in `text` by iTutFadU · Pull Request #1257 · processing/processing4 · GitHub

Use start instead of 0 for the starting index in text - #1257

Merged
catilac merged 1 commit into
processing:mainfrom
iTutFadU:patch-1
Feb 10, 2026
Merged

Use start instead of 0 for the starting index in text#1257
catilac merged 1 commit into
processing:mainfrom
iTutFadU:patch-1

Conversation

Copy link
Copy Markdown
Contributor

start can be non-zero since the method is public. Otherwise it counts newlines before the start of the actual text in range.

Stefterv commented Sep 29, 2025
edited
Loading

Copy link
Copy Markdown
Member

Hi @iTutFadU could you show through screenshots what this change would entail?

Copy link
Copy Markdown
Contributor Author

The text will show up at the correct height (here green) instead of counting newlines preceding it before the range (here red).

The example code:

String text = "Some\n\ntext\nwith\nnewlines";
char[] chars;
float textWidth;

void setup() {
    size(500, 500, P2D);
    textFont(createFont("Arial", 50));
    textAlign(LEFT, TOP);
    chars = text.toCharArray();
    textWidth = textWidth(text.substring(6, text.length()));
}

void draw() {
    background(20);
    
    fill(#FF5555);
    text(chars, 6, text.length(), 0, 0);
    
    fill(#55FF55);
    text(text.substring(6, text.length()), width / 2, 0);
}

Stefterv added this to the 4.4.11 milestone Oct 14, 2025

Stefterv commented Feb 9, 2026

Copy link
Copy Markdown
Member

@catilac

catilac merged commit 21c2466 into processing:main Feb 10, 2026
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL