Open araid opened 3 months ago
This is not a bug from p5 code, it is an issue from textAlign property. Please reach out to developers for textAlign for this problem! More info can be found here [https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign] The only piece of code realted to textAlign is here, and it doesn't edit anything about LEFT, RIGHT,CENTER for this.
@RuimingShen I'm not sure I understand your answer. What's the issue with textAlign
?
My report refers to textToPoints()
. When I step through the function, I don't see alignment being considered at any moment. That means that for multiline strings, the text layout and points are misaligned.
textAlign(LEFT, BASELINE) | textAlign(CENTER, BASELINE) |
---|---|
I updated the sketch to make it clearer. Please let me know if that makes sense.
@RuimingShen may be confused about how textAlign works. But to provide some clarity on the issue, when textToPoints() was initially written, it did not include support for multiple text lines. If you needed multiple lines, you would call it multiple times. At some point, support for splitting a string on line breaks was added, but without corresponding support for the various alignments. Fixing this would require only (I think) using the existing _handleAlignment() function from textBounds() in textToPoints() as well
I'd like to work on this.
Most appropriate sub-area of p5.js?
p5.js version
1.9.1
Web browser and version
Chrome 122.0.6261.129
Operating system
macOS
Steps to reproduce this
Steps:
\n
)textAlign(CENTER, BASELINE)
and thentextToPoints
on that string.Snippet:
see https://editor.p5js.org/araid/sketches/S7DRlqtvP