Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stipple doesn't seem to be supported in non-cli version #23

Closed
brubsby opened this issue Jan 21, 2021 · 6 comments
Closed

stipple doesn't seem to be supported in non-cli version #23

brubsby opened this issue Jan 21, 2021 · 6 comments

Comments

@brubsby
Copy link

brubsby commented Jan 21, 2021

so i have the call to ascii-art:

art.image({
            stippled: true,
            filepath: file,
            threshold: 128,
            width: 32,
            height: 32
          });

and when the art is logged to the console it appears like this:
image

and when i save to a file it gets rendered in notepad++ as:
image

i'm basically trying to put some stippled ascii art in a subtitle file, fwiw.

windows 10, most recent version of ascii-art on npm.

@khrome
Copy link
Owner

khrome commented Feb 1, 2021

notepad does not support ansi coloring. NFO readers will, however.

@brubsby
Copy link
Author

brubsby commented Feb 1, 2021

the colors are cool, but for my current project I am just regex removing them, so that doesn't concern me as much. (and a flag to do no ansi colors would be nice as well)

i'm mostly confused as to why it doesn't seem to use braille with these input settings. to work around it i reverse engineered that i needed these settings:

art.image({
  posterize: true,
  stippled: true,
  background: true,
  filepath: file,
  threshold: 96,
  width: 32,
  height: 32
});

seems like just stippled: true should work

@khrome
Copy link
Owner

khrome commented Feb 1, 2021

posterize is a special setting which outputs the color to the background and outputs braille characters to get sub-character value accuracy via braille pixels along with full flood coloring. So stippling is already happening, but in black. If I allowed default mode stippling on top of that you'd be setting foreground and background to the same color.

What is the end output effect you want?

Also almost every language has a consise strip-ansi module available. I have recommended this module in the past for a non-ansi mode. Presently all the pixel calculations are done in color and palette reduction logic is expensive... It would be much cheaper to do this in 256 level grey (or thresholded to 2 color).

There are no docs, but you can directly access the braille output here: https://github.com/khrome/ascii-art-braille/blob/master/braille.js

There is also another slightly less detailed sub-character mode, blocks, which may have slightly better support in text editors

@khrome
Copy link
Owner

khrome commented Mar 30, 2021

Doing some work this week. Is there a feature you wanted out of this other than being able to strip ansi chars?

@khrome
Copy link
Owner

khrome commented Apr 15, 2021

So after enabling ansi stripping, I finally get what the issue is in the OP. So I fixed the issue and here are some examples of the expected behavior from the upcoming changes (2.6)

art.image({
    filepath: './node_modules/ascii-art-docs/Images/animal_muppet.jpg',
    width: 32,
    height: 32
}, function(err, result){
    console.log(result);
});

Screen Shot 2021-04-15 at 2 07 12 PM

art.image({
    filepath: './node_modules/ascii-art-docs/Images/animal_muppet.jpg',
    width: 32,
    height: 32
}).strip({}, function(err, result){
    console.log(result);
});

Screen Shot 2021-04-15 at 2 08 39 PM

art.image({
    stippled: true,
    filepath: './node_modules/ascii-art-docs/Images/animal_muppet.jpg',
    threshold : 128,
    width: 32,
    height: 32
}, function(err, result){
    console.log(result);
});

Screen Shot 2021-04-15 at 2 31 29 PM

art.image({
    posterized: true,
    stippled: 'black',
    lineart: true,
    blended: true,
    filepath: './node_modules/ascii-art-docs/Images/animal_muppet.jpg',
    threshold : 50,
    width: 32,
    height: 32
}, function(err, result){
    console.log(result);
});

Screen Shot 2021-04-15 at 3 21 10 PM

art.image({
    posterized: true,
    stippled: 'black',
    filepath: './node_modules/ascii-art-docs/Images/animal_muppet.jpg',
    threshold : 20,
    width: 32,
    height: 32
}, function(err, result){
    console.log(result);
});

Screen Shot 2021-04-15 at 3 24 22 PM

These are all slightly different in function. Thanks for catching the defect!

@khrome
Copy link
Owner

khrome commented Apr 15, 2021

Changes are live.

@khrome khrome closed this as completed Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants