-
Notifications
You must be signed in to change notification settings - Fork 14
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 transformation #45
Comments
@FayCarsons this is quite nice! I like how you have the most amazing ideas and are so enthusiastic, it's motivating... :) |
@FayCarsons i feel we need a few more changes before it would make sense to start working on this:
A type for group of shapesReason behind a separate type instead of using e.g. let's say we have a donut let donut = shape_sum (circle 50) (circle 100 |> color "black") I want to be able to scale that donut the same way I scale other shapes let () = show [donut |> scale 0.5] Representing series of transformationsThis is so that we can combine transformations and represent slightly more advanced transformations such as "scale this shape by 0.5 then rotate by 45 degrees". We can probably recommend using currying and something like composition for this, and utilise the function signature of a transformation (which is Something like: (* compose right-to-left -- function on right is applied first *)
let compose_rtl f g x = g (f x)
let () =
let halve_and_rotate = compose_rtl (scale 0.5) (rotate 30) in
let rectangles = List.init 6 (fun _ -> rectangle 50 50) in
show (List.map halve_and_rotate rectangles) We should create examples for such use cases if this API looks good enough. @Sudha247 what do you think? |
Indeed, shape group and compose transformation are useful features to have. @FayCarsons are you interested in making PRs for those? I'd recommend making them as separate PRs. It's easier to review and merge that way. |
I can absolutely take these on! May need to ask more questions than usual but they both seem doable to me. In the case of the sort of compound shape type, is there any reason we couldn't just extend the shape type to also include |
Fixed by #71. |
The original Joy python library has a "higher order transformation" called repeat that applies a set of transformations iteratively to a provided initial shape.
Now that we have some transformations, rotate, translate, scale(I think? Not sure if it's been merged), this seems like it would be a fun feature to have.
I have a clear idea of how to implement this declaratively with List.fold_right and would love to get started on it ASAP :)
The text was updated successfully, but these errors were encountered: