qrohlf / trianglify

Algorithmically generated triangle art
http://qrohlf.com/trianglify/
GNU General Public License v3.0
10.08k stars 669 forks source link

minimum custom D3 build for trianglify to depend on #25

Closed tmaslen closed 9 years ago

tmaslen commented 9 years ago

Hi,

Really loving trianglify, thanks for making it! Do you know what the minimum build of D3 needs to be to make it work with trianglify? Right now I've identified the modules:

Would be a nice feature to list or even provide the minimum D3 build required to run trianglify, as the lib progresses I'd imagine the custom build may change.

Thanks, /t

tmaslen commented 9 years ago

I got default d3.min.js down from 143kb to 83kb and it still works with trianglify.

qrohlf commented 9 years ago

I looked into this a bit. There's an example of doing something like this from the author of d3 here, but I feel like this is a fairly fragile solution that ignores the usefulness of require() in node.js and the upcoming ES6 spec.

With a solution that cherry-picks and concatenates specific files from the d3 core, I'm concerned about what would happen when

I think that are two possible optimal ways to reduce the size of Trianglify + dependencies:

  1. Refactor d3 such that it's possible to require specific modules from it as dependencies, similar to the way that Bootstrap lets you cherry-pick which modules to use with SASS/LESS @import statements.
  2. Refactor Trianglify such that it no longer depends on d3, by including a Delaunay mesh algorithm in Trianglify and replacing the d3 SVG generation stuff with vanilla DOM-based SVG generation.

Thoughts?

tmaslen commented 9 years ago

That's exactly how I made the custom D3 build. Yes agree its potentially fragile. I always try to reduce dependencies in projects, maybe just cut out the bits of D3 you need and permanently add them directly into the trianglify codebase would be good enough?

I'm not a licence expert, but D3's licence would seem to be compatible with this:

https://github.com/mbostock/d3/blob/master/LICENSE

Refactor Trianglify such that it no longer depends on d3, by including a Delaunay mesh algorithm in Trianglify and replacing the d3 SVG generation stuff with vanilla DOM-based SVG generation

That's even better than having to depend on D3 but sounds like a lot of work.

Either way, Trianglify is a great project, thanks for making it.

/t

qrohlf commented 9 years ago

Closing this as the upcoming v0.2.0 release will get rid of the d3 dependency entirely in favor of ironwallaby/delaunay and vanilla JS for SVG/canvas/etc.

NiklasBr commented 9 years ago

upcoming v0.2.0 release will get rid of the d3 dependency

bower.json still lists d3 as a requirement, what happened?

qrohlf commented 9 years ago

I forgot to update bower.json :/

Will fix and issue a patch on Monday (work has been kind of involved this week, I'll get to this ASAP. PR's accepted ).

qrohlf commented 9 years ago

@NiklasBr I just pushed v0.3.1 which removes d3 as a dependency in bower.json and also updates the main entry to point to the right location.

TBH I kind of forgot that people used bower. I guess I've had my head stuck in the node ecosystem for too long lately.

NiklasBr commented 9 years ago

Great, thanks! 👍

I'm just getting started with node so I don't know any better :)