comic-bubbles
Version:
Animated comic bubbles - what else?
40 lines (33 loc) • 1.28 kB
JavaScript
import { AnimationContainer } from './animationContainer.mjs'
import { BubbleContainer } from './bubbleContainer.mjs'
import { Bounds } from './bounds.mjs'
export class Scene {
constructor(sceneId, parent) {
this.canvas = document.getElementById(sceneId)
this.canvas.width = 0
this.canvas.height = 0
this.aniCon = new AnimationContainer(this)
this.bubCon = new BubbleContainer(this)
this.bounds = new Bounds(this)
this.parent = parent
}
ctx() {
return this.canvas.getContext('2d')
}
getPrefStr() {
return this.parent === undefined ? 'scene' : this.parent.getPrefStr() + '.scene'
}
calcBounds() {
// aniCon.bounds.width must be in JSON file!!!
this.aniCon.bounds.height = this.bounds.height - this.aniCon.margin.top - this.aniCon.margin.bottom
this.aniCon.bounds.x = this.bounds.x + this.aniCon.margin.left
this.aniCon.bounds.y = this.bounds.y + this.aniCon.margin.top
this.canvas.width = this.bounds.width
this.canvas.height = this.bounds.height
this.ctx().width = this.bounds.width
this.ctx().height = this.bounds.height
/* this.ctx().fillStyle = 'blue'
this.ctx().fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height) */
this.aniCon.calcBounds()
}
}