@tekkare/romulus 0.1.179 → 0.1.180
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/module.json
CHANGED
|
@@ -122,11 +122,30 @@ async function capture(el) {
|
|
|
122
122
|
useCORS: true
|
|
123
123
|
});
|
|
124
124
|
if (!canvas.width || !canvas.height) return null;
|
|
125
|
-
return
|
|
125
|
+
return canvas;
|
|
126
126
|
} catch {
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
function slice(canvas, top, height) {
|
|
131
|
+
const part = document.createElement("canvas");
|
|
132
|
+
part.width = canvas.width;
|
|
133
|
+
part.height = Math.max(1, Math.round(height));
|
|
134
|
+
const context = part.getContext("2d");
|
|
135
|
+
if (!context) return canvas.toDataURL("image/png");
|
|
136
|
+
context.drawImage(
|
|
137
|
+
canvas,
|
|
138
|
+
0,
|
|
139
|
+
Math.round(top),
|
|
140
|
+
canvas.width,
|
|
141
|
+
part.height,
|
|
142
|
+
0,
|
|
143
|
+
0,
|
|
144
|
+
canvas.width,
|
|
145
|
+
part.height
|
|
146
|
+
);
|
|
147
|
+
return part.toDataURL("image/png");
|
|
148
|
+
}
|
|
130
149
|
async function raster(markup, width, height, scale = 2) {
|
|
131
150
|
const image = new Image();
|
|
132
151
|
image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;
|
|
@@ -585,28 +604,39 @@ export function useRmExport() {
|
|
|
585
604
|
if (faithful) {
|
|
586
605
|
sectionTitle(lang === "en" ? "Page" : "La page");
|
|
587
606
|
for (const shot of shots) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
592
|
-
|
|
593
|
-
|
|
607
|
+
const drawWidth = inner;
|
|
608
|
+
const height = shot.height / shot.width * drawWidth;
|
|
609
|
+
const room = () => bottom - y;
|
|
610
|
+
if (height <= bottom - margin) {
|
|
611
|
+
if (height > room()) {
|
|
612
|
+
doc.addPage();
|
|
613
|
+
y = margin;
|
|
614
|
+
}
|
|
615
|
+
doc.addImage(shot.toDataURL("image/png"), "PNG", margin, y, drawWidth, height, void 0, "FAST");
|
|
616
|
+
y += height + 6;
|
|
617
|
+
continue;
|
|
594
618
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
619
|
+
let drawn = 0;
|
|
620
|
+
while (drawn < height - 0.5) {
|
|
621
|
+
if (room() < 20) {
|
|
622
|
+
doc.addPage();
|
|
623
|
+
y = margin;
|
|
624
|
+
}
|
|
625
|
+
const band = Math.min(room(), height - drawn);
|
|
626
|
+
doc.addImage(
|
|
627
|
+
slice(shot, drawn / height * shot.height, band / height * shot.height),
|
|
628
|
+
"PNG",
|
|
629
|
+
margin,
|
|
630
|
+
y,
|
|
631
|
+
drawWidth,
|
|
632
|
+
band,
|
|
633
|
+
void 0,
|
|
634
|
+
"FAST"
|
|
635
|
+
);
|
|
636
|
+
drawn += band;
|
|
637
|
+
y += band;
|
|
598
638
|
}
|
|
599
|
-
|
|
600
|
-
shot.data,
|
|
601
|
-
"PNG",
|
|
602
|
-
margin + (inner - drawWidth) / 2,
|
|
603
|
-
y,
|
|
604
|
-
drawWidth,
|
|
605
|
-
drawHeight,
|
|
606
|
-
void 0,
|
|
607
|
-
"FAST"
|
|
608
|
-
);
|
|
609
|
-
y += drawHeight + 6;
|
|
639
|
+
y += 6;
|
|
610
640
|
}
|
|
611
641
|
}
|
|
612
642
|
let rowCount = 0;
|