HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<input id="wizid" type="text" onblur="getVal()" placeholder="Wizard ID"></input>
<button>Load Image</button>
<button class="btn" onclick="mugshot()">Toggle mugshot mode</button>
<button class="btn" onclick="showtoken()">show/hide token</button>
<button class="btn" onclick="toggleHat()">Toggle Hat</button>
<button class="btn" onclick="castSpell()"> Cast Spell</button>
<br>
<button class="btn pepe" onclick="memePepe()"> Meme Pepe</button>
<button class="btn gm" onclick="memeGm()"> Meme GM</button>
<button class="btn sec" onclick="memeSec()"> Meme SEC</button>
<button class="btn nude" onclick="nudeEvent()"> Nude</button>
<button class="btn homer" onclick="memeHomer()"> Springfield</button>
<button class="save" onclick="downloadPng()">Save Wizard</button>
<a class="reset" onclick="reset()">Reset</a>
<div id="preview"></div>Preview ☝️
<div id="canvas"></div>
* {
font-family: 'VT323', monospace;
font-size: 16px;
text-transform: uppercase;
}
#canvas {
overflow:hidden;
width: auto;
}
#preview {
width: 150px;
height: 150px;
background: lightgrey;
}
svg > g {
transform: scale(1.5);
transform-origin: center;
}
svg.tell-price > g,
svg.oom > g {
transform: scale(1.35);
transform-origin: center;
}
svg.mugshot > g {
transform: scale(2.35) translateY(7%)
}
svg.mugshot .artifact {
display: none;
}
svg .pw-saber-light {
opacity: 1;
}
svg .pw-saber-button {
fill: #51A200;
}
svg.showtoken .token {
opacity:1;
transform: translateY(3px) translateX(2px)
}
svg.mugshot.showtoken .token {
opacity:0;
}
.save {
margin: 10px 0;
}
button, input {
padding: 10px 20px;
margin: 0 5px 5px 0px;
border: 3px solid;
border-radius: 5px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
border-image: url(https://pixelwizards.art/wp-content/uploads/2022/11/pixel-border-1.png) 11 stretch;
}
a.reset {
color: black;
text-decoration: underline;
margin-left: 15px;
cursor: pointer;
}
button {
background: #E3FDFF;
cursor: pointer;
}
button.nude {
background: #E3BC9A;
}
button.pepe {
background: #72b82c;
color: #fff;
}
button.gm {
background-color: #FBDA61;
background-image: linear-gradient(45deg, #FBDA61 0%, #5AE1FF 100%);
color: #fff;
}
button.sec {
background: #222;
background-image: url('https://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/255px-Flag_of_the_United_States.svg.png');
background-size: cover;
color: #fff;
box-shadow: inset 0 0 0 2000px rgba(0, 0, 0, 0.3);
}
button.homer {
background: #ebd320;
}
.pepehead,
.croissant,
.coffee,
.gm-chat,
.fudcase,
.gary-face,
.gary-suit,
.meme-gm .artifact > g:not(.wrapper),
.meme-gm .staff > g:not(.wrapper),
.meme-sec .robe > g:not(.wrapper),
.meme-sec .face > g:not(.wrapper),
.meme-sec .artifact > g:not(.wrapper),
.meme-sec.meme-gm .croissant {
visibility: hidden;
}
.meme-pepe .pepehead,
.meme-gm .croissant,
.meme-gm .coffee,
.meme-gm .gm-chat,
.meme-sec .gary-face,
.meme-sec .gary-suit,
.meme-sec .fudcase {
visibility: visible;
}
.meme-sec .beard {
visibility: hidden;
}
.nude .robe {
opacity:0;
}
.gm-chat {
transform: translate(8px, 6px) scale(0.8)
}
/*
.meme-homer .backdrop > path {
fill: transparent;
}
#canvas:has(svg.meme-homer),
#preview:has(svg.meme-homer) {
background-image: url('https://virtual-bg.com/wp-content/uploads/2020/06/simpsons-fox.jpg');
background-size: cover;
background-position: center -30px;
}
*/
let canvas = document.getElementById("canvas");
let preview = document.getElementById("preview");
function getVal() {
const wizardId = document.querySelector('input').value;
fetch('https://ipfs-gw.stargaze-apis.com/ipfs/bafybeiet7wzhih3zwcmdi2kojzpkrhjdrp7otaineans5zgg6e26yuj4qu/'+wizardId+'.svg')
.then(r => r.text())
.then(text => {
canvas.innerHTML = text;
preview.innerHTML = text;
})
.catch(console.error.bind(console));
}
function mugshot() {
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("mugshot");
cSvg.classList.toggle("mugshot");
}
function castSpell() {
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("cast-spell");
cSvg.classList.toggle("cast-spell");
}
/* function tellPrice() {
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
let pwToken = pSvg.querySelector('.token').firstElementChild.className.baseVal;
console.log(pwToken);
var requestOptions = {
method: 'GET',
redirect: 'follow',
};
fetch("https://api.pixelwizards.art/v1/knowledge/" + pwToken, requestOptions)
.then(response => {
return response.json();
})
.then(data => {
let price = Number(data[priceValue]);
let percentageChange = Number(data["changePer"]);
let UpOrDown = (data["changePer"] > 0) ? "up" : "down";
})
.catch(error => {
console.log("Out of mana.");
pSvg.classList.toggle('oom');
cSvg.classList.toggle('oom');
console.log(error);
});
//pSvg.classList.toggle("tell-price");
//cSvg.classList.toggle("tell-price");
} */
function showtoken() {
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("showtoken");
cSvg.classList.toggle("showtoken");
}
function toggleHat() {
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("hat-gone");
cSvg.classList.toggle("hat-gone");
}
function nudeEvent() {
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("nude");
cSvg.classList.toggle("nude");
}
function memePepe() {
const pepeHead ='<g class="pepehead"><path d="M30 26h-1v-1h4v1h-3Zm6 0h1v-1h-3v1h2Zm-7 0h-1v1h1v-1Zm5 1v-1h-1v1h1Zm4 0v-1h-1v1h1Zm-10 0h-1v1h1v-1Zm10 0v5h1v-5h-1Zm-11 1h-1v1h1v-1Zm4 4h1v-1h-1v1Zm5-1v1h1v-1h-1Zm1 2h1v-1h-1v1Zm-11 0v-4h-1v6h1v-2Zm12 2h1v-2h-1v2Zm-12 0v1h1v-1h-1Zm11 1h1v-1h-1v1Zm-2 0h-8v1h10v-1h-2Z"/><path fill="#fff" d="M32 30h1v2h-1v-1h-1v1h-1v-2h2Zm5 0h-2v2h1v-1h1v1h1v-2h-1Z"/><path fill="#E4768D" d="M38 33v1h-9v-1h9Z"/><path fill="#D95470" d="M38 34v1h-9v-1h9Z"/><path fill="#72B82C" d="M37 27v-1h-3v1h-1v-1h-4v1h-1v1h-1v1h-1v6h1v1h10v-1h-8v-2h8v-1h-2v-2h3v-3h-1Zm-5 5h-2v-2h3v2h-1Z"/><path fill="#51A200" d="M27 28h1v3h-1v4h-1v-6h1v-1Zm4 1h-1v1h3v-1h-2Zm6 0h-2v1h3v-1h-1Zm-7 4h1v-1h-1v1Zm5 0h1v-1h-1v1Zm-6 3h1v-1h-1v1Z"/></g>';
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("meme-pepe");
cSvg.classList.toggle("meme-pepe");
d3.selectAll('.face')
.append("g")
.attr("class", "wrapper")
.html(pepeHead);
}
function memeGm() {
const croissant = '<g class="croissant"><path d="M22 37h-1v-1h3v1h-2Zm-1 0h-1v1h1v-1Zm4 1h2v-1h-3v1h1Zm-5 1v-1h-2v1h2Zm7-1v1h1v-1h-1Zm-1 2h1v-1h-1v1Zm-8 0v-1h-1v2h1v-1Zm6 0h-1v1h3v-1h-2Zm-8 1v1h1v-1h-1Zm5 0v1h2v-1h-2Zm-2 1h-2v1h4v-1h-2Z" /><path fill="#C37100" d="M27 38v1h-1v1h-3v1h-2v1h-4v-1h1v-2h2v-1h1v-1h3v1h3Z" /><path fill="#794100" d="M24 37v1h-1v-1h1Zm-3 1h-1v1h2v-1h-1Zm3 0v1h1v-1h-1Zm-6 1v1h1v-1h-1Zm4 1v1h1v-2h-1v1Zm3-1v1h1v-1h-1Zm-6 2v1h1v-2h-1v1Z" /></g>';
const coffee = '<g class="coffee"><g class="pw-particles-x"><path fill="#363636" d="M43 35h-1v-1h1v1Zm-3 0v1h1v-1h-1Zm2 1h-1v1h1v-1Zm1 0v2h1v-2h-1Zm-3 2v1h1v-2h-1v1Zm2 1h1v-1h-1v1Z" opacity=".145"/></g><path fill="#37240C" d="M41 40h-1v1h1v-1Zm1 0h-1v1h1v-1Zm1 0h-1v1h1v-1Z" /><path fill="#EBEBEB" d="M41 41v3h-1v-3h1Z" /><path fill="#fff" d="M43 41v3h-2v-3h2Z" /><path d="M44 40v4h-1v-4h1Zm-7 2v1h1v-1h-1Zm3 0v-2h-1v1h-1v1h1v1h-1v1h2v-2Zm1 2h-1v1h3v-1h-2Z" /></g>'
const gmchat = '<g class="gm-chat"><path d="M39 25h-1v-1h15v1H39Zm14 0v6h1v-6h-1Zm-15 4v-4h-1v6h1v-2Zm1 2h-1v1h1v-1Zm12 0H41v1h12v-1h-2Zm-13 1h-1v1h1v-1Zm2 1h1v-1h-1v1Zm-3 0h-1v2h2v-1h-1v-1Zm1 0v1h2v-1h-2Z" /><path fill="#FFFFEB" d="M53 25v6H41v1h-1v1h-2v-1h1v-1h-1v-6h15Zm-16 9h1v-1h-1v1Z" /><path d="M42.3 29.1h-.8v-2.4h.8v2.4Zm.7-3h.8v.8h-1.6v-.8h.8Zm0 3h.8v.8h-1.6v-.8h.8Zm.8 0v-.8H43v-.8h1.6v1.6h-.8Zm1.5.8v-4h1.5v.8H46v3.2h-.7Zm3 0v-3.2h-.8v3.2h-.8v-3.2h.8v-.8H49v4h-.7Z" /></g>'
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("meme-gm");
cSvg.classList.toggle("meme-gm");
//d3.selectAll('.staff > g, .artifact > g').remove()
d3.selectAll('.staff')
.append("g")
.attr("class", "wrapper")
.html(coffee);
d3.selectAll('.artifact')
.append("g")
.attr("class", "wrapper")
.html(croissant);
d3.selectAll('.wizard')
.append("g")
.attr("class", "wrapper")
.html(gmchat);
}
function memeSec() {
const garyface = '<g class="gary-face"><path fill="#EBEBEB" d="M28 27h1v1h-1v-1zm7 0v1h1v-1h-1z" class="Vector"/><path fill="#fff" d="M34 27v1h-4v-1h4zm0 1v1h1v-1h-1z" class="Vector"/><path fill="#B2B2B2" d="M29 29h-1v-1h1v1zm6-1v1h1v-1h-1zm-8 2h1v-1h-1v1zm9-1v1h1v-1h-1zm-7 1v1h2v-1h-2zm4 0v1h2v-1h-2z" class="Vector"/><path fill="#797979" d="M27 30h1v2h-1v-2zm9 0v2h1v-2h-1z" class="Vector"/><path fill="#363636" d="M29 31v1h-1v-1h1zm1 1h1v-1h-1v1zm3-1v1h1v-1h-1zm2 0v1h1v-1h-1zm-6 2h1v-1h-1v1zm5 0h1v-1h-1v1z" class="Vector" opacity=".145"/><path d="M29 31h1v1h-1v-1zm5 0v1h1v-1h-1zm-3 2v1h2v-1h-2z" class="pw-eyes-mouth"/></g>';
const garysuit = '<g class="gary-suit"><path fill="#EBEBEB" d="M32 39h-1v-1h1v1zm-2 1h1v-1h-1v1zm4-1h-1v1h1v-1zm-1 2h-1v1h1v-1zm-4 5h1v-1h-1v1zm5-1h-1v1h2v-1h-1z" class="Vector"/><path fill="#fff" d="M32 39v1h-1v-1h1zm0 1v1h1v-1h-1z" class="Vector"/><path fill="#E35100" d="M33 38v2h-1v-2h1zm-2 3v2h1v-3h-1v1z" class="Vector"/><path fill="#363636" d="M31 39h-1v-1h1v1zm2-1v1h1v-1h-1zm-3 1h-1v1h1v-1zm5 0h-1v1h1v-1zm-5 3h1v-2h-1v2zm4-1v-1h-1v2h1v-1zm-2 1v1h-4v1h7v-1h-2v-1h-1z" class="Vector"/><path fill="#1E1E1E" d="M29 39h-1v-1h1v-1h1v2h-1zm7-1h-1v-1h-1v2h1v1h1v-2zm-8 2v-1h-1v2h1v-1zm2 0h-1v3h2v-1h-1v-2zm4 1v1h-1v1h2v-3h-1v1zm2-1v3h1v-3h-1zm-3 4h-5v1h7v-1h-2z" class="Vector"/><path fill="#B2B2B2" d="M30 45h1v1h-1v-1zm5 0v1h1v-1h-1z" class="Vector"/></g>';
const fudcase = '<g class="fudcase"><path fill="#623807" d="M24 35v2h-1v-1h-3v1h-1v-2h5z" class="Vector"/><path fill="#B2B2B2" d="M18 36h1v1h-1v-1zm6 0v1h1v-1h-1zm-3 3h-1v1h3v-1h-2z" class="Vector"/><path fill="#363636" d="M26 38v2h-3v-1h-3v1h-3v-2h9z" class="Vector"/><path fill="#1E1E1E" d="M26 40v3h-9v-3h9z" class="Vector"/><path d="M18 38h-1v-1h9v1h-8zm8 0v5h-9v-5h-1v6h11v-6h-1z" class="Vector"/><path fill="#fff" d="M18.1 40.7h.3v.3h-.6v-.3h.3zm-.7.6h.3V41h-.3v.3zm.7.4v-.3h-.3v.3h.3zm-.7.3v.3h.6V42h-.6zm1 0v-.3h-.3v.3h.3zm.4-1.3v1.6h.6V42h-.3v-.3h.3v-.3h-.3V41h.3v-.3h-.6zm1.7 1.6h.3V42h-.6v.3h.3zm-.4-1.6v.3h.6v-.3h-.6zm-.3.6v.7h.3v-1h-.3v.3zm2.4-.6h-.3v1.6h.3v-.6h.3v-.3h-.3V41h.6v-.3h-.6zm1.7.3v1h-.3v-1.3h-.3v1.6h.9v-1.6h-.3v.3zm1.3 0v1h.3v-1h-.3zm-.3.7V41h.3v-.3h-.6v1.6h.6V42h-.3v-.3z" class="Vector"/></g>';
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("meme-sec");
cSvg.classList.toggle("meme-sec");
//d3.selectAll('.staff > g, .artifact > g').remove()
d3.selectAll('.robe')
.append("g")
.attr("class", "wrapper")
.html(garysuit);
d3.selectAll('.artifact')
.append("g")
.attr("class", "wrapper")
.html(fudcase);
d3.selectAll('.face')
.append("g")
.attr("class", "wrapper")
.html(garyface);
}
function memeHomer() {
const homerFace = '<g class="homer-face"><path fill="#fff" d="M30 30h1v2h-2v-2h1Zm4 0h-1v2h2v-2h-1Z" /><path fill="#CF9F54" d="M31 34h-1v-1h4v1h-3Zm3 0v1h-4v-1h-1v2h2v1h2v-1h2v-2h-1Z" /><path fill="#CF9F54" d="M31 33h-1v-1h4v1h-3Zm-1 0h-1v1h1v-1Zm5 1v-1h-1v1h1Zm-6 0h-1v2h1v-2Zm6 0v2h1v-2h-1Zm-5 2h-1v1h2v-1h-1Zm3 0v1h2v-1h-2Zm-2 1v1h2v-1h-2Z" /><path d="M31 32h-1v-1h1v1Zm3-1v1h1v-1h-1Zm-2 3h-2v1h4v-1h-2Z" class="pw-eyes-mouth"/></g>';
const homerSkin = '<g class="homerskin"><path fill="#BDA910" d="M32 37h-1v-1h2v1h-1Zm-1 2h-1v1h1v-1Zm2 0v1h1v-1h-1Zm-1 5h1v-1h-1v1Zm-1 1h1v-1h-1v1Z" class="skin-details"/><path fill="#EBD320" d="M36 38h-1v-1h1v-1h1v-7h-1v-2h-8v2h-1v7h1v1h1v1h-1v1h1v4h-1v2h1v1h2v-2h1v-1h1v1h-1v1h1v1h3v-1h-1v-5h1v-2Zm-5-2h2v1h-2v-1Zm-1 3h1v1h-1v-1Zm3 1v-1h1v1h-1Zm-6-1h1v3h-1v-3Zm11 3v1h-2v-3h1v2h1Z" class="skin-fill"/></g>';
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.toggle("meme-homer");
cSvg.classList.toggle("meme-homer");
d3.selectAll('.skin')
.append("g")
.attr("class", "wrapper")
.html(homerSkin);
d3.selectAll('.face')
.append("g")
.attr("class", "wrapper")
.html(homerFace);
}
function reset() {
const pSvg = preview.querySelector('svg');
const cSvg = canvas.querySelector('svg');
pSvg.classList.value = ''
cSvg.classList.value = ''
d3.selectAll('.wrapper').remove();
}
function downloadPng() {
var element = document.getElementById("canvas");
html2canvas(element, {
height: element.offsetHeight - 5,
width: element.offsetWidth - 5,
allowTaint: true,
useCORS: true
}).then(function(canvas) {
canvas.toBlob(function(blob) {
window.saveAs(blob, "wizard.png");
});
});
}
Also see: Tab Triggers