Skip to content

Commit

Permalink
Patch fixes (#9)
Browse files Browse the repository at this point in the history
* Use browser safe png encode

* Add duration unit in readme

* Rephrase GIF to animations to be generic

* Fix package-lock name typo

* Update deps

* Clean eslintrc

* Update cli with name and version

* 1.1.3
  • Loading branch information
peterthehan committed Feb 14, 2021
1 parent a682824 commit 0fd59a5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true,
"jest": true,
Expand All @@ -11,8 +10,6 @@
"ecmaVersion": 2018
},
"rules": {
"curly": "warn",
"no-console": "off",
"sort-imports": "error"
"curly": "warn"
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ getRuneScapeText(string, [options], [wordWrapOptions]);
| replacement | `string` | No | `""` | String to replace characters the font does not support |
| maxMessageLength | `number` | No | `280` | Max message length allowed after the string has been sanitized |
| scale | `number` | No | `2` | Scale factor of the font (multiples of 16px), prefer integer values greater than or equal to 1, decimal values will render blurry text |
| fps | `number` | No | `20` | Frames per second to render GIFs at, prefer integer values less than or equal to 60 |
| cycleDuration | `number` | No | `3000` | Duration of one cycle before the GIF loops |
| quality | `number` | No | `100` | Quality to render GIFs at, more information [here](https://github.com/twolfson/gif-encoder#setqualityquality) |
| fps | `number` | No | `20` | Frames per second to render animations at, prefer integer values less than or equal to 60 |
| cycleDuration | `number` | No | `3000` | Duration in milliseconds of one cycle before the animation loops |
| quality | `number` | No | `100` | Quality to render animations at, more information [here](https://github.com/twolfson/gif-encoder#setqualityquality) |
| showLogs | `boolean` | No | `false` | Determines whether to print runtime logs or not |

#### WordWrapOptions
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "runescape-text",
"version": "1.1.2",
"version": "1.1.3",
"description": "Convert text to a text image with RuneScape chat effects.",
"keywords": [
"cli",
Expand Down Expand Up @@ -73,7 +73,7 @@
"word-wrap": "^1.2.3"
},
"devDependencies": {
"eslint": "^7.19.0",
"eslint": "^7.20.0",
"jest": "^26.6.3",
"prettier": "^2.2.1"
}
Expand Down
6 changes: 5 additions & 1 deletion src/classes/Encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ class Encoder {
}

encodePng(contexts) {
return contexts[0].canvas.toBuffer("image/png");
const data = contexts[0].canvas
.toDataURL()
.replace(/^data:image\/\w+;base64,/, "");

return Buffer.from(data, "base64");
}

encodeGif(contexts, width, height) {
Expand Down
3 changes: 3 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env node

const fs = require("fs");
const { name, version } = require("../package.json");
const getRuneScapeText = require("./index");

const getFilename = () => {
return `runescape-text-${Date.now()}`;
};

const main = async () => {
console.log(`${name} v${version}`);

const filename = getFilename();
if (
fs.existsSync(`./${filename}.gif`) ||
Expand Down

0 comments on commit 0fd59a5

Please sign in to comment.