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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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://s3-us-west-2.amazonaws.com/s.cdpn.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>

            
          
!
            
              /* 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;
}
            
          
!
            
              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;
    TweenLite.to(image, 1, {pixi:vars});
    if (isEnabled) {
      style.backgroundImage = "none";
      style.backgroundColor = "#4e9816";
      $(".code").text("TweenLite.to(image, 1, {pixi:{" + code + ((combineCMF && name.indexOf("blur") === -1 && name !== "reset")  ? ", combineCMF:true" : "") + "}});").removeClass("prettyprinted");
    } else {
      TweenLite.set(this, {clearProps:"backgroundImage,backgroundColor"});
    }
    
    PR.prettyPrint(); 
  });
}

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


image = PIXI.Sprite.from("http://s3-us-west-2.amazonaws.com/s.cdpn.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
🕑 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.

Console