Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
victorqribeiro committed Aug 14, 2020
2 parents 9c841e2 + 5a5b54e commit ca7e181
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms


patreon: victorqribeiro

20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,37 @@

A JavaScript implementation of a image to ascii converter.

[Live example](https://victorqribeiro.github.io/imgToAscii/)

## How to use

Include the imgToAscii.js file
```
```html
<script src="src/imgToAscii.js"></script>
```
or
```
```html
<script src="https://raw.githubusercontent.com/victorqribeiro/imgToAscii/v1.3/src/imgToAscii.js"></script>

```
then just create a new imgToAscii object with the image address and optionaly the alphabet: (0 - simpler shades, 1 - more complex shades) - default is 0

```
<script>
```javascript
let ele = new imgToAscii('elefante.png');
ele.display();
</script>
```

You can also resize your image passing a second parameter between 0 and 1 as percentage. e.g.: 0.5 = 50% - Will reduce the size of your image in 50% both vertical and horizontal (width, height).

```
<script>
```javascript
let eu = new imgToAscii('eu.png',0.5);
eu.display();
</script>
```

To display the ASCII image with color just call the method displayColor(). You can set the background color of your image passing a color parameter to the method. e.g.: gray, white, black, #fff, rgb(10,10,10). Default is transparent.

```
<script>
```javascript
eu.displayColor('gray');
</script>
```

Note that on the code above the same 'eu' image was used. Once you load an image, you can display it with or without color, without the need to reload the image data.
Expand All @@ -46,7 +42,7 @@ Note that on the code above the same 'eu' image was used. Once you load an image
The ascii art depends on a monospace font to work properly. You should consider that 1 pixel in your image is going to be translated to 1 char in Ascii. e.g.: if a image is 100 pixels wide, it's going to take 100 chars of space on your page, unless you do something about it.

The imgToAscii should work with remote images:
```
```javascript
let img = new imgToAscii('http://site.com/image.png');
```
but it might not because of cross-origin settings. Keep that in mind.
Expand Down

0 comments on commit ca7e181

Please sign in to comment.