How to change the background color of a PixiJS application?

/ #Pixi.js

The default background color of a PixiJS application is black and boring. Here is how you can set it to whatever you want.

The code

Create a new HTML file and add this code to it:

<!DOCTYPE html>

        <meta charset="utf-8">
        <title>PixiJS Background Color</title>

        <script src=""></script>
        <script type="text/javascript">
            // The application
            var app = new PIXI.Application({
                backgroundColor: 0x2980b9

            // Add application to the DOM

If you open up this file in your browser, you should see a nice blue colored square.

There isn't actually any magic going on here, you create the application and append it to the DOM the same way as always. The only difference is that we added a option to the "PIXI.Application". You can pass in any kind if HEX color here, just remember to prepend it with a "0x" instead of the typical "#".


No comments yet...

Add comment


Subscribe to my weekly newsletter. One time per week I will send you a short summary of the tutorials I have posted in the past week.