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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div class="c-preview">
  <img src="https://unsplash.it/1800/1200?random" alt="" class="c-preview__image svg-filter" />
  <svg width="0" height="0" xmlns="http://www.w3.org/2000/svg" version="1.1">
    <defs>
        <filter id="svgfilter" x="0%" y="0%" width="100%" height="100%">
            <feColorMatrix result="original" id="svgcolormatrix" type="matrix" values="1 0 0 0 0  
                                                 0 1 0 0 0 
                                                 0 0 1 0 0 
                                                 0 0 0 1 0"/>
        </filter>
    </defs>
</svg>

</div>


<div class="c-controls">
  <div class="c-controls__head">
    <h3>feColorMatrix Generator</h3>
    <p>
      To understand what's going on here read this <a href="http://alistapart.com/article/finessing-fecolormatrix" target="_blank">article</a> by A List Apart
    </p>
  </div>
  <div class="c-color">
    <span class="c-color__name"> Red to Red: </span>
    <span class="c-color__value" id="">1</span>
    <input type="range" id="aR1" min="-1" max="2" step=".1" value="1" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Green to Red: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="aR2" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Blue to Red: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="aR3" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Alpha to Red: </span>
    <span class="c-color__value" id="">0</span>

    <input type="range" id="aR4" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Add to Red: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="aR5" min="-1" max="2" step=".1" value="0" />
  </div>


  <div class="c-color">
    <span class="c-color__name">Red to Green: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="bG1" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Green to Green: </span>
    <span class="c-color__value" id="">1</span>
    <input type="range" id="bG2" min="-1" max="2" step=".1" value="1" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Blue to Green: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="bG3" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Alpha to Green: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="bG4" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Add to Green: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="bG5" min="-1" max="2" step=".1" value="0" />
  </div>


  <div class="c-color">
    <span class="c-color__name">Red to Blue: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="cB1" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Green to Blue: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="cB2" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Blue to Blue: </span>
    <span class="c-color__value" id="">1</span>
    <input type="range" id="cB3" min="-1" max="2" step=".1" value="1" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Alpha to Blue: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="cB4" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Add to Blue: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="cB5" min="-1" max="2" step=".1" value="0" />
  </div>


  <div class="c-color">
    <span class="c-color__name">Red to Alpha </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="dA1" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Green to Alpha: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="dA2" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Blue to Alpha: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="dA3" min="-1" max="2" step=".1" value="0" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Alpha to Alpha: </span>
    <span class="c-color__value" id="">0</span>
    <input type="range" id="dA4" min="-1" max="2" step=".1" value="1" />
  </div>
  <div class="c-color">
    <span class="c-color__name">Add to Alpha: </span>
    <span class="c-color__value" id="">1</span>
    <input type="range" id="dA5" min="-1" max="2" step=".12" value="0" />
  </div>
  <div class="c-color">
    <button class="js-toggle-filter o-button">Toggle filter on/off</button>
  </div>
</div>
<div class="c-code">
  <small>
   Filter Code:
  </small>

  <pre class="js-show-code c-code__pre">Change the parameters and the feColorMatrix code will appear here</pre>
</div>
              
            
!

CSS

              
                @import 'https://fonts.googleapis.com/css?family=Fira+Mono';
* + * {
  margin-top: 0.5em;
}
* {
  box-sizing: border-box;
}
body{
  font: normal 1em/1.25 "Fira Mono";
  background-color: rgb(41, 41, 41);
  color: white;
}
a{
  color: currentColor;
}

.c-preview{
  width: 50%;
  padding: 1em;
  position: fixed;
  top: 0;
  left: 0;
  width: calc(100vw - 275px);
  height: 100vh;
  display: flex;
  align-content: center;
  justify-content: center;
}

.c-preview__image{
  object-fit: contain;
  width: 100%;
}

.svg-filter{
  -webkit-filter: url('#svgfilter');
  filter: url('#svgfilter');
}
.s-filter--off .svg-filter{
  -webkit-filter: none;
  filter: none;
}

.c-code{
  position: fixed;
  bottom: 2em;
  left: 2em;
  max-width: 500px;
  z-index: 200;
  background-color: rgb(17, 17, 17);
  padding: 1em;
}

.c-code__pre{
  color: #454545;
  white-space: pre-line;
  margin-bottom: 0;
}

.c-controls{
  position: relative;
  z-index: 100;
  padding-bottom: 4em;
  width: 250px;
  float: right;
}
.c-controls__head{
  padding: 0.5em;
}

.c-color{
  width: 100%;
  padding: 0.5em 1em;
  border: 1px solid rgb(27, 27, 29);
}

.c-color__name, .c-color__value{
  font-size: 0.75em;
}

input[type=range] {
  -webkit-appearance: none; 
  width: 100%; 
  height: 1em;
  background: transparent;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
}

input[type=range]:focus {
  outline: none;
}


input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  border: none;
  position: relative;
  top: 50%;
  height: 0.7em;
  margin-top: -0.35em;
  width: 2em;
  border-radius: 5px;
  background: white;
  cursor: pointer;
}


input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  cursor: pointer;
  background: rgb(27, 27, 29);
  border: none;
  height: 0.5em;
  border-radius: 5px;
  transition: all 300ms ease-out;
}

input[type=range]:hover::-webkit-slider-runnable-track {
  height: 1em;
}

.o-button{
  -webkit-appearance: none;
  border: none;
  background-color: transparent;
  color: currentColor;
  font-family: inherit;
  font-size: 0.75em;
  padding: 1em 0;
}
.o-button:focus{
  outline: none;
}


              
            
!

JS

              
                
var colorMatrix = document.getElementById("svgcolormatrix");
var rangeSliders = Array.apply(null, document.querySelectorAll('input[type="range"]'));
var colorMatrixObject = {};
var showCodeIn = document.querySelector('.js-show-code');

function updateMatrix(colorID, value){
  colorMatrixObject[colorID] = value.toString();
  var matrixArray = [];
  for(var val in colorMatrixObject){
    matrixArray.push(colorMatrixObject[val]);
  }
  colorMatrix.setAttribute("values", matrixArray.join(' '));
}

function getCode(el){
  var nodeClone = el.cloneNode(true);
  var tmp = document.createElement('div');
      tmp.appendChild(nodeClone);
  
  return tmp.innerHTML;
}

function onRangeChange(rangeSlider){
  var sliderValue = Math.round(rangeSlider.value*10)/10;
      rangeSlider.previousElementSibling.innerHTML = sliderValue;
  updateMatrix(rangeSlider.id, sliderValue);
  showCodeIn.textContent = getCode(colorMatrix);
}

rangeSliders.forEach(function(rangeSlider){
  var t = rangeSlider;
  updateMatrix(t.id, t.value);
  rangeSlider.addEventListener('change', function(){
    onRangeChange(rangeSlider);
  }, false);
});


document.querySelector('.js-toggle-filter').addEventListener('click', function(){
  document.body.classList.toggle('s-filter--off');
})


              
            
!
999px

Console