From 7bd9e7f9a4df3c9b3f74ae045e74d75379259d98 Mon Sep 17 00:00:00 2001 From: Dipansh Khandelwal Date: Thu, 28 Dec 2017 01:56:05 +0530 Subject: [PATCH 1/5] Remove random circle placement error --- js/activity.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/activity.js b/js/activity.js index 920bfc1..cb52d37 100644 --- a/js/activity.js +++ b/js/activity.js @@ -51,7 +51,7 @@ define(function (require) { var Star = "images/star.svg"; var Dot = "images/dot.svg"; var Pen = "images/pen.svg"; - var shape = -1; + var shape = 0; // Get things started init(); @@ -225,9 +225,8 @@ define(function (require) { } function new_positions() { - if (shape == -1) { + if (shape >= 12) { shape = 0; - return; } for (i = 0; i < bitmaps.length; i++) { if (shape < shapes.length) { From e8fe1e7a60fd81b34219bc844feced779e880755 Mon Sep 17 00:00:00 2001 From: Dipansh Khandelwal Date: Thu, 28 Dec 2017 11:03:33 +0530 Subject: [PATCH 2/5] Removed hardcoded shapes data length --- js/activity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/activity.js b/js/activity.js index cb52d37..8d55e43 100644 --- a/js/activity.js +++ b/js/activity.js @@ -225,7 +225,7 @@ define(function (require) { } function new_positions() { - if (shape >= 12) { + if (shape >= shapes.length) { shape = 0; } for (i = 0; i < bitmaps.length; i++) { From 8cff64c994b795df5a0ed7c3b6dd0690d444573e Mon Sep 17 00:00:00 2001 From: Dipansh Khandelwal Date: Thu, 28 Dec 2017 11:12:54 +0530 Subject: [PATCH 3/5] 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; From d99096c2e8153bd3d0561f83189718534d5a5fa1 Mon Sep 17 00:00:00 2001 From: Dipansh Khandelwal Date: Thu, 28 Dec 2017 11:46:15 +0530 Subject: [PATCH 4/5] Remove unnecessary call to new_positions --- js/activity.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/activity.js b/js/activity.js index 41eb51a..48ceaf8 100644 --- a/js/activity.js +++ b/js/activity.js @@ -96,7 +96,6 @@ define(function (require) { // Create a drawing canvas drawingCanvas = new createjs.Shape(); stage.addChild(drawingCanvas); - new_positions(); stage.update(); } From 9d8c74b5ad6253943e17743d7f00e84ac7ebb931 Mon Sep 17 00:00:00 2001 From: James Cameron Date: Fri, 29 Dec 2017 09:00:37 +1100 Subject: [PATCH 5/5] Refactorise new_positions --- js/activity.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/js/activity.js b/js/activity.js index 48ceaf8..2595c9b 100644 --- a/js/activity.js +++ b/js/activity.js @@ -230,27 +230,20 @@ define(function (require) { 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]; - bitmaps[i].x = shapeX; - bitmaps[i].y = shapeY; - bitmapLabels[i].x = shapeX - ovrhdX; - bitmapLabels[i].y = shapeY - ovrhdY; + bitmaps[i].x = shapes[shape][i][0]; + bitmaps[i].y = shapes[shape][i][1]; } else { - var outRange = -100; - bitmaps[i].x = outRange; - bitmaps[i].y = outRange; - bitmapLabels[i].x = outRange; - bitmapLabels[i].y = outRange; + bitmaps[i].x = -100; + bitmaps[i].y = -100; } } else { bitmaps[i].x = canvas.width * Math.random() | 0; bitmaps[i].y = canvas.height * Math.random() | 0; - bitmapLabels[i].x = bitmaps[i].x - ovrhdX; - bitmapLabels[i].y = bitmaps[i].y - ovrhdY; } + bitmapLabels[i].x = bitmaps[i].x - ovrhdX; + bitmapLabels[i].y = bitmaps[i].y - ovrhdY; } pen_bitmap.x = bitmaps[0].x; pen_bitmap.y = bitmaps[0].y;