initial public design release
This commit is contained in:
commit
262d06dac1
208 changed files with 11817 additions and 0 deletions
48
logo/svg2png_converter/converter.js
Normal file
48
logo/svg2png_converter/converter.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
let can = document.createElement("canvas");
|
||||
let ctx = can.getContext("2d");
|
||||
let result;
|
||||
const renderButton = document.querySelector("#render");
|
||||
const downloadButton = document.querySelector("#download");
|
||||
|
||||
function handleFileSelect(e) {
|
||||
const files = e.target.files;
|
||||
if (!files || !files.length) return;
|
||||
const file = files[0];
|
||||
if (file.type !== "image/svg+xml") return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = (readerEvent) => {
|
||||
renderSVG(readerEvent.target.result);
|
||||
}
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
function renderSVG(base64SVG) {
|
||||
const image = new Image();
|
||||
const preview = document.querySelector("#preview");
|
||||
|
||||
image.onload = function () {
|
||||
can.setAttribute("width", this.width);
|
||||
can.setAttribute("height", this.height);
|
||||
ctx.drawImage(image, 0, 0, this.width, this.height);
|
||||
|
||||
preview.src = result = can.toDataURL("image/png");
|
||||
downloadButton.disabled = false;
|
||||
}
|
||||
|
||||
image.src = base64SVG;
|
||||
}
|
||||
|
||||
function downloadURI(_uri, _name) {
|
||||
let link = document.createElement("a");
|
||||
link.download = "render.png";
|
||||
link.href = result;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
delete link;
|
||||
}
|
||||
|
||||
document.querySelector('#file_input').addEventListener('change', handleFileSelect, false);
|
||||
downloadButton.addEventListener("click", downloadURI);
|
29
logo/svg2png_converter/index.html
Normal file
29
logo/svg2png_converter/index.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body style="height: 100vh;">
|
||||
|
||||
<div style="display: flex; flex-direction: column; gap: 1em; align-items: center">
|
||||
<div>
|
||||
<input id="file_input" type="file" name="image" accept="image/svg+xml" />
|
||||
</div>
|
||||
|
||||
<img src="" style="width: 400px; height: 300px; border: solid 4px darkblue; object-fit: contain" id="preview" />
|
||||
|
||||
<button id="download" disabled>
|
||||
Download Result
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<script src="converter.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue