Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ 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

Auto Save

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

              
                <link href='//fonts.googleapis.com/css?family=Signika+Negative:300,400' rel='stylesheet' type='text/css'>

<div class="wrapper">
  
  <h2>PixiPlugin Filter Effects</h2>
  <div class="demo">
  <img src="https://assets.codepen.io/16327/car-dashboard-blur.jpg" width="300" height="300" cross-origin="anonymous">
  <canvas id="PixiApp" width="300" height="300"></canvas>
  </div>
  
  <pre class="code prettyprint lang-js">//sample code</pre>
  <div class="nav"></div>
  <form>
  <div>
    <input type="checkbox" id="combineCMF" name="combineCMF" value="false">
    <label for="combineCMF">combineCMF:true</label>
  </div>
    <p class="explanation">When combineCMF is set to true, the newly applied ColorMatrixFilter will preserve any previously-set "hue", "saturation", "brightness", "contrast", and "colorize" values. So if you desaturate the image and then increase brightness you will get a very bright grayscale image. However, if you desaturate the image and then click "colorize red" or "hue 180" you will not see any color change as the image will still have saturation of 0. combineCMF is false by default.</p>
</form>
  
  
</div>

              
            
!

CSS

              
                /* Global styles come from external css https://codepen.io/GreenSock/pen/JGaKdQ*/
button {
  margin:0 6px 6px 0;
  padding: 9px 18px;
}
.explanation {
  font-weight: 300;
}



/*
 * Derived from einaros's Sons of Obsidian theme at
 * http://studiostyl.es/schemes/son-of-obsidian by
 * Alex Ford of CodeTunnel:
 * http://CodeTunnel.com/blog/post/71/google-code-prettify-obsidian-theme
 */

.str
{
    color: #EC7600;
}
.kwd
{
    color: #93C763;
}
.com
{
    color: #66747B;
}
.typ
{
    color: #678CB1;
}
.lit
{
    color: #FACD22;
}
.pun
{
    color: #F1F2F3;
}
.pln
{
    color: #9a8297;
}
.tag
{
    color: #8AC763;
}
.atn
{
    color: #E0E2E4;
}
.atv
{
    color: #EC7600;
}
.dec
{
    color: purple;
}
pre.prettyprint
{
    border: 0px solid #888;
}
ol.linenums
{
    margin-top: 0;
    margin-bottom: 0;
}
.prettyprint {
    background: #000;
}
li.L0, li.L1, li.L2, li.L3, li.L4, li.L5, li.L6, li.L7, li.L8, li.L9
{
    color: #555;
    list-style-type: decimal;
}
li.L1, li.L3, li.L5, li.L7, li.L9 {
    background: #111;
}
@media print
{
    .str
    {
        color: #060;
    }
    .kwd
    {
        color: #006;
        font-weight: bold;
    }
    .com
    {
        color: #600;
        font-style: italic;
    }
    .typ
    {
        color: #404;
        font-weight: bold;
    }
    .lit
    {
        color: #044;
    }
    .pun
    {
        color: #440;
    }
    .pln
    {
        color: #000;
    }
    .tag
    {
        color: #006;
        font-weight: bold;
    }
    .atn
    {
        color: #404;
    }
    .atv
    {
        color: #060;
    }
}

pre.prettyprint.code {
  padding:10px;
  margin-left:0px;
}

button:hover {
  background-color: #333;
  background-image: none;
}
              
            
!

JS

              
                var image, currentButton, 
    combineCMF = false;
var app = new PIXI.Application({
    width:300,
    height:300,
		backgroundColor: 0x000000, 
    autoResize: true, 
    view:document.getElementById("PixiApp")
});

function createEffect(name, code, onVars, offVars){
  var button = $("<button/>").text(name).appendTo(".nav"),
      style = button[0].style;
  button[0]._enabled = false;
  button.click(function() {
    var isEnabled = !this._enabled;
    if (!combineCMF || name === "reset") {
      $(".nav button").each(function() {
        this.style.removeProperty("background-image");
        this.style.removeProperty("background-color");
        this._enabled = false;
      });
    }
    currentButton = this;
    this._enabled = isEnabled;
    var vars = isEnabled ? onVars : offVars;
    vars.combineCMF = combineCMF;
    gsap.to(image, {duration:1, pixi:vars});
    if (isEnabled) {
      style.backgroundImage = "none";
      style.backgroundColor = "#4e9816";
      $(".code").text("gsap.to(image, {duration: 1, pixi:{" + code + ((combineCMF && name.indexOf("blur") === -1 && name !== "reset")  ? ", combineCMF:true" : "") + "}});").removeClass("prettyprinted");
    } else {
      gsap.set(this, {clearProps:"backgroundImage,backgroundColor"});
    }
    
    PR.prettyPrint(); 
  });
}

//toggle combineCMF
$('#combineCMF').click(function(){
  combineCMF = $(this).is(':checked');
  if (currentButton) {
    currentButton.click();
  }
});


image = PIXI.Sprite.from("https://assets.codepen.io/16327/car-dashboard-blur.jpg"); //previously used this, but ran into CORS issues: new PIXI.Sprite(resources.image.texture);
image.width = image.height = 300;
app.stage.addChild(image);
createEffect("colorize red", 'colorize:"red", colorizeAmount:1', {colorize:"red", colorizeAmount:1}, {colorize:"red", colorizeAmount:0});
createEffect("desaturate", "saturation:0", {saturation:0}, {saturation:1});
createEffect("hue 180", 'hue:180', {hue:180}, {hue:0});
createEffect("brightness", 'brightness:3', {brightness:3}, {brightness:1});
createEffect("contrast", 'contrast:3', {contrast:3}, {contrast:1});
createEffect("blur", 'blur:20', {blur:10}, {blur:0});
createEffect("reset", 'colorMatrixFilter:null, blur:0', {colorMatrixFilter:null, blur:0}, {colorMatrixFilter:null, blur:0});



              
            
!
999px

Console