mirror of
https://github.com/alibaba/GCanvas.git
synced 2025-12-08 17:36:42 +00:00
35 lines
999 B
JavaScript
35 lines
999 B
JavaScript
/**
|
|
* Created by G-Canvas Open Source Team.
|
|
* Copyright (c) 2017, Alibaba, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the Apache Licence 2.0.
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file in the root directory of this source tree.
|
|
*/
|
|
const { createCanvas ,Image, createImage} = require('bindings')('canvas');
|
|
const { PNGStream } = require("./stream/pngstream");
|
|
const { JPGStream } = require('./stream/jpgstream')
|
|
module.exports = {
|
|
createCanvas: createCanvasInner,
|
|
Image: createImage,
|
|
}
|
|
function createCanvasInner(width, height) {
|
|
let canvas = createCanvas(width, height);
|
|
Object.defineProperty(canvas, 'createPNGStream', {
|
|
value: function (options) {
|
|
return new PNGStream(canvas, options);
|
|
}
|
|
})
|
|
Object.defineProperty(canvas, 'createJPEGStream', {
|
|
value: function (options) {
|
|
return new JPGStream(canvas, options);
|
|
}
|
|
})
|
|
return canvas;
|
|
}
|
|
|
|
|
|
|
|
|
|
|