From 89debe257703448317b909877a6b165a310d1740 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 17 Jul 2015 03:06:33 -0700 Subject: [PATCH] add more ansii image methods for animation. fix test. --- README.md | 3 +++ lib/widgets/ansiimage.js | 13 +++++++++++++ test/widget-png.js | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a16c9a5..29f9f25 100644 --- a/README.md +++ b/README.md @@ -1493,6 +1493,9 @@ installed. - __setImage(file)__ - Set the image in the box to a new path. File can be a path, url, or buffer. - __clearImage()__ - Clear the image. +- __play()__ - Play animation if it has been paused or stopped. +- __pause()__ - Pause animation. +- __stop()__ - Stop animation. #### OverlayImage (from Box) diff --git a/lib/widgets/ansiimage.js b/lib/widgets/ansiimage.js index c245d97..0d007f2 100644 --- a/lib/widgets/ansiimage.js +++ b/lib/widgets/ansiimage.js @@ -118,7 +118,20 @@ ANSIImage.prototype.setImage = function(file) { } }; +ANSIImage.prototype.play = function() { + return this.img.play(); +}; +ANSIImage.prototype.pause = function() { + return this.img.pause(); +}; +ANSIImage.prototype.stop = function() { + return this.img.stop(); +}; + ANSIImage.prototype.clearImage = function() { + if (this.img && this.img.frames) { + this.stop(); + } this.setContent(''); this.img = null; this.cellmap = null; diff --git a/test/widget-png.js b/test/widget-png.js index 3baef2b..700c505 100644 --- a/test/widget-png.js +++ b/test/widget-png.js @@ -61,7 +61,7 @@ var url = 'https://people.mozilla.org/~dolske/apng/spinfox.png'; if (!file) { try { if (!fs.existsSync(spinfox)) { - var buf = blessed.png.curl(url); + var buf = blessed.ansiimage.curl(url); fs.writeFileSync(spinfox, buf); } file = spinfox;