From 4b02063b5f7d02102e7ebfc9443ec374d42b07b6 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Wed, 18 Oct 2017 22:24:01 -0400 Subject: [PATCH] fix for #379: draw image file path doesn't work --- pd/nw/pdgui.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index b849fd414..76b9dc9e1 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -3533,13 +3533,18 @@ function gui_drawimage_new(obj_tag, file_path, canvasdir, flags) { } file_path = path.normalize(file_path); } - if (file_path !== "" && - fs.existsSync(file_path) && - fs.lstatSync(file_path).isDirectory()) { - files = fs.readdirSync(file_path) + if (file_path !== "" && fs.existsSync(file_path)) { + if (image_seq && fs.lstatSync(file_path).isDirectory()) { + // [draw sprite] + files = fs.readdirSync(file_path) .sort(); // Note that js's "sort" method doesn't do the // "right thing" for numbers. For that we'd need // to provide our own sorting function + } else { + // [draw image] + files = [path.basename(file_path)]; + file_path = path.dirname(file_path); + } // todo: warn about image sequence with > 999 files.forEach(function(file) { ext = path.extname(file).toLowerCase(); -- GitLab