From c8a866197889d60d30fb23665637f567c359356a Mon Sep 17 00:00:00 2001 From: mattmcw Date: Thu, 29 Jul 2021 18:34:25 -0400 Subject: [PATCH] Restore textPos function --- sticky/package-lock.json | 6 +++--- sticky/sticky.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sticky/package-lock.json b/sticky/package-lock.json index 93f1626..7ab6da3 100644 --- a/sticky/package-lock.json +++ b/sticky/package-lock.json @@ -132,8 +132,8 @@ "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" }, "node_modules/hersheytext": { - "version": "2.0.0", - "resolved": "git+ssh://git@github.com/mattmcw/hersheytextjs.git#5aab4b86180419170157d36f14571605c587cb06", + "version": "2.0.1", + "resolved": "git+ssh://git@github.com/mattmcw/hersheytextjs.git#6b309796d2a83509307011165c75f3061709d88f", "license": "MIT", "dependencies": { "cheerio": "^0.22.0" @@ -399,7 +399,7 @@ "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" }, "hersheytext": { - "version": "git+ssh://git@github.com/mattmcw/hersheytextjs.git#5aab4b86180419170157d36f14571605c587cb06", + "version": "git+ssh://git@github.com/mattmcw/hersheytextjs.git#6b309796d2a83509307011165c75f3061709d88f", "from": "hersheytext@github:mattmcw/hersheytextjs", "requires": { "cheerio": "^0.22.0" diff --git a/sticky/sticky.js b/sticky/sticky.js index 63eb019..fdc8925 100755 --- a/sticky/sticky.js +++ b/sticky/sticky.js @@ -40,6 +40,17 @@ async function loadFont (fontPath) { } */ +function textPos (str) { + const len = str.length; + const w = len * W; + const h = H; + const x = (75.0 - w) / 2.0; + const y = (75.0 - h) / 2.0; + + return { x : x * UNIT, y : y * UNIT }; +} + + async function main () { const fontPath = args.font; const text = args.text.replace('\\n', '\n');