From e7f23a391aaf04c3a362b2a12463a986e2c2263a Mon Sep 17 00:00:00 2001 From: Martijn de Boer Date: Tue, 9 Jan 2018 21:31:40 +0100 Subject: [PATCH] Abstract version of the API --- controllers/vmcontroller.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/controllers/vmcontroller.js b/controllers/vmcontroller.js index d1cc134..07e1f3a 100644 --- a/controllers/vmcontroller.js +++ b/controllers/vmcontroller.js @@ -34,8 +34,22 @@ class VMController } resetSandbox() { + let matrixSize = this.driver.getSize(); + this.sandbox = { - 'matrix': this.driver, + 'WIDTH': matrixSize.width, + 'HEIGHT': matrixSize.height, + + 'setBrightness': this.driver.setBrightness.bind( this.driver ), + 'getBrightness': this.driver.getBrightness.bind( this.driver ), + 'setPixel': this.driver.setPixel.bind( this.driver ), + 'getPixel': this.driver.getPixel.bind( this.driver ), + 'drawLine': this.driver.drawLine.bind( this.driver ), + 'drawRect': this.driver.drawRect.bind( this.driver ), + 'drawRectFilled': this.driver.drawRectFilled.bind( this.driver ), + 'drawCircle': this.driver.drawCircle.bind( this.driver ), + 'write': this.driver.write.bind( this.driver ), + 'delta': this.getDelta.bind( this ) }; }