cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <!--  
SVG DUOTONE FILTERS
1. feColorMatrix to grayscale the image 
2. feComponentTransfer to calculate the RGB values of the two colors in the gradient map
   ex: #01283c == R(1) G(40) B(60). Divide each RGB value by 255 to get the matrix value

   <feFuncR type="table" tableValues="(1/255 = 0.003921568627) 0.007843137255"></feFuncR>
   <feFuncG type="table" tableValues="(40/255 = 0.1568627451) 0.3803921569"></feFuncG>
   <feFuncB type="table" tableValues="(60/255 = 0.2352941176) 0.5725490196"></feFuncB>
   <feFuncA type="table" tableValues="0 1"></feFuncA>
-->

<svg class="duotone-filters" xmlns="http://www.w3.org/2000/svg">	
    <filter id="duotone_darkblue">
        <feColorMatrix type="matrix" values="0.2126 0.7152 0.0722 0 0
            0.2126 0.7152 0.0722 0 0
            0.2126 0.7152 0.0722 0 0
            0 0 0 1 0" result="gray">
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0.003921568627 0.007843137255"></feFuncR>
            <feFuncG type="table" tableValues="0.1568627451 0.3803921569"></feFuncG>
            <feFuncB type="table" tableValues="0.2352941176 0.5725490196"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter>
  
    <filter id="duotone_redblue">
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone"> 
            <feFuncR type="table" tableValues="0.00294117647058825 0.9372549019607843"></feFuncR>
            <feFuncG type="table" tableValues="0.11372549019607843 0.19215686274509805"></feFuncG>
            <feFuncB type="table" tableValues="0.403921568627451 0.1411764705882353"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer> 
    </filter>

    <filter id="duotone_lightblue">
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0.1960784314 0.5764705882"></feFuncR>
            <feFuncG type="table" tableValues="0.03921568627 0.8431372549"></feFuncG>
            <feFuncB type="table" tableValues="0.2549019608 0.9803921569"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter> 

    <filter id="duotone_bluedarkorange">
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0 0.9882352941"></feFuncR>
            <feFuncG type="table" tableValues="0.1411764706 0.4862745098"></feFuncG>
            <feFuncB type="table" tableValues="0.2117647059 0.3176470588"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter> 

    <filter id="duotone_blueorange">
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0 0.9568627451"></feFuncR>
            <feFuncG type="table" tableValues="0.1411764706 0.5921568627"></feFuncG>
            <feFuncB type="table" tableValues="0.2117647059 0.1333333333"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter> 

    <filter id="duotone_seafoam">
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0 0.1647058824"></feFuncR>
            <feFuncG type="table" tableValues="0.1411764706 0.6588235294"></feFuncG>
            <feFuncB type="table" tableValues="0.2117647059 0.5490196078"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter>
    
    <filter id="duotone_bluetan">
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0 0.9411764706"></feFuncR>
            <feFuncG type="table" tableValues="0.1411764706 0.937254902"></feFuncG>
            <feFuncB type="table" tableValues="0.2117647059 0.8823529412"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter>
  
    <filter id="duotone_spotify_blue">
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0 
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0.2588235294 0.61960784317"></feFuncR>
            <feFuncG type="table" tableValues="0.1333333333 0.937254902"></feFuncG>
            <feFuncB type="table" tableValues="0.9450980392 0.8823529412"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter>
  
    <filter id="duotone_spotify_peachy"> 
        <feColorMatrix type="matrix" result="gray"
            values="1 0 0 0 0
                    1 0 0 0 0
                    1 0 0 0 0
                    0 0 0 1 0" >
        </feColorMatrix>

        <feComponentTransfer color-interpolation-filters="sRGB" result="duotone">
            <feFuncR type="table" tableValues="0.9294117647 0.9960784314"></feFuncR>
            <feFuncG type="table" tableValues="0.2431372549 0.7803921569"></feFuncG>
            <feFuncB type="table" tableValues="0.6431372549 0.4235294118"></feFuncB>
            <feFuncA type="table" tableValues="0 1"></feFuncA>
        </feComponentTransfer>
    </filter>
</svg> <!-- /.duotone-filters -->

<h1>Duotone SVG Filters</h1>
<ol>
  <li>feColorMatrix to grayscale the image</li>
  <li>feColorTransfer to calculate the RGB values of the two colors in the gradient map (details in HTML comments)</li>
</ol>
<p>Hover over image to view original image. The last few tiles are based on the gradient maps in <a href="https://yearinmusic.spotify.com/en-US" target="_blank">Spotify's Year in Music</a>, and the last tile is a css blendmodes variation attempt.</p>
<div class="tiles">
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile"></div>
  <div class="tile blendmode"></div>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Open+Sans:100,300,400,600);

