From f3a415e690e024b8433e26af87a2ebdbddf057e0 Mon Sep 17 00:00:00 2001 From: Vishesh Yadav Date: Sat, 2 May 2015 14:10:01 -0400 Subject: [PATCH] Add color argument to makeSceneImage() function --- whalesong/image/private/js-impl.js | 38 +++++++++++++++++------------- whalesong/image/private/kernel.js | 6 ++--- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/whalesong/image/private/js-impl.js b/whalesong/image/private/js-impl.js index 0c9a1e9..18c3099 100644 --- a/whalesong/image/private/js-impl.js +++ b/whalesong/image/private/js-impl.js @@ -689,7 +689,7 @@ EXPORTS['empty-scene'] = var height = checkNonNegativeReal(MACHINE, 'empty-scene', 1); var color = (MACHINE.a===3)? checkColor(MACHINE, 'empty-scene', 2) : null; - return new SceneImage(jsnums.toFixnum(width), + return makeSceneImage(jsnums.toFixnum(width), jsnums.toFixnum(height), color, [], @@ -708,10 +708,11 @@ EXPORTS['put-image'] = if (isScene(background)) { return background.add(picture, jsnums.toFixnum(x), background.getHeight() - jsnums.toFixnum(y)); } else { - var newScene = makeSceneImage(background.getWidth(), - background.getHeight(), - [], - false); + var newScene = makeSceneImage(background.getWidth(), + background.getHeight(), + null, + [], + false); newScene = newScene.add(background, background.getWidth()/2, background.getHeight()/2); newScene = newScene.add(picture, jsnums.toFixnum(x), background.getHeight() - jsnums.toFixnum(y)); return newScene; @@ -732,10 +733,11 @@ EXPORTS['place-image'] = if (isScene(background)) { return background.add(picture, jsnums.toFixnum(x), jsnums.toFixnum(y)); } else { - var newScene = makeSceneImage(background.getWidth(), - background.getHeight(), - [], - false); + var newScene = makeSceneImage(background.getWidth(), + background.getHeight(), + null, + [], + false); newScene = newScene.add(background, background.getWidth()/2, background.getHeight()/2); newScene = newScene.add(picture, jsnums.toFixnum(x), jsnums.toFixnum(y)); return newScene; @@ -766,10 +768,11 @@ EXPORTS['place-image/align'] = if (isScene(background)) { return background.add(img, jsnums.toFixnum(x), jsnums.toFixnum(y)); } else { - var newScene = makeSceneImage(background.getWidth(), - background.getHeight(), - [], - false); + var newScene = makeSceneImage(background.getWidth(), + background.getHeight(), + null, + [], + false); newScene = newScene.add(background, background.getWidth()/2, background.getHeight()/2); newScene = newScene.add(img, jsnums.toFixnum(x), jsnums.toFixnum(y)); return newScene; @@ -921,10 +924,11 @@ EXPORTS['scene+line'] = var y2 = checkReal(MACHINE, "scene+line", 4); var c = checkColor(MACHINE, "scene+line", 5); // make a scene containing the image - var newScene = makeSceneImage(jsnums.toFixnum(img.getWidth()), - jsnums.toFixnum(img.getHeight()), - [], - false); + var newScene = makeSceneImage(jsnums.toFixnum(img.getWidth()), + jsnums.toFixnum(img.getHeight()), + null, + [], + false); newScene = newScene.add(img, img.getWidth()/2, img.getHeight()/2); // make an image containing the line var line = makeLineImage(jsnums.toFixnum(x2-x1), diff --git a/whalesong/image/private/kernel.js b/whalesong/image/private/kernel.js index 03cda2c..b5d1806 100644 --- a/whalesong/image/private/kernel.js +++ b/whalesong/image/private/kernel.js @@ -288,7 +288,7 @@ var isScene = function(x) { ////////////////////////////////////////////////////////////////////// -// SceneImage: primitive-number primitive-number color (listof image) -> Scene +// SceneImage: primitive-number primitive-number color (listof image) boolean -> Scene var SceneImage = function(width, height, color, children, withBorder) { BaseImage.call(this); this.width = width; @@ -1311,8 +1311,8 @@ var colorListToImage = function(listOfColors, -var makeSceneImage = function(width, height, children, withBorder) { - return new SceneImage(width, height, null, children, withBorder); +var makeSceneImage = function(width, height, color, children, withBorder) { + return new SceneImage(width, height, color, children, withBorder); }; var makeCircleImage = function(radius, style, color) { return new EllipseImage(2*radius, 2*radius, style, color);