<title>SVG Icon Editor</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-B4gt1ebN6GhDNCq4QsIPptMxFyM0rK+ZxB8bY4f6b4f4zTN0MhD8hM8dOJq7bFS8" crossorigin="anonymous">
<div class="container-fluid text-center">
<div class="svg-container" id="svg-icon">
<svg xmlns="http://www.w3.org/2000/svg" height="5em" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
<style id="svgStyle">svg {fill: black;}</style>
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"/> </svg>
<div class="color-picker-container">
<label class="color-picker-label" for="colorPicker">Select Color:</label>
<input type="color" id="colorPicker" class="color-picker">
<label class="color-picker-label" for="svg-change-size">Adjust Size:</label>
<input type="range" class="range-slider" min="1" step=".1" max="10" id="svg-change-size">
<div class="code-editor mt-3">
<pre><code class="language-css" id="code-editor"></code></pre>
<button id="copy-button">Copy SVG Code</button>
<button id="download-button">Download PNG</button>
<pre id="result" class="toast">Code Copied</pre>
<span id="info">🎉 The Font Awesome Twitter X icon has been officially released on FontAwesome.com! 🚀 </span>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/canvg@1.5.3/dist/canvg.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dom-to-image@2.6.0/dist/dom-to-image.min.js"></script>
$(document).ready(function () {
var svgStyleElement = $('#svgStyle');
var colorPicker = $('#colorPicker');
var svgChangeSize = $('#svg-change-size');
var svgIcon = $('#svg-icon svg');
function updateSvgSize() {
const newSize = svgChangeSize.val();
svgIcon.attr('height', newSize + 'em');
svgChangeSize.on('input', updateSvgSize);
colorPicker.on('input', function () {
var selectedColor = colorPicker.val();
svgStyleElement.text('svg{fill:' + selectedColor + '}');
var observer = new MutationObserver(function (mutationsList, observer) {
for (var mutation of mutationsList) {
$("#code-editor").text($("#svg-icon").html());
observer.observe(document.querySelector("#svg-icon"), {
childList: true, // This option ensures that child element changes are observed
subtree: true, // This option ensures deep observation of child elements
attributes: true, // This option ensures that attribute changes are observed
// Show code on initial load
$("#code-editor").text($("#svg-icon").html());
$("#copy-button").on("click", () => {
const copyText = $("#code-editor").text();
navigator.clipboard.writeText(copyText)
$("#result").css("display", "block");
$("#result").css("display", "none");
console.error("Could not copy text: ", err);
$("#download-button").on("click", function () {
domtoimage.toPng(document.getElementById("svg-icon"))
.then(function (dataUrl) {
var link = document.createElement("a");
link.download = "icon.png";
.catch(function (error) {
console.error("Error generating PNG image: ", error);
background-color: #fff5f5;
border: 2px solid #ff8080;
/* Aligns items vertically */
/* Aligns items horizontally */
/* Ensure the container takes up the full height */
/* Ensure the SVG scales within the container */
font-family: 'Courier New', Courier, monospace;
background-color: #007bff;
transition: background-color 0.3s ease;
background-color: #0056b3;
/* New CSS for download button */
background-color: #28a745;
transition: background-color 0.3s ease;
background-color: #218838;