mir3z / aalib.js

ASCII art library in JavaScript
http://mir3z.github.io/aalib.js
MIT License
188 stars 20 forks source link

script wont work if using charset in renderer #7

Open carljustineoyales opened 4 years ago

carljustineoyales commented 4 years ago

I'm using vuejs in this code but by following the api that is listed it should work.

const img = document.getElementById("img");

    aalib.read.image
      .fromHTMLImage(img)

      .map(aalib.aa({ width: 100, height: 50 }))
      .map(aalib.filter.inverse())
      .map(
        aalib.render.canvas({
          el: document.getElementById("el"),
          width: 400,
          height: 330,
          charset:['x']
        })
      )
      .subscribe();

But when adding the charset property the output will be like this

image

Did i miss a step or something in the documentation?

niemes commented 3 days ago

Charset take an array of strings (chars) as input. The list of character will be assigned to a level of brightness. So using only one character makes everything the same.

In the direction bright → Dark.

Like so :

[...]
.map(aalib.render.html({
        el: asciiArtElement,
        width: 130,
        height: 60,
        charset: [
          ' ','*','`','.',' ','_','.','/','|','O','#','s','m'
          ]
        })
      )
[...]