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

              
                <script id="shader" type="shader">
  precision mediump float;
  
  uniform vec2 mouse;
  uniform vec2 resolution;
  uniform float time;
  void main(){
   gl_FragColor = vec4(sin(time),mouse.x/resolution.x,mouse.y/resolution.y,1.0);
  
  }
</script>
              
            
!

CSS

              
                body {
  margin: 0;
  overflow: hidden;
}
              
            
!

JS

              
                var width = window.innerWidth;//Get the screen width and height
var height = window.innerHeight;
var renderer = new PIXI.autoDetectRenderer(width, height);//Chooses either WebGL if supported or falls back to Canvas rendering
document.body.appendChild(renderer.view);//Add the render view object into the page

var stage = new PIXI.Container();//The stage is the root container that will hold everything in our scene

//Load an image and create an object
var logo = PIXI.Sprite.fromImage("http://www.goodboydigital.com/pixijs/pixi_v3_github-pad.png");
logo.x = width / 2;//Set it at the center of the screen
logo.y = height / 2;
logo.anchor.set(0.5);//Make sure the center point of the image is at its center, instead of the default top left
stage.addChild(logo)//Add it to the screen

//Create a uniforms object to send to the shader
var uniforms = {}
uniforms.mouse = {
  type:'v2',
  value: {x:0,y:0}
}
uniforms.time = {
  type:"f",
  value:0
}
uniforms.resolution = {
  type:"v2",
  value:{x:width,y:height}
}

function animate() {
    // start the timer for the next animation loop
    requestAnimationFrame(animate);
    // this is the main render call that makes pixi draw your container and its children.
    renderer.render(stage);
  
   uniforms.time.value += 0.1
}
animate()

//Get shader code as a string
var shaderCode = document.getElementById("shader").innerHTML
//Create our Pixi filter using our custom shader code
var simpleShader = new PIXI.AbstractFilter('',shaderCode,uniforms);
//Apply it to our object
logo.filters = [simpleShader]

document.onmousemove = function(evt){
  //Get the mouse position
  mousePos = {x:evt.clientX,y:evt.clientY}
  //Assigning a new value lets Pixi know to update the uniform in the shader
  // But doing something like uniforms.mouse.x = 0, won't update in this current version of Pixi
  uniforms.mouse.value = mousePos;
}
              
            
!
999px

Console