Skip to content
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

Add Text Node #6

Open
anandology opened this issue Jun 8, 2021 · 8 comments
Open

Add Text Node #6

anandology opened this issue Jun 8, 2021 · 8 comments
Assignees

Comments

@anandology
Copy link
Contributor

The API

Not sure, if this can be called a shape though.

I'm not completelty sure what would be the right API for this.

t = Text(text="Hello")
t = Text(value="Hello")
t = Text(contents="Hello")

The first one is confusing because the word text is appearing multiple times. I'm not sure either value or contents is the right word.

Reference

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text

@anandology anandology self-assigned this Jun 8, 2021
@anandology
Copy link
Contributor Author

@amitkaps what do you think?

@amitkaps
Copy link

amitkaps commented Jun 8, 2021

Text is a responsive shape - normally implemented within a rectangle frame element - where the size is determined by content (character) length, font & font specs like line height and wrapping & alignment modifier.

I would treat the content as default first param and then all other modifier as keywords args.

t = Text("hello world")
t1 = Text("hello", start=Point(100, 100))

@anandology
Copy link
Contributor Author

How about this API for text?

t = text("hello", x=100, y=100)
show(t)

@vsrigayatri
Copy link

How to specify the size of the text?

@anandology
Copy link
Contributor Author

How to specify the size of the text?

How about this way?

t = text("hello", x=100, y=100, font_size=24)

@vsrigayatri
Copy link

vsrigayatri commented Jul 14, 2021 via email

@asteppke
Copy link

A text node feels essential, so I gave this a quick go. It turns out that with the current coordinate system of joy this is rather difficult because the flip transformation of the y axis flips any text as well. This seems to be a rather inherent property of SVG: https://stackoverflow.com/questions/3846015/flip-svg-coordinate-system

This is easy to workaround though if you have full control over the generated SVG and then alloows to add a basic text node: #37

@vsrigayatri
Copy link

vsrigayatri commented Jan 27, 2022 via email

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

No branches or pull requests

4 participants