Jump to content

Define Location of Pixi.js on Page within Canvas


fullerton
 Share

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">
<html>
    <head>
        <meta charset="UTF-8" />
        <title>Test Page</title>
    </head>
    <body>
        <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=""/>
        </canvas>
        
        <script>
        
        let app = new PIXI.Application({width:683, height:455, antialias:true, view:myCanvas});
        document.body.appendChild(app.view);
           
        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;
        app.stage.addChild(img);    
            
        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;
        app.stage.addChild(depthMap);
        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;
        };
            
        </script>
        <br /><br />
        And here's some text after it. 
        
    </body>

 

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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