qrohlf / trianglify

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

Proposal: Node.js friendly version #4

Closed Visgean closed 10 years ago

Visgean commented 10 years ago

With node.js friendly version one could use this to generate backgrounds on server side or on desktop.

D3 is already in NPM so it should not be that hard.

I tried to do it myself but I do not really now node.js that well

qrohlf commented 10 years ago

I'd love to have a node.js version of this project - unfortunately I don't have a ton of time for side projects right now (this was kind of a fluke) so I probably won't be making those changes soon.

Visgean commented 10 years ago

(I meant it as proposal for anyone who wants to contribute to this project but does not necessarily know what to do)

christianbundy commented 10 years ago

What do you mean by "node.js friendly"? This could be thrown onto a Node server like express incredibly easily – what features are you looking for? I'm not sure I know what you mean by "generate backgrounds on server side".

qrohlf commented 10 years ago

I think that Visgean means he'd like to see it packaged as a npm module with a CLI.

Visgean commented 10 years ago

Yes that is what I meant. It is nothing that hard but there needs to be changes so it could be used like require('trianglify')..

qrohlf commented 10 years ago

Closed by a26e52ba51c139fba9071738c865e387da7ccb5a. There's no CLI, but I think that probably belongs in a separate module (trianglify-cli anyone?).

npm install trianglify
var Trianglify = require('trianglify');
t = new Trianglify();
console.log(t.generate(100, 100).svgString);
christianbundy commented 10 years ago

Beautiful – you beat me to it! :)

Visgean commented 10 years ago

Did you succeed at saving that data as file?

!/usr/bin/env node

var fs = require('fs'); var Trianglify = require('trianglify');

var t = new Trianglify(); var image_data = t.generate(800, 600).svgString;

fs.writeFile('filename', image_data, function(err) { if(err) { console.log(err); } else { console.log("The file was saved!"); } });

did not work, the data saved is not standard svg format...

qrohlf commented 10 years ago

jsdom is generating a self-closing tag, which Illustrator maybe doesn't seem to like. (specifically, the feTurbulence tag in the noise filter). Also, the capitalization of the svg and path tags? I'm not really certain what the issue is here, since the XML validates just fine.

christianbundy commented 10 years ago

Can you post your output?

Visgean commented 10 years ago

https://gist.github.com/Visgean/10831242

@qrohlf yes the capitalization of the svg and path tags was the problem

Visgean commented 10 years ago

So for anyone else interested: you can have your wallpaper changed automatically: https://gist.github.com/Visgean/10847362

qrohlf commented 10 years ago

Capitalization issue fixed in 5089a9758a6c44f40260ca5de2b2f44cfce7fe76

cryptiklemur commented 6 years ago

Was this removed?