starting canvas module

This commit is contained in:
Bala Clark 2015-07-16 10:29:33 +02:00
parent 7ccbdac37b
commit e6d46b593b
5 changed files with 67 additions and 2 deletions

28
app/view/canvas.js Normal file
View 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