import * as Vue from 'vue' ; import { warn } from './utils' ; export class Renderer { constructor ( private ctx ) { } clear ( ) { const { width , height } = this . ctx . canvas ; this . ctx . clearRect ( 0 , 0 , width , height ) ; } render ( vm ) { const options = vm . $options . canvas ! ; if ( process . env . NODE_ENV !== 'production' ) { if ( ! options ) { warn ( 'canvas options must be defined for descendants of context ' + `<${ vm . _componentTag }>` ) ; return ; } } this . ctx . save ( ) ; if ( typeof options . applyDrawingState === 'function' ) { options . applyDrawingState . call ( vm , this . ctx ) ; } if ( typeof options . render === 'function' ) { options . render . call ( vm , this . ctx ) ; } vm . $children . forEach ( child => this . render ( child ) ) ; this . ctx . restore ( ) ; } }