canvas-recorder
Advanced tools
Comparing version 1.7.1 to 1.8.0
@@ -0,0 +0,0 @@ #! /usr/bin/env node |
@@ -0,1 +1,2 @@ | ||
import JSZip from "jszip"; | ||
import { BaseRecorder, Settings } from "./shared"; | ||
@@ -19,4 +20,8 @@ export declare class Recorder extends BaseRecorder<WebGLRenderingContext> { | ||
declare const setup: (action: (context: WebGLRenderingContext) => void) => void; | ||
declare const bootstrap: (options?: import("../../../../../Users/roboshoes/Projects/canvas-recorder/src/shared").BoostrapOptions) => void; | ||
declare const bootstrap: (options?: import("./shared").BoostrapOptions) => void; | ||
declare const addFrame: (canvas: HTMLCanvasElement) => Promise<void>; | ||
declare const resetBundle: () => void; | ||
declare const downloadBundle: () => Promise<void>; | ||
declare const getBundle: () => JSZip; | ||
export default recorder; | ||
export { getCanvas, getContext, options, start, stop, cleanup, reset, draw, setup, bootstrap }; | ||
export { getCanvas, getContext, options, start, stop, cleanup, reset, draw, setup, bootstrap, addFrame, resetBundle, downloadBundle, getBundle, JSZip, }; |
23
gl.js
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const jszip_1 = __importDefault(require("jszip")); | ||
exports.JSZip = jszip_1.default; | ||
const lodash_1 = require("lodash"); | ||
@@ -11,3 +16,4 @@ const shared_1 = require("./shared"); | ||
const canvas = document.createElement("canvas"); | ||
const context = (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")); | ||
const context = (canvas.getContext("webgl") || | ||
canvas.getContext("experimental-webgl")); | ||
super(canvas, context); | ||
@@ -25,3 +31,4 @@ } | ||
this.canvas = canvas; | ||
this.context = (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")); | ||
this.context = (canvas.getContext("webgl") || | ||
canvas.getContext("experimental-webgl")); | ||
} | ||
@@ -42,2 +49,6 @@ } | ||
"bootstrap", | ||
"addFrame", | ||
"resetBundle", | ||
"downloadBundle", | ||
"getBundle", | ||
]); | ||
@@ -64,2 +75,10 @@ const getCanvas = exports.recorder.getCanvas; | ||
exports.bootstrap = bootstrap; | ||
const addFrame = exports.recorder.addFrame; | ||
exports.addFrame = addFrame; | ||
const resetBundle = exports.recorder.resetBundle; | ||
exports.resetBundle = resetBundle; | ||
const downloadBundle = exports.recorder.downloadBundle; | ||
exports.downloadBundle = downloadBundle; | ||
const getBundle = exports.recorder.getBundle; | ||
exports.getBundle = getBundle; | ||
exports.default = exports.recorder; |
import JSZip from "jszip"; | ||
import { BaseRecorder, DrawOptions, Settings } from "./shared"; | ||
export { Settings, DrawOptions }; | ||
export declare class Recorder extends BaseRecorder<CanvasRenderingContext2D> { | ||
@@ -9,10 +8,2 @@ constructor(); | ||
} | ||
export declare function addFrame(canvas: HTMLCanvasElement): Promise<void>; | ||
export declare function getBundle(): JSZip; | ||
export declare function resetBundle(): void; | ||
/** | ||
* Download the current bundle of frames. This will also reset the bundle to a new empty one. | ||
* All further frames will not be included but can be downloaded subsequently. | ||
*/ | ||
export declare function downloadBundle(): Promise<void>; | ||
declare const recorder: Recorder; | ||
@@ -27,5 +18,9 @@ declare const getCanvas: () => HTMLCanvasElement; | ||
declare const draw: (action: (context: CanvasRenderingContext2D, time: number, t: number) => void) => void; | ||
declare const bootstrap: (options?: import("../../../../../Users/roboshoes/Projects/canvas-recorder/src/shared").BoostrapOptions) => void; | ||
declare const bootstrap: (options?: import("./shared").BoostrapOptions) => void; | ||
declare const setup: (action: (context: CanvasRenderingContext2D) => void) => void; | ||
declare const addFrame: (canvas: HTMLCanvasElement) => Promise<void>; | ||
declare const resetBundle: () => void; | ||
declare const downloadBundle: () => Promise<void>; | ||
declare const getBundle: () => JSZip; | ||
export default recorder; | ||
export { getCanvas, getContext, options, start, stop, cleanup, reset, draw, bootstrap, setup }; | ||
export { getCanvas, getContext, options, start, stop, cleanup, reset, draw, bootstrap, setup, addFrame, resetBundle, downloadBundle, getBundle, JSZip, Settings, DrawOptions, }; |
46
index.js
@@ -7,2 +7,3 @@ "use strict"; | ||
const jszip_1 = __importDefault(require("jszip")); | ||
exports.JSZip = jszip_1.default; | ||
const lodash_1 = require("lodash"); | ||
@@ -26,35 +27,2 @@ const shared_1 = require("./shared"); | ||
exports.Recorder = Recorder; | ||
/** | ||
* Bundle of utilities to use just the recording without any other featuers. This is usefaul | ||
* when working with a setup that is not compatible with the options/draw configuration of | ||
* canvas-recorder. | ||
*/ | ||
let bundle = new jszip_1.default(); | ||
let count = 0; | ||
function addFrame(canvas) { | ||
return shared_1.record(canvas, count++, bundle); | ||
} | ||
exports.addFrame = addFrame; | ||
function getBundle() { | ||
return bundle; | ||
} | ||
exports.getBundle = getBundle; | ||
function resetBundle() { | ||
bundle = new jszip_1.default(); | ||
count = 0; | ||
} | ||
exports.resetBundle = resetBundle; | ||
/** | ||
* Download the current bundle of frames. This will also reset the bundle to a new empty one. | ||
* All further frames will not be included but can be downloaded subsequently. | ||
*/ | ||
function downloadBundle() { | ||
return bundle.generateAsync({ type: "blob" }) | ||
.then(shared_1.download) | ||
.then(() => { | ||
count = 0; | ||
bundle = new jszip_1.default(); | ||
}); | ||
} | ||
exports.downloadBundle = downloadBundle; | ||
// For ease of use we make a bound version of the recorder available. | ||
@@ -73,2 +41,6 @@ const recorder = new Recorder(); | ||
"setup", | ||
"addFrame", | ||
"resetBundle", | ||
"downloadBundle", | ||
"getBundle", | ||
]); | ||
@@ -95,2 +67,10 @@ const getCanvas = recorder.getCanvas; | ||
exports.setup = setup; | ||
const addFrame = recorder.addFrame; | ||
exports.addFrame = addFrame; | ||
const resetBundle = recorder.resetBundle; | ||
exports.resetBundle = resetBundle; | ||
const downloadBundle = recorder.downloadBundle; | ||
exports.downloadBundle = downloadBundle; | ||
const getBundle = recorder.getBundle; | ||
exports.getBundle = getBundle; | ||
exports.default = recorder; |
{ | ||
"name": "canvas-recorder", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"description": "Browserside tool to record canvas animations frame by frame.", | ||
@@ -5,0 +5,0 @@ "types": "./", |
@@ -0,0 +0,0 @@ # Canvas Recorder |
@@ -38,3 +38,3 @@ import JSZip from "jszip"; | ||
protected isLooping: boolean; | ||
protected zip?: JSZip; | ||
protected zip: JSZip; | ||
/** | ||
@@ -100,2 +100,21 @@ * State of settings currently in use. For more detail please refer to the README. | ||
bootstrap(options?: BoostrapOptions): void; | ||
/** | ||
* Adds a single frame to the current bundle. | ||
*/ | ||
addFrame(canvas: HTMLCanvasElement): Promise<void>; | ||
/** | ||
* Returns a reference to the current collection of all frames in the form of a JSZip. | ||
*/ | ||
getBundle(): JSZip; | ||
/** | ||
* Empties all frames and resets the frame count to 0. Leaves all other settings in tact. | ||
* For a more comprehensive reset use the `reset()` method as it reestablishes the default | ||
* mode of the recorder. | ||
*/ | ||
resetBundle(): void; | ||
/** | ||
* Download the current bundle of frames. This will also reset the bundle to a new empty one. | ||
* All further frames will not be included but can be downloaded subsequently. | ||
*/ | ||
downloadBundle(): Promise<void>; | ||
protected abstract clear(): void; | ||
@@ -102,0 +121,0 @@ protected abstract updateCanvas(canvas: HTMLCanvasElement): void; |
@@ -20,2 +20,3 @@ "use strict"; | ||
this.isLooping = false; | ||
this.zip = new jszip_1.default(); | ||
/** | ||
@@ -147,2 +148,35 @@ * State of settings currently in use. For more detail please refer to the README. | ||
} | ||
/** | ||
* Adds a single frame to the current bundle. | ||
*/ | ||
addFrame(canvas) { | ||
return record(canvas, this.count++, this.zip); | ||
} | ||
/** | ||
* Returns a reference to the current collection of all frames in the form of a JSZip. | ||
*/ | ||
getBundle() { | ||
return this.zip; | ||
} | ||
/** | ||
* Empties all frames and resets the frame count to 0. Leaves all other settings in tact. | ||
* For a more comprehensive reset use the `reset()` method as it reestablishes the default | ||
* mode of the recorder. | ||
*/ | ||
resetBundle() { | ||
this.count = 0; | ||
this.zip = new jszip_1.default(); | ||
} | ||
/** | ||
* Download the current bundle of frames. This will also reset the bundle to a new empty one. | ||
* All further frames will not be included but can be downloaded subsequently. | ||
*/ | ||
downloadBundle() { | ||
return this.zip.generateAsync({ type: "blob" }) | ||
.then(download) | ||
.then(() => { | ||
this.count = 0; | ||
this.zip = new jszip_1.default(); | ||
}); | ||
} | ||
init() { | ||
@@ -149,0 +183,0 @@ this.canvas.width = this.settings.size[0]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37890
682