Skip to content

Commit

Permalink
save as PNG works
Browse files Browse the repository at this point in the history
  • Loading branch information
qrohlf committed May 4, 2020
1 parent 5481056 commit 0731297
Show file tree
Hide file tree
Showing 10 changed files with 470 additions and 364 deletions.
12 changes: 5 additions & 7 deletions examples/save-as-png.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ const canvas = trianglify({
variance: Math.random(),
}).toCanvas()

// Strip off the uri part of the data uri, leaving the data
const data = pngURI.substr(pngURI.indexOf('base64') + 7)
// Save the buffer to a file. See the node-canvas docs for a full
// list of all the things you can do with this Canvas object:
// https://github.com/Automattic/node-canvas
const file = fs.createWriteStream('trianglify.png')
canvas.createPNGStream().pipe(file)

// Decode the base64 encoded blob into a buffer
const buffer = new Buffer.from(data, 'base64')

// Save the buffer to a file
fs.writeFileSync(process.argv[2], buffer)
91 changes: 0 additions & 91 deletions lib/pattern.js

This file was deleted.

19 changes: 0 additions & 19 deletions lib/points.js

This file was deleted.

218 changes: 0 additions & 218 deletions lib/trianglify.js

This file was deleted.

Loading

0 comments on commit 0731297

Please sign in to comment.