-
Notifications
You must be signed in to change notification settings - Fork 18
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
Added text node. #37
base: main
Are you sure you want to change the base?
Added text node. #37
Conversation
@@ -249,8 +249,7 @@ def render(self): | |||
svg_header = render_tag(**attrs)+ "\n" | |||
svg_footer = "</svg>\n" | |||
|
|||
# flip the y axis so that y grows upwards | |||
node = Group(self.nodes) | Scale(sx=1, sy=-1) | |||
node = Group(self.nodes) |
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.
I don't think replacing y
to -y
wherever it is used for avoiding this transformation is a good idea. Right now we don't maintain the exact attributes used to create a shape, but we would like to do that at some point.
I think it would better to apply scale(y=-1)
to text shape to compesate for this.
>>> t = text("Hello!", center=Point(x=100, y=100), alignment_baseline="middle", text_anchor="middle") | ||
>>> show(t) | ||
""" | ||
def __init__(self, content, anchor=Point(0, 0), **kwargs): |
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.
This API is inconsitent with other shapes. We typically use x
and y
attributes to specify position instead of a Point
.
For example: circle(x=100, y=100)
I think it would be better to use it as text("Hello", x=100, y=100)
show(t) | ||
|
||
""" | ||
return Text(content, anchor=Point(x=x, y=-y), **kwargs) |
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.
Ah, I see that you've retained the interface of using x
and y
here.
@@ -116,7 +116,7 @@ For example, draw 10 circles: | |||
|
|||
``` | |||
c = circle(x=-100, y=0, r=50) | |||
shape = c | Repeat(10, Translate(x=10, y=0) | |||
shape = c | repeat(10, translate(x=10, y=0) |
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.
This change is not related to adding text node. Could you please remove this change from this PR?
Thanks @asteppke for the PR. I've added some comments. Please review. |
In the first commit the flip transformation of the y-axis is exchanged by a sign change of all given y coordinates. This allows upright text.
Then we can add a basic text node relatively straightforward. Of course I am looking forward for any feedback!