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
repeat - new higher-order transformation #1
Comments
@amitkaps please let me know your comments. |
Also, I would like to make it easier to specify anchor point when doing rotations. For example, I want to draw a square by rotating a the line by 90 degrees 4 times. It could be expressed as:
Every shape maintains important points for that shape. Here are the points that are available for each shape:
Some examples of the possibilties with this: Rotate the circle around the right most point.
Rotate the rectangle around the top-left corner.
When combining multiple shapes, we could give labels to each shape and use it when specifying anchors.
|
In principle, I like the functional pipe transformation syntax as well as the construct of a transform function without applying to a shape. Both are intuitive to understand for me. For the rotation along a point, the point construct makes sense. Not sure about extracting points from rect and circle though based on canvas coordinate direction, as that is unclear (after any transforms) and basically our discussion on #2. In general for polygon - ordered vertices would make sense and for arc/curved lines - equal partitions of length segments make sense. Adds complexity so maybe park it for now. |
Agreed. I liked the pipe syntax.
Do you mean the following?
Agreed. For rect, having |
With every basic shape and transformation becoming title-case classes, only |
Wondering if it would be a good ideas to replace
|
I'm going to complete this task leaving out the labeled points for anchor. Will create another issue to handle that. |
On case - here is a thought. Nouns - Objects like Shapes - Titlecase |
That is an interesting thought. So we'll have Now could could add more higher-order transformations like We could even have a
|
I'm not completely convinced. The Just like
It would have made sense to use lower case if they were really actions, like in this example:
|
@amitkaps any comments? |
Maybe case syntax is not that important to make this difference clear - using nouns & verbs properly is enough. That was my thought process. |
I'm proposing a new higher-order transformation
repeat
, what would apply a transformation repeatedly and combine all the resulting shapes.For example:
would produce:
New Transform API
To make it easier to use the transforms, I propose a new API for transforms.
All the transform functions work in two ways.
When a shape argument is suplied, it returns a new shape with the transformation applied. For example
rotate(rect(), 45)
would rotate the shape by 45 degrees.When shape argument is not supplied, it returns a transformation object.
rotate(45)
return the transformation object that rotates given shape by 45 degres.A new transformation can be created by combining multiple transformations and the
|
is used for combining them.Even repeat can be called without a shape and that creates a new transformation.
With this we can do create many transformations with ease.
Some examples:
Draw four circles in a row:
Draw a 4x4 grid of circles.
In fact, the
cycle
function will become a special case ofrepeat
.The text was updated successfully, but these errors were encountered: