This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#c{ | |
border:1px solid red; | |
top:22px; | |
left:0px; | |
height: 100%; | |
width: 99%; | |
} | |
.box { | |
float: left; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="c" width="400" height="200"></canvas> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/20032214/recreate-fabric-js-canvas-and-export-as-an-image | |
function download(url,name){ | |
// make the link. set the href and download. emulate dom click | |
$('<a>').attr({href:url,download:name})[0].click(); | |
} | |
function downloadFabric(canvas,name){ | |
// convert the canvas to a data url and download it. | |
download(canvas.toDataURL(),name+'.png'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source: https://bl.ocks.org/davelandry/a39f0c3fc52804ee859a | |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<script src="//d3plus.org/js/d3.js"></script> | |
<script src="//d3plus.org/js/d3plus.js"></script> | |
<style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Source: http://stackoverflow.com/questions/33659059/invoke-amazon-lambda-function-from-node-app?rq=1 | |
var AWS = require('aws-sdk'); | |
// you shouldn't hardcode your keys in production! See http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html | |
AWS.config.update({accessKeyId: 'akid', secretAccessKey: 'secret'}); | |
var lambda = new AWS.Lambda(); | |
var params = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<label for="nValue" | |
style="display: inline-block; width: 240px; text-align: right"> | |
angle = <span id="nValue-value"></span> | |
</label> | |
<input type="number" min="0" max="360" step="5" value="0" id="nValue"> | |
</p> | |
<p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source: http://stackoverflow.com/questions/22387627/how-to-save-an-image-in-its-original-size-in-a-canvas-after-scaled-the-canvas | |
The size you set with the width and height properties will be the image's final size. | |
canvas.width = 1920; // actual size given with integer values | |
canvas.height = 1080; | |
If you need to scale down while on screen you need to use CSS (one of those special cases): | |
canvas.style.width = '960px'; // show at 50% on screen | |
canvas.style.height = '540px'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//libraries used: | |
https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js | |
//Polyfills | |
https://rawgit.com/eligrey/Blob.js/master/Blob.js | |
https://rawgit.com/eligrey/canvas-toBlob.js/master/canvas-toBlob.js | |
https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2014-11-29/FileSaver.min.js | |
//all in one save option | |
$( "#save" ).click(function() { | |
var img = new Image, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Source: http://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript | |
$( "#imagetourl" ).click(function() { | |
function toDataUrl(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.onload = function() { | |
var reader = new FileReader(); | |
reader.onloadend = function() { | |
callback(reader.result); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source: http://stackoverflow.com/questions/13990673/upload-canvas-data-to-s3 | |
var canvas = document.getElementById("imagePreviewChatFooter"); | |
var dataUrl = canvas.toDataURL("image/jpeg"); | |
var blobData = dataURItoBlob(dataUrl); | |
var fileName = file.name; | |
var params = {Key: fileName, ContentType: file.type, Body: blobData}; | |
bucket.upload(params, function (err, data) { | |
console.log(data); | |
console.log(err ? 'ERROR!' : 'UPLOADED.'); |