espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.76k stars 741 forks source link

Graphics.createImage : Same result with different strings #2296

Closed rchateauneu closed 1 year ago

rchateauneu commented 1 year ago

These two calls to Graphics.createImage create the same ArrayBuffer:

var img = Graphics.createImage(`

 1

 1

`);
={ width: 2, height: 3,  buffer: "\4" }

var img = Graphics.createImage(`

 1

`);
={ width: 2, height: 1,  buffer: "\4" }

On top of this, it would be very convenient to, optionaly, not eliminate empty lines at the beginning and end of the input buffer : It is convenient to set the total size of the image, even of the borders are set to zero.

gfwilliams commented 1 year ago

Sorry for the delay - just fixed this.

The idea was that you could use empty lines at the beginning and end... It would discount just the first and last newline in the image, not other empty lines (so it was just a bit broken).

In your examples above it'd give you a 2x6 image in each case.