body {
  color: #FFFFFF;
  font-family: 'Open Sans', sans-serif;
  font-size: 100%;
  background: #454f4f;
}

a {
  color: #A1C3D1;
  
  &:hover,
  &:focus {
    color: #9EEFE1;
  }
}

.duotone-filters {
    height: 0;
    left: -9999em;
    margin: 0;
    padding: 0;
    position: absolute;
    width: 0;
}

.tiles {
  display: -webkit-box;
  display: -ms-flexbox;
  -webkit-display: flex;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin: 40px 0;
}
.tile {
  background: url('https://unsplash.it/600/400/?image=441') center no-repeat;
  background-size: cover;
  height: 350px;
  // margin: 0 auto;
  transition: all 300ms ease-in-out;
  width: 500px;
  
  &:nth-of-type(1) {
    -webkit-filter: url(#duotone_darkblue);
    -moz-filter: url(#duotone_darkblue);
    -o-filter: url(#duotone_darkblue);
    -ms-filter: url(#duotone_darkblue);
    filter: url(#duotone_darkblue);
  }
  &:nth-of-type(2) {
    -webkit-filter: url(#duotone_redblue);
    -moz-filter: url(#duotone_redblue);
    -o-filter: url(#duotone_redblue);
    -ms-filter: url(#duotone_redblue);
    filter:  url(#duotone_redblue);
  }
  &:nth-of-type(3) {
    -webkit-filter: url(#duotone_bluedarkorange);
    -moz-filter: url(#duotone_bluedarkorange);
    -o-filter: url(#duotone_bluedarkorange);
    -ms-filter: url(#duotone_bluedarkorange);
    filter:  url(#duotone_bluedarkorange);
  }
  &:nth-of-type(4) {
    -webkit-filter: url(#duotone_blueorange);
    -moz-filter: url(#duotone_blueorange);
    -o-filter: url(#duotone_blueorange);
    -ms-filter: url(#duotone_blueorange);
    filter:  url(#duotone_blueorange);
  }
  &:nth-of-type(5) {
    -webkit-filter: url(#duotone_seafoam);
    -moz-filter: url(#duotone_seafoam);
    -o-filter: url(#duotone_seafoam);
    -ms-filter: url(#duotone_seafoam);
    filter:  url(#duotone_seafoam);
  }
  &:nth-of-type(6) {
    -webkit-filter: url(#duotone_lightblue);
    -moz-filter: url(#duotone_lightblue);
    -o-filter: url(#duotone_lightblue);
    -ms-filter: url(#duotone_lightblue);
    filter:  url(#duotone_lightblue);
  }
  &:nth-of-type(7) {
    -webkit-filter: url(#duotone_bluetan);
    -moz-filter: url(#duotone_bluetan);
    -o-filter: url(#duotone_bluetan);
    -ms-filter: url(#duotone_bluetan);
    filter:  url(#duotone_bluetan);
  }
  &:nth-of-type(8) {
    -webkit-filter: url(#duotone_spotify_blue);
    -moz-filter: url(#duotone_spotify_blue);
    -o-filter: url(#duotone_spotify_blue);
    -ms-filter: url(#duotone_spotify_blue);
    filter:  url(#duotone_spotify_blue);
    
    &:before {
      content: 'Spotify Gradient';
      display: block;
      margin: 20px;
    }
  }
  &:nth-of-type(9) {
    -webkit-filter: url(#duotone_spotify_peachy);
    -moz-filter: url(#duotone_spotify_peachy);
    -o-filter: url(#duotone_spotify_peachy);
    -ms-filter: url(#duotone_spotify_peachy);
    filter:  url(#duotone_spotify_peachy);
    
    &:before {
      content: 'Spotify Gradient';
      display: block;
      margin: 20px;
    }
  }
  
  &.blendmode {
    background: 
    linear-gradient(#ED3EA4 0%, #FDC66C 100%),
    url('https://unsplash.it/600/400/?image=441');
    background-blend-mode: multiply;
    position: relative;
    
    &:before {
      background: #ED3EA4;
      content: '';
      color: #ffffff;
      height: 100%;
      left: 0;
      position: absolute;
      opacity: 0.3;
      right: 0;
      top:0;
      width: 100%;
    }
    &:after {
      content: 'CSS Blendmode variation: Close enough, right? *shrug*';
      left: 0;
      padding: 20px;
      position: absolute;
      top: 0;
    }
  }
  
  &:hover,
  &:focus {
    -webkit-filter: none;
    filter: none;
    background-blend-mode: normal;
  }
  
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console