From 1a8a200d1a16132b92a2d72d6e7f897bd35acb42 Mon Sep 17 00:00:00 2001 From: Dipansh Khandelwal Date: Thu, 28 Dec 2017 11:12:54 +0530 Subject: [PATCH] Resolved random shapes After the fixed number of shapes it will now randomly generate the shapes --- js/activity.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/js/activity.js b/js/activity.js index 8d55e43..41eb51a 100644 --- a/js/activity.js +++ b/js/activity.js @@ -225,17 +225,14 @@ define(function (require) { } function new_positions() { - if (shape >= shapes.length) { - shape = 0; - } for (i = 0; i < bitmaps.length; i++) { + var fontSize = 6; + var ovrhdX = i.toString().length * fontSize; + var ovrhdY = fontSize + 4; if (shape < shapes.length) { if (i < shapes[shape].length) { var shapeX = shapes[shape][i][0]; var shapeY = shapes[shape][i][1]; - var fontSize = 6; - var ovrhdX = i.toString().length * fontSize; - var ovrhdY = fontSize + 4; bitmaps[i].x = shapeX; bitmaps[i].y = shapeY; bitmapLabels[i].x = shapeX - ovrhdX; @@ -252,8 +249,8 @@ define(function (require) { else { bitmaps[i].x = canvas.width * Math.random() | 0; bitmaps[i].y = canvas.height * Math.random() | 0; - bitmapLabels[i].x = canvas.width * Math.random() | 0; - bitmapLabels[i].y = canvas.height * Math.random() | 0; + bitmapLabels[i].x = bitmaps[i].x - ovrhdX; + bitmapLabels[i].y = bitmaps[i].y - ovrhdY; } } pen_bitmap.x = bitmaps[0].x;