From a68e6bedad9568e402df71bebddef3ca19250232 Mon Sep 17 00:00:00 2001 From: Michael Aschauer Date: Wed, 24 Oct 2018 10:31:05 +0200 Subject: [PATCH] add Pi reporter --- stitchcode/objects.js | 12 +++++++++--- stitchcode/threads.js | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/stitchcode/objects.js b/stitchcode/objects.js index 9ebbe471..4fa5bcf4 100644 --- a/stitchcode/objects.js +++ b/stitchcode/objects.js @@ -1135,7 +1135,7 @@ StageMorph.prototype.initCamera = function () { var width = Math.max(myself.width(), 480), height = Math.max(myself.height(), 360); - this.zoomFactor = Math.max(width / distance, height / distance) * 0.95; + this.zoomFactor = Math.min(width / distance, height / distance) * 0.90; this.applyZoom(); this.position.set(center.x, center.y, 10); @@ -1613,8 +1613,13 @@ SpriteMorph.prototype.initBlocks = function () { type: 'command', spec: 'zoom to fit', category: 'sensing' - }; - + }; + + this.blocks.reportPi = { + type: 'reporter', + category: 'operators', + spec: 'PI', + }; }; SpriteMorph.prototype.initBlocks(); @@ -1987,6 +1992,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(block('reportModulus')); blocks.push(block('reportRound')); blocks.push(block('reportMonadic')); + blocks.push(block('reportPi')); blocks.push(block('reportRandom')); blocks.push('-'); blocks.push(block('reportLessThan')); diff --git a/stitchcode/threads.js b/stitchcode/threads.js index a67b12ed..7fea8f4e 100644 --- a/stitchcode/threads.js +++ b/stitchcode/threads.js @@ -34,3 +34,8 @@ Process.prototype.zoomToFit = function() { stage.camera.fitScene(); } } + +Process.prototype.reportPi = function (min, max) { + return Math.PI; +}; +