-
Notifications
You must be signed in to change notification settings - Fork 13
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 setting text alignment mode #64
Comments
It's possible in purr-data as long as HTML SVG supports it. Of which I'm almost certain, but I'm not sure how much work it would be. (There's stacked lines of text in HTML SVG, but I'm not sure that the HTML text alignment styles are supported there. If they are then it should be rather trivial, otherwise you'd have to do it by calculating the bounding box of the text and applying transformation matrices.) |
Thanks for the feedback! Looks like all options would be possible with combinations of
@timothyschoen : any thoughts on this? i might give the vanilla version a try. |
adding to this: probably, horizontal alignment is more relevant in this context? so maybe the function could have an optional second argument and expect set_text_align(LEFT)
set_text_align(RIGHT, BOTTOM) or i'd be fine with any variant (also the mode for both directions), but maybe one seems preferable from a more experienced point of view here? |
We could either have set_text_align, or add an extra argument to draw_text, so we'd have draw_text(x, y, w, fontheight, align = top_left), so the alignment is left by default for backward compatibility. Both are okay with me. I'd define alignment options like this:
I'd prefer to limit it to one argument, and this should be clear enough? |
sounds like a good option to me as well to set it directly in i'd stick with to avoid misunderstandings from my side: should these be strings or values like |
I think values are better here. I agree about using "center" instead! |
thanks for the feedback! sorry for coming up with more and more questions here ... but i see in -- constants used in the signal and graphics API
DATA = 0
SIGNAL = 1
Colors = {background = 0, foreground = 1, outline = 2} ... not sure now if we would add all these alignment values on this level? but then again, i'm not sure how to implement that at all - so i'll probably have to better understand a few more parts of the code first. :) |
see #65. we can discuss the details there if it looks good in general. |
currently, the text coordinate always is at the upper left of the text bounding box - obviously resulting in top-left aligned text.
For some use cases (especially when displaying numbers), right alignment would be a nice option to have.
For this, we could add a new alignment setting (similar to the way that colors are set) like
set_text_align(mode)
. An open question here is whether the vertical alignment is also necessary or ifleft
,center
,right
are enough.Tcl/Tk uses compass directions for this (see https://www.tcl.tk/man/tcl8.4/TkCmd/options.htm#M-anchor):
n, ne, e, se, s, sw, w, nw, center
... that would be an option as well, but not sure if needed and if that would easily be adaptable for purr data and plugdata?The text was updated successfully, but these errors were encountered: