NOTE: Not all web browsers allow the use of a video camera (eg built into a laptop or connected via USB). This is not related to the construction of the ASCII Art library, or even with p5js, but with the browser manufacturer's treatment of security. Sometimes this is related to the operating system (eg iOS in some cases blocks access to the camera), sometimes with security settings or certificates. Some of these settings can be changed, but generally not all browsers work with cameras. Currently the best browser on macOS, Windows and Linux to test p5js sketches hosted locally or loaded from a webserver and using video camera (and the ASCII Art library) is Mozilla Firefox
The main library pseudo-class. You must create an object derived from this class to use the library. The simplest version of the constructor does not require any parameters, but you can also use one of the versions that allow you to create an object with parameters, too:
var aa = new AsciiArt();
var aa = new AsciiArt(_fontName);
var aa = new AsciiArt(_fontName, _fontSize);
var aa = new AsciiArt(_fontName, _fontSize, _textStyle);
_fontName, _fontSize, _textStyle correspond to the typical font parameters used in p5js. The given font parameters will be used to create the table that stores glyphs ordered in terms of their area - on the basis of this table, the object will convert the image pixels to the ASCII art form.
A function that converts images into ASCII graphics. It can be used in a version with one or three parameters. The function returns a two-dimensional array containing glyphs (chars).
[AsciiArt instance].convert(_img, _w, _h);
If it is used with one parameter convert(_img), the function assumes that the resolution of ASCII graphics should be equal to the resolution of the converted image. In the version with three parameters convert(_img, _w, _h), we can determine the resolution of ASCII graphics regardless of the source image resolution (usually the resolution of ASCII graphics will of course be lower than the converted image).
An auxiliary function that converts a two-dimensional array containing (implicitly) glyphs (chars) into a text string - such arrays are generated by the convert function. It can be used to export the generated ASCII art graphics.
A 2d array to convert should bepassed to the function as a parameters. The function returns String.
Boolean variable that allows to reverse the direction of assigning the lightness of pixels to the area taken by the glyphs (this can be compared to generating a negative image). Default value of the variable is false.
This method prints to the console the table that stores glyphs ordered in terms of their area.
No parameters are required.
An auxiliary function that prints the contents of a two-dimensional array on the screen. The function assumes that the array stores glifs (chars) - such arrays are generated by the convert function. Can be called in 3 variants:
[AsciiArt instance].typeArray2d(_arr2d, _dst);
[AsciiArt instance].typeArray2d(_arr2d, _dst, _x, _y);
[AsciiArt instance].typeArray2d(_arr2d, _dst, _x, _y, _w, _h);
The parameters are as follows:
_arr2d - 2-dimentional array containing glyphs (chars);
_dst - destination (typically the sketch itself);
_x, _y - coordinates of the upper left corner;
_w, _h - width and height
write to: contact | at | tetoki | dot | eu