UNPKG

matting-editor

Version:

matting-editor

171 lines (156 loc) 4.55 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios); var _bluebird = require('bluebird'); var _bluebird2 = _interopRequireDefault(_bluebird); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = { version: '0.2.4', options: { maxImageHeight: 1000, maxImageWidth: 1000, maxFileSize: 9 * 1024 * 1024, canvasBackgroundColor: '#e6e6e6', brushColorsMap: { keep: '#196cfa', drop: '#f73d64' }, swatches: [{ value: null, text: '透明' }, { value: '#000000', text: '黑色' }, { value: '#666666', text: '灰色' }, { value: '#ffffff', text: '白色' }, { value: '#d8090b', text: '红色' }, { value: '#01a1ff', text: '蓝色' }], defaultTool: 'keep', loadingDelay: 500, showToolbar: true, guiderable: true, popperGuiderable: true, enableHelp: false, api: { mattingPath: 'http://www.dev.gaoding.com/api/mattings', timeout: 21000, options: {} }, uploadImage: function uploadImage(imageBlob) { return { url: URL.createObjectURL(imageBlob) }; }, mattingImage: function mattingImage(matting) { var apiUrl = '/api/mattings/' + matting.id + '/images'; return _axios2.default.post(apiUrl, { content: matting.content }).then(function (res) { return res.data; }); }, saveMatting: function saveMatting(matting) { return _bluebird2.default.try(function () { if (matting.id) { if (matting.$update) { return matting.$update(); } return _axios2.default.put('/api/mattings/' + matting.id, matting); } if (matting.$save) { return matting.$save(); } return _axios2.default.post('/api/mattings', matting); }).then(function (res) { return res.data || res; }); } }, toolbar: [{ className: 'matting-tools-undo', type: 'button', name: 'undo', text: '撤销', disabled: function disabled(matting) { return matting.snapshot.currentIndex <= 0; }, handler: function handler(matting) { matting.undo(); } }, { className: 'matting-tools-redo', type: 'button', name: 'redo', text: '重做', disabled: function disabled(matting) { var snapshot = matting.snapshot; return snapshot.currentIndex >= snapshot.size - 1; }, handler: function handler(matting) { matting.redo(); } }, { type: 'pipe', name: 'pipe' }, { className: 'matting-tools-zoomin', type: 'button', name: 'zoomIn', text: '放大', handler: function handler(matting) { matting.zoomIn(); } }, { className: 'matting-tools-zoomout', type: 'button', name: 'zoomOut', text: '缩小', handler: function handler(matting) { matting.zoomOut(); } }, { className: 'matting-tools-zoomfull', type: 'button', name: 'fitZoom', text: '适应画布', hide: function hide(matting) { return matting.zoom !== 1; }, handler: function handler(matting) { matting.fitZoom(); } }, { className: 'matting-tools-zoomoff', type: 'button', name: 'oriZoom', text: '实际大小', hide: function hide(matting) { return matting.zoom === 1; }, handler: function handler(matting) { matting.setZoom(1); } }], supportExportImageExt: ['png', 'jpeg', 'jpg'], defaultMattingData: { sourceImage: '', imageHeight: 0, imageWidth: 0, backgroundColor: null, featheringRadius: 0, brushSize: 30, lines: [] } };