Jump to content

Define Location of Pixi.js on Page within Canvas


Recommended Posts

I have a little pixi.js JavaScript I would like to have placed on a specific place on a wordpress page. Right now, it is displaying at the bottom of the page, despite me defining that it should be placed within a canvas.

(it seems to render correctly on here, but not on my wordpress site)

Please let me know where I went wrong.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <meta charset="UTF-8" />
        <title>Test Page</title>
        <script src="https://pixijs.download/release/pixi.min.js"></script>
        Some pre-image text goes here <br /><br />        
        <canvas id="myCanvas" width="683" height="455" style="border:8px solid #076e21; width:683; height:455;">
        <img src="https://devlucidpix.wpengine.com/wp-content/uploads/2019/12/4-illumination-tree-lights-morton-arboretum.jpg" width="683" height="455" alt=""/>
        let app = new PIXI.Application({width:683, height:455, antialias:true, view:myCanvas});
        let img = new PIXI.Sprite.from("https://devlucidpix.wpengine.com/wp-content/uploads/2019/12/4-illumination-tree-lights-morton-arboretum.jpg");
        img.width = 683;
        img.height =455;
        depthMap = new PIXI.Sprite.from("https://devlucidpix.wpengine.com/wp-content/uploads/2019/12/4-illumination-tree-lights-morton-arboretum_depth.jpg");
        depthMap.width = 683;
        depthMap.height = 455;
        displacementFilter = new PIXI.filters.DisplacementFilter(depthMap);
        app.stage.filters = [displacementFilter];
        window.onmousemove = function(e) {
        displacementFilter.scale.x = (window.innerWidth / 2 - e.clientX) /20;
        displacementFilter.scale.y = (window.innerHeight / 2 - e.clientY) /20;
        <br /><br />
        And here's some text after it. 


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...