starting canvas module
This commit is contained in:
parent
7ccbdac37b
commit
e6d46b593b
5 changed files with 67 additions and 2 deletions
28
app/view/canvas.js
Normal file
28
app/view/canvas.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
let EventEmitter = require('events').EventEmitter
|
||||
|
||||
class Canvas extends EventEmitter {
|
||||
|
||||
constructor (options) {
|
||||
super()
|
||||
|
||||
this.options = Object.assign({
|
||||
// fitWidth, fitWindow, manua
|
||||
zoomMode: 'fitWidth',
|
||||
// ltr, rtl
|
||||
readDirection: 'ltr'
|
||||
}, options)
|
||||
|
||||
this.canvas = document.createElement('canvas')
|
||||
this.context = this.canvas.getContext('2d')
|
||||
}
|
||||
|
||||
draw (image, doublePage, image2) {
|
||||
if (!(image instanceof window.Image) || (doublePage && !(image2 instanceof window.Image))) {
|
||||
throw new Error('Invalid image')
|
||||
}
|
||||
|
||||
this.emit('draw')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Canvas
|
Loading…
Add table
Add a link
Reference in a new issue