mirror of
https://github.com/penpot/penpot.git
synced 2025-05-09 21:16:38 +02:00
✨ Add experiments directory.
This commit is contained in:
parent
dff038f4d7
commit
96d4c1e2fd
22 changed files with 1838 additions and 56 deletions
29
experiments/js/main.js
Normal file
29
experiments/js/main.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
function svgDataURL(svg) {
|
||||
var svgAsXML = new XMLSerializer().serializeToString(svg);
|
||||
return "data:image/svg+xml," + encodeURIComponent(svgAsXML);
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", event => {
|
||||
html2canvas(document.querySelector("foreignObject"), {
|
||||
logging: false,
|
||||
scale: 4
|
||||
}).then((canvas) => {
|
||||
|
||||
|
||||
let dataURL = canvas.toDataURL();
|
||||
let image = document.createElementNS("http://www.w3.org/2000/svg", "image");
|
||||
image.setAttribute("href", dataURL);
|
||||
image.setAttribute("width", "400");
|
||||
image.setAttribute("height", "200");
|
||||
image.width = 400;
|
||||
image.height = 200;
|
||||
|
||||
document.querySelector("foreignObject").replaceWith(image);
|
||||
document.body.appendChild(canvas);
|
||||
|
||||
// html2canvas(document.querySelector("svg")).then(canvas => {
|
||||
// document.body.appendChild(canvas);
|
||||
// });
|
||||
});
|
||||
//console.log(svgDataURL(svg));
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue