PHP Classes

File: toastui/src/js/component/freeDrawing.js

Recommend this page to a friend!
  Classes of Mark de Leon   PHP Document Scanner using SANE or eSCL AirPrint   toastui/src/js/component/freeDrawing.js   Download  
File: toastui/src/js/component/freeDrawing.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Document Scanner using SANE or eSCL AirPrint
Web interface to scan printed documents
Author: By
Last change:
Date: 4 years ago
Size: 1,686 bytes
 

Contents

Class file image Download
/** * @author NHN Ent. FE Development Team <dl_javascript@nhn.com> * @fileoverview Free drawing module, Set brush */ import fabric from 'fabric/dist/fabric.require'; import Component from '../interface/component'; import consts from '../consts'; /** * FreeDrawing * @class FreeDrawing * @param {Graphics} graphics - Graphics instance * @extends {Component} * @ignore */ class FreeDrawing extends Component { constructor(graphics) { super(consts.componentNames.FREE_DRAWING, graphics); /** * Brush width * @type {number} */ this.width = 12; /** * fabric.Color instance for brush color * @type {fabric.Color} */ this.oColor = new fabric.Color('rgba(0, 0, 0, 0.5)'); } /** * Start free drawing mode * @param {{width: ?number, color: ?string}} [setting] - Brush width & color */ start(setting) { const canvas = this.getCanvas(); canvas.isDrawingMode = true; this.setBrush(setting); } /** * Set brush * @param {{width: ?number, color: ?string}} [setting] - Brush width & color */ setBrush(setting) { const brush = this.getCanvas().freeDrawingBrush; setting = setting || {}; this.width = setting.width || this.width; if (setting.color) { this.oColor = new fabric.Color(setting.color); } brush.width = this.width; brush.color = this.oColor.toRgba(); } /** * End free drawing mode */ end() { const canvas = this.getCanvas(); canvas.isDrawingMode = false; } } module.exports = FreeDrawing;