minBlock.js icon indicating copy to clipboard operation
minBlock.js copied to clipboard

Bug: Problem if the canvas size and the number of blocks per edge are NOT divisible without remainder.

Open ndsvw opened this issue 6 years ago • 2 comments

If the canvas size and the blocks per edge are divisible without remainder, everything works fine:

Example: canvas height and width: 500 blocks per edge: 5

download1

But there is a problem in the code in regards to odd numbers existing since 2015 when it was created.

If the canvas size and the number of blocks per edge are NOT divisible without remainder, the blocks getting drawn on the canvas can have ugly spaces/lines between each other.

Example: canvas height and width: 541 blocks per edge: 7

download2

closer look: bildschirmfoto 2019-02-18 um 23 29 05

This problem exists in Firefox, Safari and Chromium-based browsers (and probably in every other browser).

ndsvw avatar Feb 18 '19 22:02 ndsvw

It seems that it's not so easy to solve this.

The question: Should this "problem" be solved or should there just be a recommendation like:

Try to use even canvas sizes only (100px, 200px, 500px...)! The canvas size should also be divisible without remainder by the number of blocks per edge.

bad:

  • canvas size: 100
  • blocks per edge: 7 bad because 100 / 7 = 14.2857142857

good:

  • canvas size: 105
  • blocks per edge: 7 good because 105 / 7 = 15

I can maybe solve this with an (ugly) workaround (if two 100x100 rectangles would be next to each other, then a 200x100 rectangle is drawn instead of two, if three of them would be next to each other, a 300x100 rectangle is drawn...), but I don't know if that's a nice solution.

ndsvw avatar Feb 26 '19 17:02 ndsvw

Give me little bit time. Let's solve this.

flouthoc avatar Feb 27 '19 12:02 flouthoc