@nxtedition/ass
Advanced tools
+3
-1
@@ -111,2 +111,4 @@ import Color, { type ColorTypes } from 'colorjs.io'; | ||
| */ | ||
| export declare function toAssColor(input: ColorTypes): string; | ||
| export declare function toAssColor(input: ColorTypes, opts?: { | ||
| trimLeadingZeroes?: boolean; | ||
| }): string; |
+11
-8
@@ -254,3 +254,3 @@ import { wordwrap } from '@nxtedition/wordwrap' | ||
| color.alpha = 1 | ||
| const c = toAssColor(color) | ||
| const c = toAssColor(color, { trimLeadingZeroes: true }) | ||
| const aa = channelToHex(1 - alpha).toUpperCase() | ||
@@ -261,3 +261,3 @@ return [`${prefix}c${c}&`, `${prefix}a&H${aa}&`] | ||
| function getOverrideTags(styleOverrides ) { | ||
| const tags = Object.entries(styleOverrides ?? {}) | ||
| const tags = Object.entries((styleOverrides ?? {}) ) | ||
| .map(([key, value]) => { | ||
@@ -325,6 +325,6 @@ switch (key) { | ||
| style.fontsize, | ||
| style.primaryColour, | ||
| style.secondaryColour, | ||
| style.outlineColour, | ||
| style.backColour, | ||
| style.primaryColour ? toAssColor(fromAssColor(style.primaryColour)) : undefined, | ||
| style.secondaryColour ? toAssColor(fromAssColor(style.secondaryColour)) : undefined, | ||
| style.outlineColour ? toAssColor(fromAssColor(style.outlineColour)) : undefined, | ||
| style.backColour ? toAssColor(fromAssColor(style.backColour)) : undefined, | ||
| style.bold, | ||
@@ -513,3 +513,3 @@ style.italic, | ||
| */ | ||
| export function toAssColor(input ) { | ||
| export function toAssColor(input , opts ) { | ||
| const color = new Color(input) | ||
@@ -520,3 +520,6 @@ const rr = channelToHex(color.r ?? 0) | ||
| const aa = channelToHex(1 - color.alpha) | ||
| const aabbggrr = [aa, bb, gg, rr].join('').replace(/^0+/, '') || '0' | ||
| let aabbggrr = [aa, bb, gg, rr].join('') | ||
| if (opts?.trimLeadingZeroes) { | ||
| aabbggrr = aabbggrr.replace(/^0+/, '') || '0' | ||
| } | ||
| return `&H${aabbggrr}`.toUpperCase() | ||
@@ -523,0 +526,0 @@ } |
+5
-4
| { | ||
| "name": "@nxtedition/ass", | ||
| "version": "2.1.1", | ||
| "version": "2.1.2", | ||
| "type": "module", | ||
@@ -15,6 +15,7 @@ "main": "lib/index.js", | ||
| "typecheck": "tsc --noEmit", | ||
| "test": "node --test" | ||
| "test": "node --test", | ||
| "test:ci": "node --test" | ||
| }, | ||
| "dependencies": { | ||
| "@nxtedition/wordwrap": "^1.0.0", | ||
| "@nxtedition/wordwrap": "^1.0.1", | ||
| "colorjs.io": "^0.6.0", | ||
@@ -27,3 +28,3 @@ "fraction.js": "^5.3.4" | ||
| }, | ||
| "gitHead": "faa05f53edb2c4a96b6642aa5518052f8c1f6db6" | ||
| "gitHead": "0f407ebce03f670f13a733240af2a733ca56eefc" | ||
| } |
19705
2.44%485
1.04%Updated