stathissideris / dali

dali is a Clojure library for representing, exporting and manipulating the SVG graphics format.
296 stars 16 forks source link

Adding a param to distribute? #19

Closed onealexharms closed 4 years ago

onealexharms commented 4 years ago

Hi! Thanks for this library! It's exactly what we were looking for. (We is me and my project pair.)

We have a situation where we need to place things an objective distance apart, without regard for the width of the thing. We are thinking that adding an anchor-distance param to distribute that defaults to largest-object would solve our problem without creating backwards compatibility issues. The step amount would then be either the gap + the largest element (as it is now), or the gap + anchor-distance.

Would you be open to a pull request? And how do you feel about the approach and the names?

stathissideris commented 4 years ago

Hello! Glad dali is useful for you!

From looking at the distribute code, it sounds like you'd like to be able to override step (which would be a good name for the new option I think). Currently step is max dimension (depending on direction) + gap. I think it would be confusing to have both gap and manual step be in effect at the same time, so I think it would be best to make it so when you define a step you're overriding both.

In fact, the necessary change is pretty minimal, could you please give a try to this (completely untested) branch? https://github.com/stathissideris/dali/tree/manual-distribute-step

The project now has a deps.edn so if you're using deps instead of leiningen you can point to the commit directly.

onealexharms commented 4 years ago

Thanks! I only kept gap basically to avoid a bigger change :) but of course you're right that it'd be kinda weird.

I'll give that a try this weekend. Thanks again.

onealexharms commented 4 years ago

Perfect! Thanks :)

stathissideris commented 4 years ago

Alright, let's make it official then! The change was released in v1.0.1 (although now that I think of it, it should have been a minor version instead of a patch version). I'm always on the lookout for good dali examples, so if you end up making something you can share, I'd be more than happy to include it in the examples. And you'd get your name mentioned in the readme as a contributor!