66 * MIT Licensed
77 */
88
9- /**
10- * Module dependencies.
11- */
12-
139const bindings = require ( './bindings' )
1410const Canvas = module . exports = bindings . Canvas
1511const Context2d = require ( './context2d' )
@@ -24,15 +20,6 @@ Canvas.prototype[util.inspect.custom || 'inspect'] = function () {
2420 return `[Canvas ${ this . width } x${ this . height } ]`
2521}
2622
27- /**
28- * Get a context object.
29- *
30- * @param {String } contextType must be "2d"
31- * @param {Object {alpha: boolean, pixelFormat: PIXEL_FORMAT} } contextAttributes Optional
32- * @return {Context2d }
33- * @api public
34- */
35-
3623Canvas . prototype . getContext = function ( contextType , contextAttributes ) {
3724 if ( '2d' == contextType ) {
3825 var ctx = this . _context2d || ( this . _context2d = new Context2d ( this , contextAttributes ) ) ;
@@ -42,77 +29,21 @@ Canvas.prototype.getContext = function (contextType, contextAttributes) {
4229 }
4330} ;
4431
45- /**
46- * Create a `PNGStream` for `this` canvas.
47- *
48- * @param {Object } [options]
49- * @param {number } [options.compressionLevel] Number from 0 to 9 corresponding
50- * to the ZLIB compression level. Defaults to 6.
51- * @param {number } [options.filters] Any bitwise combination of
52- * `PNG_FILTER_NONE`, `PNG_FITLER_SUB`, `PNG_FILTER_UP`, `PNG_FILTER_AVG`,
53- * `PNG_FILTER_PATETH`; or one of `PNG_ALL_FILTERS` or `PNG_NO_FILTERS`. These
54- * specify which filters *may* be used by libpng. During encoding, libpng will
55- * select the best filter from this list of allowed filters.
56- * @param {Uint8ClampedArray } [options.palette] Provide for indexed PNG
57- * encoding. Entries should be R-G-B-A values.
58- * @param {number } [options.backgroundIndex] Optional index of background color
59- * for indexed PNGs. Defaults to 0.
60- * @return {PNGStream }
61- * @public
62- */
6332Canvas . prototype . pngStream =
6433Canvas . prototype . createPNGStream = function ( options ) {
6534 return new PNGStream ( this , options ) ;
6635} ;
6736
68- /**
69- * Create a `PDFStream` for `this` canvas.
70- *
71- * @param {object } [options]
72- * @param {string } [options.title]
73- * @param {string } [options.author]
74- * @param {string } [options.subject]
75- * @param {string } [options.keywords]
76- * @param {string } [options.creator]
77- * @param {Date } [options.creationDate]
78- * @param {Date } [options.modDate]
79- * @return {PDFStream }
80- * @public
81- */
8237Canvas . prototype . pdfStream =
8338Canvas . prototype . createPDFStream = function ( options ) {
8439 return new PDFStream ( this , options ) ;
8540} ;
8641
87- /**
88- * Create a `JPEGStream` for `this` canvas.
89- *
90- * @param {Object } [options]
91- * @param {number } [options.quality] Number from 0 to 1. Defaults to 0.75.
92- * @param {boolean|1|2 } [options.chromaSubsampling] Enables 2x2 chroma
93- * subsampling. `true` is equivalent to `2`, `false` is equivalent to `1`.
94- * @param {boolean } [options.progressive] Enables progressive encoding. Defautls
95- * to false.
96- * @return {JPEGStream }
97- * @public
98- */
9942Canvas . prototype . jpegStream =
10043Canvas . prototype . createJPEGStream = function ( options ) {
10144 return new JPEGStream ( this , options ) ;
10245} ;
10346
104- /**
105- * Returns a data URI. Pass a function for async operation (non-standard).
106- *
107- * @param {"image/png"|"image/jpeg" } [type="image/png"] Type.
108- * @param {Object|Number } [encoderOptions] A number between 0 and 1 indicating
109- * image quality if the requested type is image/jpeg (standard), or an options
110- * object for image encoding (see documentation for Canvas#toBuffer)
111- * (non-standard).
112- * @param {Function } [fn] Callback for asynchronous operation (non-standard).
113- * @return {String } data URL if synchronous (callback omitted)
114- * @api public
115- */
11647Canvas . prototype . toDataURL = function ( a1 , a2 , a3 ) {
11748 // valid arg patterns (args -> [type, opts, fn]):
11849 // [] -> ['image/png', null, null]
0 commit comments