From 7263750b3db6248e6e384331d642e38c68bc0274 Mon Sep 17 00:00:00 2001 From: ghaiklor Date: Mon, 28 Mar 2016 17:20:09 +0300 Subject: [PATCH] docs(animation): Update examples --- examples/advanced.js | 27 ++++++++++++++------------- examples/simple.js | 6 +++--- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/advanced.js b/examples/advanced.js index b4ea2ab..44ba85e 100644 --- a/examples/advanced.js +++ b/examples/advanced.js @@ -1,19 +1,19 @@ "use strict"; -const cursor = require('kittik-cursor').create().resetTTY().hideCursor(); +const cursor = require('kittik-cursor').create().reset().hideCursor(); const Rectangle = require('kittik-shape-rectangle'); const Slide = require('../lib/Slide'); const AVAILABLE_DIRECTIONS = ['inUp', 'inDown', 'inLeft', 'inRight']; const shapes = [ - Rectangle.create({background: 'dark_blue', x: 'left', y: 'top', text: 'Shape 1'}), - Rectangle.create({background: 'dark_blue', x: 'center', y: 'top', text: 'Shape 2'}), - Rectangle.create({background: 'dark_blue', x: 'right', y: 'top', text: 'Shape 3'}), - Rectangle.create({background: 'navy_blue', x: 'left', y: 'middle', text: 'Shape 4'}), - Rectangle.create({background: 'navy_blue', x: 'center', y: 'middle', text: 'Shape 5'}), - Rectangle.create({background: 'navy_blue', x: 'right', y: 'middle', text: 'Shape 6'}), - Rectangle.create({background: 'yellow_1', x: 'left', y: 'bottom', text: 'Shape 7'}), - Rectangle.create({background: 'yellow_1', x: 'center', y: 'bottom', text: 'Shape 8'}), - Rectangle.create({background: 'yellow_1', x: 'right', y: 'bottom', text: 'Shape 9'}) + Rectangle.create(cursor, {background: 'dark_blue', x: 'left', y: 'top', text: 'Shape 1'}), + Rectangle.create(cursor, {background: 'dark_blue', x: 'center', y: 'top', text: 'Shape 2'}), + Rectangle.create(cursor, {background: 'dark_blue', x: 'right', y: 'top', text: 'Shape 3'}), + Rectangle.create(cursor, {background: 'navy_blue', x: 'left', y: 'middle', text: 'Shape 4'}), + Rectangle.create(cursor, {background: 'navy_blue', x: 'center', y: 'middle', text: 'Shape 5'}), + Rectangle.create(cursor, {background: 'navy_blue', x: 'right', y: 'middle', text: 'Shape 6'}), + Rectangle.create(cursor, {background: 'yellow', x: 'left', y: 'bottom', text: 'Shape 7'}), + Rectangle.create(cursor, {background: 'yellow', x: 'center', y: 'bottom', text: 'Shape 8'}), + Rectangle.create(cursor, {background: 'yellow', x: 'right', y: 'bottom', text: 'Shape 9'}) ]; // It's implemented in Kittik engine, so you need just to implement child class from Animation as above @@ -21,9 +21,10 @@ let renderedShapes = []; let currentShapeIndex = 0; const onTick = (shape, property, value) => { - renderedShapes.forEach(shape => shape.render(cursor)); - shape.render(cursor); - cursor.flush().eraseScreen(); + cursor.eraseScreen(); + renderedShapes.forEach(shape => shape.render()); + shape.render(); + cursor.flush(); }; const nextShape = shape => { diff --git a/examples/simple.js b/examples/simple.js index 92ee6de..3bb5fd7 100644 --- a/examples/simple.js +++ b/examples/simple.js @@ -1,8 +1,8 @@ "use strict"; -const cursor = require('kittik-cursor').create().resetTTY().hideCursor(); +const cursor = require('kittik-cursor').create().reset().hideCursor(); const Slide = require('../lib/Slide'); -const shape = require('kittik-shape-rectangle').create({ +const shape = require('kittik-shape-rectangle').create(cursor, { text: 'Good news, everybody!', x: 'center', background: 'white', @@ -10,4 +10,4 @@ const shape = require('kittik-shape-rectangle').create({ width: '50%' }); -new Slide({duration: 3000}).on('tick', shape => shape.render(cursor) && cursor.flush().eraseScreen()).animate(shape).then(() => cursor.showCursor().flush()); +new Slide({duration: 3000}).on('tick', shape => cursor.eraseScreen() && shape.render() && cursor.flush()).animate(shape).then(() => cursor.showCursor());