Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <svg id="dkSVG" viewBox="10 30 430 350">
  <defs>  
    <pattern id="scanlines" class="scanLines" patternUnits="userSpaceOnUse" width="4" height="4">
      <line x1="0" y1="0" x2="4" y2="0" fill="none"/>
    </pattern>
    <pattern id="box" patternUnits="userSpaceOnUse" width="10" height="10" x="0" y="0">     
      <line x1="0" y1="0" x2="10" y2="0" style="stroke:rgb(0,127,255);stroke-width:3" />
      <line x1="0" y1="9" x2="10" y2="10" style="stroke:rgb(0,127,255);stroke-width:3" />
      <line x1="1" y1="1" x2="1" y2="9" style="stroke:rgb(0,255,255);stroke-width:2" />
      <line x1="9" y1="1" x2="9" y2="9" style="stroke:rgb(0,255,255);stroke-width:2" />
    </pattern>
  </defs>
  <symbol>
    <path id="tubeShape" d="M 50 50 
               A 150 12 0 1 1 400 50 
               A 12 50 0 1 1 400 350 
               A 150 12 0 1 1 50 350 
               A 12 50 0 1 1 50 50 Z" />
  </symbol>
  <g><use class="bg" xlink:href="#tubeShape"/></g>
  <g id="title" class="title"></g>  
  <g id="scores" class="scores">
    <text class="text" x="170"  y="225" fill="white">HIGH SCORES</text>
  </g>
  <g><use xlink:href="#tubeShape" fill="url(#scanlines)"/></g>  
</svg>

<div class="audioControls">  
<svg class="audioOn" viewBox="0 0 75 75">
<g id="g1"><polygon
id="polygon1"
points="39.389,13.769 22.235,28.606 6,28.606 6,47.699 21.989,47.699 39.389,62.75 39.389,13.769"
style="stroke-width:5;stroke-linejoin:round;"
/><path id="path1"
d="M 48.128,49.03 C 50.057,45.934 51.19,42.291 51.19,38.377 C 51.19,34.399 50.026,30.703 48.043,27.577"
style="fill:none;stroke-width:5;stroke-linecap:round"/>
<path id="path2"
d="M 55.082,20.537 C 58.777,25.523 60.966,31.694 60.966,38.377 C 60.966,44.998 58.815,51.115 55.178,56.076"
style="fill:none;stroke-width:5;stroke-linecap:round"/>
<path id="path1"
d="M 61.71,62.611 C 66.977,55.945 70.128,47.531 70.128,38.378 C 70.128,29.161 66.936,20.696 61.609,14.01"
style="fill:none;stroke-width:5;stroke-linecap:round"/>
</g>
</svg>

<svg class="audioOff" viewBox="0 0 75 75">
  <g id="g1">
  <polygon id="polygon1"
   points="39.389,13.769 22.235,28.606 6,28.606 6,47.699 21.989,47.699 39.389,62.75 39.389,13.769"
   style="stroke-width:5;stroke-linejoin:round;" />
  <path
   id="path3003"
   d="M 48.651772,50.269646 69.395223,25.971024"
   style="fill:none;stroke-width:5;stroke-linecap:round"/>
  <path
   id="path3003-1"
   d="M 69.395223,50.269646 48.651772,25.971024"
   style="fill:none;stroke-width:5;stroke-linecap:round"/>
  </g>
</svg>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Press+Start+2P');

body {
  background: black; 
  overflow: hidden;
}

.dkSVG {
  width: auto;
  height: auto;
  margin: auto;
}

use.bg {
  fill: #222222;
  opacity: 0.8;
}

.scanLines {
  fill: none; 
  stroke: black; 
  stroke-width: 3; 
  stroke-opacity: 0.3;
}

.text {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.6em;
  opacity: 0.8;
}

.blink {
  animation: blink 1s infinite; 
}
@keyframes blink {
  from { opacity: 0; }
  to { opacity: 1; }
}

.audioControls > * {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 50px;
  height: 50px;
  stroke: #555;
  fill: #555; 
  opacity: 0.8;
}

.audioOn {
  display: block;  
}

.audioOff {
  display: none;
}
              
            
!

JS

              
                const scores = [{rank: '1st', name: 'AAA', score: '000012122', color: 'red'},
             {rank: '2nd', name: 'BBB', score: '000012120', color: 'red'},
             {rank: '3rd', name: 'CCC', score: '000012100', color: 'red'},
             {rank: '4th', name: 'DDD', score: '000012000', color: 'green'},
             {rank: '5th', name: 'EEE', score: '000010000', color: 'green'}];

const title = `
***  *** *  * *  * *** * *
** * * * ** * ***  *   * *
** * * * **** **   *** ***
** * * * * ** * *  *    *
***  *** *  * *  * ***  *

    *  * *** *  * ****
    ***  * * ** * *
    **   * * **** * **
    * *  * * * ** *  *
    *  * *** *  * ****
`;

const lines = title.split('\n');
const svgElement = document.querySelector('#title');

const ns = 'http://www.w3.org/2000/svg';
const xTitleOffset = 100;
const yTitleOffset = 70;
const boxSize = 10;

const scoreTop = 250;
const scoreRankLeft = 120;
const scoreNameLeft = 185;
const scoreLeft = 250;

lines.forEach((line, i) => {
  line.split('').forEach((char, j) => {
    if(char === '*')                       
      drawBox(j, i);
  });
});
  
function drawBox(x, y) {
  let rectElement = document.createElementNS(ns, 'rect');
  rectElement.setAttribute('width', boxSize + 'px');
  rectElement.setAttribute('height', boxSize + 'px');
  rectElement.setAttribute('x', xTitleOffset + (x * boxSize) + 'px');
  rectElement.setAttribute('y', yTitleOffset + (y * boxSize) + 'px');
  rectElement.setAttribute('fill', 'url(#box)');
  svgElement.appendChild(rectElement);
}

scores.forEach((score, i) => {
  drawScore(i, score);
});

function drawScore(i, score) {
  let textElement = document.createElementNS(ns, 'text');
  textElement.setAttribute('fill', score.color);
  textElement.setAttribute('x', scoreLeft + 'px');
  textElement.setAttribute('y', scoreTop + (i * 20) + 'px'); 
  if(i === 0)
    textElement.setAttribute('class', 'text blink'); 
  else
    textElement.setAttribute('class', 'text'); 
  textElement.textContent = score.score;
  svgElement.appendChild(textElement);
  
  textElement = document.createElementNS(ns, 'text');
  textElement.setAttribute('fill', score.color);
  textElement.setAttribute('x', scoreNameLeft + 'px');
  textElement.setAttribute('y', scoreTop + (i * 20) + 'px'); 
  if(i === 0)
    textElement.setAttribute('class', 'text blink'); 
  else
    textElement.setAttribute('class', 'text'); 
  textElement.textContent = score.name;
  svgElement.appendChild(textElement);
  
  textElement = document.createElementNS(ns, 'text');
  textElement.setAttribute('fill', score.color);
  textElement.setAttribute('x', scoreRankLeft + 'px');
  textElement.setAttribute('y', scoreTop + (i * 20) + 'px'); 
  if(i === 0)
    textElement.setAttribute('class', 'text blink');
  else
    textElement.setAttribute('class', 'text'); 
  textElement.textContent = score.rank;
  svgElement.appendChild(textElement);
}
              
            
!
999px

Console