opencrush 0.3.17 → 0.3.19
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/index.js +27 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -245654,15 +245654,18 @@ function splitRespectingParens(str2) {
|
|
|
245654
245654
|
function escapeXml(str2) {
|
|
245655
245655
|
return str2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
245656
245656
|
}
|
|
245657
|
-
function buildTextOverlay(data) {
|
|
245657
|
+
function buildTextOverlay(data, bgR = 20, bgG = 20, bgB = 30) {
|
|
245658
245658
|
const S2 = SCALE;
|
|
245659
|
-
const textX =
|
|
245660
|
-
const panelW =
|
|
245659
|
+
const textX = 44 * S2;
|
|
245660
|
+
const panelW = 480 * S2;
|
|
245661
245661
|
const availW = panelW - textX - 30 * S2;
|
|
245662
|
-
|
|
245662
|
+
const meta = [data.age, data.location].filter(Boolean).join(" \xB7 ");
|
|
245663
|
+
const lineCount = 1 + (meta ? 1 : 0) + (data.job ? 1 : 0) + 1 + (data.tags.length > 0 ? 1 : 0) + (data.vibe ? 1 : 0);
|
|
245664
|
+
const blockH = lineCount * 32 * S2;
|
|
245665
|
+
const startY = Math.max(50 * S2, Math.round((H2 - blockH) / 2) - 20 * S2);
|
|
245666
|
+
let y2 = startY;
|
|
245663
245667
|
const nameY = y2;
|
|
245664
245668
|
y2 += 50 * S2;
|
|
245665
|
-
const meta = [data.age, data.location].filter(Boolean).join(" \xB7 ");
|
|
245666
245669
|
const metaY = y2;
|
|
245667
245670
|
if (meta) y2 += 32 * S2;
|
|
245668
245671
|
const jobY = y2;
|
|
@@ -245699,11 +245702,11 @@ function buildTextOverlay(data) {
|
|
|
245699
245702
|
const jobText = data.job.length > jobMax ? data.job.slice(0, jobMax - 1) + "\u2026" : data.job;
|
|
245700
245703
|
const vibeText = data.vibe.length > vibeMax ? data.vibe.slice(0, vibeMax - 1) + "\u2026" : data.vibe;
|
|
245701
245704
|
return `<svg width="${panelW}" height="${H2}" xmlns="http://www.w3.org/2000/svg">
|
|
245702
|
-
<!--
|
|
245705
|
+
<!-- Panel background using sampled color -->
|
|
245703
245706
|
<defs>
|
|
245704
245707
|
<linearGradient id="panel" x1="0" y1="0" x2="1" y2="0">
|
|
245705
|
-
<stop offset="0%" stop-color="rgba(
|
|
245706
|
-
<stop offset="100%" stop-color="rgba(
|
|
245708
|
+
<stop offset="0%" stop-color="rgba(${bgR},${bgG},${bgB},0.92)" />
|
|
245709
|
+
<stop offset="100%" stop-color="rgba(${bgR},${bgG},${bgB},0.80)" />
|
|
245707
245710
|
</linearGradient>
|
|
245708
245711
|
</defs>
|
|
245709
245712
|
<rect width="${panelW}" height="${H2}" fill="url(#panel)" />
|
|
@@ -245748,27 +245751,32 @@ async function generateCard(characterName) {
|
|
|
245748
245751
|
if (!refImagePath) {
|
|
245749
245752
|
return generateFallbackCard(charDir, characterName, data);
|
|
245750
245753
|
}
|
|
245751
|
-
const
|
|
245752
|
-
const
|
|
245753
|
-
const
|
|
245754
|
-
const
|
|
245754
|
+
const { data: colorData } = await sharp(refImagePath).resize(1, 1, { fit: "cover" }).raw().toBuffer({ resolveWithObject: true });
|
|
245755
|
+
const [cr2, cg, cb] = [colorData[0], colorData[1], colorData[2]];
|
|
245756
|
+
const bgR = Math.round(cr2 * 0.18), bgG = Math.round(cg * 0.18), bgB = Math.round(cb * 0.18);
|
|
245757
|
+
const bgSolid = await sharp({
|
|
245758
|
+
create: { width: W2, height: H2, channels: 3, background: { r: bgR, g: bgG, b: bgB } }
|
|
245759
|
+
}).png().toBuffer();
|
|
245760
|
+
const portraitH = H2;
|
|
245761
|
+
const portraitW = Math.round(portraitH * 4 / 5);
|
|
245762
|
+
const portrait = await sharp(refImagePath).resize(portraitW, portraitH, { fit: "cover", position: "top" }).png().toBuffer();
|
|
245755
245763
|
const fadeMask = Buffer.from(
|
|
245756
|
-
`<svg width="${
|
|
245764
|
+
`<svg width="${portraitW}" height="${portraitH}">
|
|
245757
245765
|
<defs>
|
|
245758
245766
|
<linearGradient id="fade" x1="0" y1="0" x2="1" y2="0">
|
|
245759
245767
|
<stop offset="0%" stop-color="white" />
|
|
245760
|
-
<stop offset="
|
|
245768
|
+
<stop offset="65%" stop-color="white" />
|
|
245761
245769
|
<stop offset="100%" stop-color="black" />
|
|
245762
245770
|
</linearGradient>
|
|
245763
245771
|
</defs>
|
|
245764
|
-
<rect width="${
|
|
245772
|
+
<rect width="${portraitW}" height="${portraitH}" fill="url(#fade)" />
|
|
245765
245773
|
</svg>`
|
|
245766
245774
|
);
|
|
245767
245775
|
const maskedPortrait = await sharp(portrait).composite([{ input: fadeMask, blend: "dest-in" }]).png().toBuffer();
|
|
245768
|
-
const panelW = Math.round(
|
|
245769
|
-
const textSvg = buildTextOverlay(data);
|
|
245776
|
+
const panelW = Math.round(480 * SCALE);
|
|
245777
|
+
const textSvg = buildTextOverlay(data, bgR, bgG, bgB);
|
|
245770
245778
|
const textPanel = await sharp(Buffer.from(textSvg)).resize(panelW, H2).png().toBuffer();
|
|
245771
|
-
const card = sharp(
|
|
245779
|
+
const card = sharp(bgSolid).composite([
|
|
245772
245780
|
{ input: maskedPortrait, left: 0, top: 0 },
|
|
245773
245781
|
{ input: textPanel, left: W2 - panelW, top: 0 }
|
|
245774
245782
|
]);
|
|
@@ -245809,7 +245817,7 @@ var init_card = __esm({
|
|
|
245809
245817
|
init_source();
|
|
245810
245818
|
SCALE = 2;
|
|
245811
245819
|
W2 = 1200 * SCALE;
|
|
245812
|
-
H2 =
|
|
245820
|
+
H2 = 960 * SCALE;
|
|
245813
245821
|
}
|
|
245814
245822
|
});
|
|
245815
245823
|
|