@embedpdf/models 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/color.d.ts +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts +41 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1476,6 +1476,15 @@ function webColorToPdfColor(color) {
|
|
|
1476
1476
|
blue: parseInt(b, 16)
|
|
1477
1477
|
};
|
|
1478
1478
|
}
|
|
1479
|
+
function getContrastStrokeColor(fillColor) {
|
|
1480
|
+
try {
|
|
1481
|
+
const { red, green, blue } = webColorToPdfColor(fillColor);
|
|
1482
|
+
const luminance = (0.299 * red + 0.587 * green + 0.114 * blue) / 255;
|
|
1483
|
+
return luminance < 0.45 ? "#fff" : "#000";
|
|
1484
|
+
} catch {
|
|
1485
|
+
return "#000";
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1479
1488
|
function pdfAlphaToWebOpacity(alpha) {
|
|
1480
1489
|
const clamp = (n) => Math.max(0, Math.min(255, n));
|
|
1481
1490
|
return clamp(alpha) / 255;
|
|
@@ -2280,6 +2289,7 @@ export {
|
|
|
2280
2289
|
extractWebOpacity,
|
|
2281
2290
|
flagsToNames,
|
|
2282
2291
|
getBlendModeInfo,
|
|
2292
|
+
getContrastStrokeColor,
|
|
2283
2293
|
getRectCenter,
|
|
2284
2294
|
getStandardFontDescriptor,
|
|
2285
2295
|
getTextAlignmentInfo,
|