voxel-share

Take a snapshot of voxel.js and share on imgur/twitter

npm install voxel-share
7 downloads in the last week
13 downloads in the last month

voxel-share

Take a snapshot in voxel.js and share on imgur.com/twitter.com.

Props to imgur.com for enabling CORS and accepting base64 image uploads via the browser. :D

View this example

usage

Create a share tool:

var share = require('voxel-share')({
  // pass a copy of the game
  game: game,

  // api key from https://api.imgur.com/oauth2/addclient
  key: 'abcd1234',

  // specify a message to set as caption/tweet
  message: 'Greetings from voxel.js! @voxeljs',

  // type of image: image/png or image/jpg
  type: 'image/png',

  // quality of image. between 0 and 1
  quality: 0.75,

  // do something else with the image link after it's uploaded
  afterUpload: function(imageLink) {
    // Open the tweet dialog with image link
    this.tweet(imageLink);
  },
});

Then upon desired event, open/close the share dialog:

window.addEventListener('keyup', function(e) {

  // on enter, open dialog
  if (e.keyCode === 13) share.open();

  // on esc, close dialog
  if (e.keyCode === 27) share.close();

});

Check the example for a more in-depth usage.

install

With npm do:

npm install voxel-share

Use browserify to require('voxel-share').

release history

  • 0.3.0 - Added afterUpload feature. Thanks @maxogden!
  • 0.2.0 - update to work with imgur api v3. Thanks @maxogden!
  • 0.1.0 - initial release

license

Copyright (c) 2013 Kyle Robinson Young
Licensed under the MIT license.

npm loves you