-
Notifications
You must be signed in to change notification settings - Fork 19
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
Proposal: Make point first class citizens of Joy #2
Comments
What about |
I like making Point as first class citizen. Also, the internal api can then be based on Point & Matrix transforms
|
This will be Polygon of 4 sides, not a rectangle. I think we need Also, my worry is that this may create difficulty and more syntax for newbies.
vs.
The other option is to relax the named arguments.
Thoughts? |
What I sketched earlier was the internal api for it and not the external api. You can probably implement it many different ways so that is not the main point. Making point1 = Point(x=0, y=0)
point2 = Point(x=100, y=50) For line1 = Line(start=point1, end=point2)
line1.points
# (0,0), (100,50)
line1.center
# (50,25) For rect1 = Rect(center=Point(x=50, y =25), width=100, height=50)
rect1.points
# (0, 0), (100, 0), (100, 50), (0, 50)
rect1.center
# (50, 25)
transform1 = SkewX(30)
shape1 = rect1 | transform1
show(shape1)
# <rect x="0" y="0" width="100" height="50" transform="skewX(30)" />
# which is a parallelogram
shape1.points, shape1.center
# ??? This is useful because then I can manipulate individual points of a shape to experiment with more expressive ideas. |
Yes, that's what I was thinking as well. I agree adding point would be useful, but it is also adding complexity. The hello world is now:
And the following is not easy to read:
I would rather prefer:
and convert (50, 25) to a Point internally. I understand the purity part of it, but it feels a bit too long. Anyway, let me give it a shot and see how it turn up. |
I'm having second thoughts about the Thoughts? |
I write down both the APIs to compare one against the other. https://gist.github.com/anandology/a02041798553736c7a326f49eddc22ec I think the new version wins by a huge margin. It is a lot more coherent. Also, I've replaced |
In the new scheme, what will be the arguments to the
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. |
Moved this disucussion to #6. |
Rewrote the entire user facing API of the library. Major changes: - all the shapes and transformations are in TitleCase: Circle, Rectangle etc. - The + operator is used to combine shapes - The | operator is used to apply transformations, allowing chaining of transformations - Using Point object wherever makes sense instead of just x and y Issue #2
Rewrote the entire user facing API of the library. Major changes: - all the shapes and transformations are in TitleCase: Circle, Rectangle etc. - The + operator is used to combine shapes - The | operator is used to apply transformations, allowing chaining of transformations - Using Point object wherever makes sense instead of just x and y Issue #2
Right now we specify just the x and y coordinates to the functions like x1, y1 or cx, cy etc. How about passing points instead of individual coordinates?
The new API would become:
As mentioned in #1, these shapes will have points available as attributes.
And we could use the same for transformations.
The text was updated successfully, but these errors were encountered: