-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Allow textAlign(CENTER, CENTER) with max width but no max height #6060
Changes from 3 commits
b65fa5f
d58ca11
4e231d9
5146ba4
2985c65
8c9bf58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -298,15 +298,12 @@ p5.Renderer.prototype.text = function(str, x, y, maxWidth, maxHeight) { | |||||
} | ||||||
} else { | ||||||
// no text-height specified, show warning for BOTTOM / CENTER | ||||||
if (this._textBaseline === constants.BOTTOM) { | ||||||
return console.warn( | ||||||
'textAlign(*, BOTTOM) requires x, y, width and height' | ||||||
); | ||||||
} | ||||||
if (this._textBaseline === constants.CENTER) { | ||||||
return console.warn( | ||||||
'textAlign(*, CENTER) requires x, y, width and height' | ||||||
); | ||||||
if (this._textBaseline === constants.BOTTOM || | ||||||
this._textBaseline === constants.CENTER) { | ||||||
// use rectHeight as an approximation for text height | ||||||
let rectHeight = p.textSize() * (this._textLeading || 1.25); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like Line 40 in 4e231d9
textSize() , so I think it's safe to just use this._textLeading here.
If there's a case I'm not considering though, and we need the Line 163 in 4e231d9
|
||||||
finalMinHeight = y - rectHeight / 2; | ||||||
finalMaxHeight = y + rectHeight / 2; | ||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably shouldn't edit p5.sound.js here, as it comes from builds in https://github.com/processing/p5.js-sound that we periodically pull from. If we want to make a change to it, we'd have to make it in that repo for it to not get overwritten in the next build.