Skip to content

Conversation

asteppke
Copy link

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!

@asteppke asteppke mentioned this pull request Jan 14, 2022

# flip the y axis so that y grows upwards
node = Group(self.nodes) | Scale(sx=1, sy=-1)
node = Group(self.nodes)
Copy link
Contributor

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):
Copy link
Contributor

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)
Copy link
Contributor

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.

```
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)
Copy link
Contributor

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?

@anandology
Copy link
Contributor

Thanks @asteppke for the PR. I've added some comments. Please review.

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

Successfully merging this pull request may close these issues.

2 participants