Open timjs opened 7 years ago
For what shapes in particular do you think this would be problematic? Calculating the extents of polygons and ellipses can be done efficiently using basic highschool geometry, and obviously anything rectangular such as images and text would be pretty trivial. Handling paths might be a bit more complicated, but the problem there seems fundamentally to be one of design, not implementation. (Determining the extent of arbitrary HTML elements could also be difficult, but that would be true even with purely rectangular envelopes I should think.)
Maybe you’re right and it is only a problem of design instead of implementation. My main concern is keeping the library simple. When calculating arbitrary envelopes we’ll need vectors instead of the simple Up|Down|Right|Left enumeration. Obviously we can provide functions to cover those basic directions.
On 18 Oct 2017, 05:34 +0200, Dathan Ault-McCoy , wrote:
For what shapes in particular do you think this would be problematic? Calculating the extents of polygons and ellipses can be done efficiently using basic highschool geometry. Obviously anything rectangular such as images and text would be pretty trivial. Handling paths might be a bit more complicated, but the problem there seems fundamentally to be one of design, not implementation. (Determining the extent of arbitrary HTML elements could also be difficult, but that would be true even with purely rectangular envelopes I should think.) — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Is there a reason to use vectors instead of angles? For instance, you could define
envelope : Float -> Collage msg -> Float
to return the distance from the origin to the edge of the envelope at an angle specified by the float argument. Then you could define
up = pi/2
down = 3*pi/2
left = pi
right = 0
So you could still use envelope up
just like before (except lower case), but you could also say envelope 0.833
. What simplicity do you see being lost here?
Would be totally fine to use angles I think!
This, off course, would be awesome! Strange things like the top-right of a circle being out of the shape won't happen any more. Two things are important to keep in mind however:
Summarised: awesome to extend envelopes further, but I currently don't have the time and knowledge to implement this myself.
(First brought up in #4.)