Skip to content

Commit 69b15d7

Browse files
committed
Fix bug, adding default value to inputs
1 parent 5d34c06 commit 69b15d7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

ShapeAlgorithm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ class ShapeAlgorithm {
8888
calculate() {
8989
// colorize all possible this.biggest_box.w * this.biggest_box.h items iterate
9090
for (let i = 0; i < this.matrix.length; i += this.biggest_box.h) {
91-
for (let j = 0; j < this.matrix[i].length; j += this.biggest_box.w) {
92-
if (j >= this.window.w || i >= this.window.h || j+this.biggest_box.w >= this.window.w || i+this.biggest_box.h >= this.window.h) break;
91+
for (let j = 0; j < this.matrix[0].length; j += this.biggest_box.w) {
92+
if (j > this.window.w || i > this.window.h || j + this.biggest_box.w > this.window.w || i + this.biggest_box.h > this.window.h) break;
9393

9494
this.labels[`${this.biggest_box.w}_${this.biggest_box.h}`] = 1;
9595

demo.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ <h1>Shapes Algorithm</h1>
1414
<p>Enter numbers to see the result.</p>
1515

1616
<label>Width of the main window:</label>
17-
<input id="window_width" type="number" pattern="[0-9]+">
17+
<input id="window_width" type="number" pattern="[0-9]+" value="10">
1818
<br>
1919

2020
<label>Height of the main window:</label>
21-
<input id="window_height" type="number" pattern="[0-9]+">
21+
<input id="window_height" type="number" pattern="[0-9]+" value="10">
2222
<br>
2323

2424
<label>Width of biggest box:</label>
25-
<input id="biggest_box_width" type="number" pattern="[0-9]+">
25+
<input id="biggest_box_width" type="number" pattern="[0-9]+" value="2">
2626
<br>
2727

2828
<label>Height of biggest box:</label>
29-
<input id="biggest_box_height" type="number" pattern="[0-9]+">
29+
<input id="biggest_box_height" type="number" pattern="[0-9]+" value="5">
3030
<br>
3131

3232
<button id="button">Preview</button>

0 commit comments

Comments
 (0)