0

I have a certain amount of squares with the width and height of 40, Is there any way to fit them "perfectly" into an image generated with node-canvas without the image being too big or too small? Also making the image size balanced so that there is not too much squares on the width or too much on the height.

Here is what I have tried:

let b = ((accent.length + other.length + 1) * 40); // the amount of squares * 40 (width/height)
let canvas = new Canvas(b, b);

and:

let b = ((accent.length + other.length + 1) * 40) / 2; // the amount of squares * 40 (width/height)
let canvas = new Canvas(b, b);

But that either just makes the image too big or too small.

xBeastMode
  • 29
  • 1
  • 7
  • Why are you doing `+ 1` to the number of squares you have? Won't this always make the canvas one square too big? To me the first attempt looks correct if you remove the `+ 1`. – Ankh Aug 30 '18 at 14:47
  • That `+ 1` is another square being filled in as well, I don't know if I should really remove it. – xBeastMode Aug 30 '18 at 14:50

0 Answers0