diff --git a/app/canvas.js b/app/canvas.js index 80dc4b7..9ba289b 100644 --- a/app/canvas.js +++ b/app/canvas.js @@ -2,7 +2,6 @@ 'use strict'; - let Canvas = function(container, width, height) { this.container = container; @@ -30,7 +29,7 @@ }; - Canvas.prototype.showImage = function(name) { + Canvas.prototype.drawImage = function(name) { if (!(name in this.images)) { throw new Error('image ' + name + ' unknown'); diff --git a/app/director.js b/app/director.js new file mode 100644 index 0000000..9a49484 --- /dev/null +++ b/app/director.js @@ -0,0 +1,24 @@ +(function() { + + 'use strict'; + + const Scene = require('./scene'); + + let Director = function(script, canvas) { + + this.script = script; + this.canvas = canvas; + + }; + + Director.prototype.begin = function() { + + let scene = new Scene(this.script.scenes.vaginal, this.canvas); + + scene.play(); + + }; + + module.exports = Director; + +})(); \ No newline at end of file diff --git a/app/index.js b/app/index.js index e44dff8..d461629 100644 --- a/app/index.js +++ b/app/index.js @@ -4,11 +4,14 @@ require('../assets/style.css'); - const scenes = require('./scenes.json'); + const script = require('./script.json'); + const Canvas = require('./canvas'); + const Director = require('./director'); let canvas = new Canvas(document.getElementById("canvasDiv"), 512, 272); + let director = new Director(script, canvas); - canvas.show('room'); + director.begin(); })(); diff --git a/app/scene.js b/app/scene.js new file mode 100644 index 0000000..0a4412d --- /dev/null +++ b/app/scene.js @@ -0,0 +1,29 @@ +(function() { + + 'use strict'; + + let Scene = function(scene, canvas) { + + this.frames = scene.frames; + this.roll = scene.roll; + this.canvas = canvas; + + }; + + Scene.prototype.drawFrame = function(frame) { + + let images = this.frames[frame]; + + images.forEach((image) => { + this.canvas.drawImage(image); + + }); + }; + + Scene.prototype.play = function() { + this.drawFrame('vaginal_initial'); + }; + + module.exports = Scene; + +})(); \ No newline at end of file diff --git a/app/scenes.json b/app/scenes.json deleted file mode 100644 index 2b6ee24..0000000 --- a/app/scenes.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "vaginal": { - "frames": [ - { - "name": "vaginal_initial", - "images": [ - "room", - "vaginal_base", - "vaginal_frame1" - ] - }, - { - "name": "vaginal_frame1", - "images": [ - "vaginal_frame1" - ] - }, - { - "name": "vaginal_frame2", - "images": [ - "vaginal_frame2" - ] - }, - { - "name": "vaginal_balloon_venho", - "images": [ - "vaginal_balloon_venho" - ] - } - ], - "scene": [ - { - "frame": "vaginal_initial", - "duration": 750 - }, - [ - { - "repeat": 19 - }, - { - "frame": "vaginal_frame1", - "duration": 750 - }, - { - "frame": "vaginal_frame2", - "duration": 750 - } - ], - { - "frame": "vaginal_balloon_venho" - }, - [ - { - "repeat": 6 - }, - { - "frame": "vaginal_frame1", - "duration": 750 - }, - { - "frame": "vaginal_frame2", - "duration": 750 - } - ], - { - "frame": "vaginal_initial", - "duration": 2500 - } - ] - } -} \ No newline at end of file diff --git a/app/script.json b/app/script.json new file mode 100644 index 0000000..aeb5498 --- /dev/null +++ b/app/script.json @@ -0,0 +1,61 @@ +{ + "scenes": { + "vaginal": { + "frames": { + "vaginal_initial": [ + "room", + "vaginal_base", + "vaginal_frame1" + ], + "vaginal_frame1": [ + "vaginal_frame1" + ], + "vaginal_frame2": [ + "vaginal_frame2" + ], + "vaginal_balloon_venho": [ + "vaginal_balloon_venho" + ] + }, + "roll": [ + { + "frame": "vaginal_initial", + "duration": 750 + }, + [ + { + "repeat": 19 + }, + { + "frame": "vaginal_frame1", + "duration": 750 + }, + { + "frame": "vaginal_frame2", + "duration": 750 + } + ], + { + "frame": "vaginal_balloon_venho" + }, + [ + { + "repeat": 6 + }, + { + "frame": "vaginal_frame1", + "duration": 750 + }, + { + "frame": "vaginal_frame2", + "duration": 750 + } + ], + { + "frame": "vaginal_initial", + "duration": 2500 + } + ] + } + } +} \ No newline at end of file