This repository was archived by the owner on Nov 17, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCanvasToVideo.min.js
9 lines (8 loc) · 1.84 KB
/
CanvasToVideo.min.js
1
2
3
4
5
6
7
8
9
/*!
* CanvasToVideo v0.1.0beta
* https://github.com/neogeek/CanvasToVideo
*
* Copyright (c) 2014 Scott Doxey
*/
!function(){"use strict";function a(a,b,c){var d=new window.XMLHttpRequest;d.open("put",a),"[object Array]"===Object.prototype.toString.call(b)&&(b=JSON.stringify(b)),"function"===String(typeof c)&&d.addEventListener("readystatechange",function(){4===this.readyState&&204===this.status&&c.call(this)}),d.send(b)}var b=function(a,b){this.url=a,this.canvas=b,this.imageType="image/png",this.imageQuality=100,this.cache=[],this.cacheEnabled=!1;try{this.canvas.getContext("2d")}catch(c){throw this.canvas=null,new Error("Element passed to CanvasToVideo was not a valid canvas element.")}};b.prototype.capture=function(){var b;this.canvas&&(b=this.canvas.toDataURL(this.imageType,this.imageQuality).replace(/^[\W\w]*,/,""),this.cacheEnabled?this.cache.push(b):a(this.url,[b]))},b.prototype.flush=function(){this.cacheEnabled&&a(this.url,this.cache,function(){this.cache=[]})},b.prototype.setCanvas=function(a){this.canvas=a;try{this.canvas.getContext("2d")}catch(b){throw this.canvas=null,new Error("Element passed to CanvasToVideo.setCanvas was not a valid canvas element.")}},b.prototype.setCacheEnabled=function(a){this.cacheEnabled=a?!0:!1},b.prototype.setEndpoint=function(a){this.url=a},b.prototype.setImageType=function(a){if(!a.match(/image\/(png|jpeg)/))throw new Error(a+" is not a valid image type. The valid types are: image/png and image/jpeg.");this.imageType=a},b.prototype.setImageQuality=function(a){if("number"!==String(typeof a))throw new Error(a+" is not a valid number. Must be a number between 0 (lowest quality) and 100 (highest quality).");this.imageQuality=a},"function"===String(typeof window.define)&&window.define.hasOwnProperty("amd")?window.define([],function(){return b}):window.CanvasToVideo=b}();
//# sourceMappingURL=CanvasToVideo.min.js.map