Convert Figma logo to code with AI

pixijs logopixijs

The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.

44,341
4,818
44,341
400

Top Related Projects

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.

5,970

a fresh, modern & lightweight HTML5 game engine

10,014

Powerful web graphics runtime built on WebGL, WebGPU, WebXR and glTF

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.

Quick Overview

PixiJS is a fast, lightweight 2D rendering library for the web. It uses WebGL for hardware-accelerated graphics and falls back to HTML5 Canvas when WebGL isn't available. PixiJS is designed to create interactive graphics, animations, and games that run smoothly across various devices and browsers.

Pros

  • High performance due to WebGL rendering
  • Easy to learn and use, with a simple API
  • Cross-platform compatibility (desktop and mobile)
  • Active community and regular updates

Cons

  • Limited 3D capabilities compared to dedicated 3D engines
  • Steeper learning curve for complex projects
  • Some features may require additional plugins or extensions

Code Examples

Creating a basic sprite:

import * as PIXI from 'pixi.js';

const app = new PIXI.Application();
document.body.appendChild(app.view);

const sprite = PIXI.Sprite.from('path/to/image.png');
app.stage.addChild(sprite);

Animating a sprite:

const sprite = PIXI.Sprite.from('path/to/image.png');
app.stage.addChild(sprite);

app.ticker.add((delta) => {
    sprite.rotation += 0.1 * delta;
});

Creating a simple particle system:

const particles = new PIXI.ParticleContainer();
app.stage.addChild(particles);

for (let i = 0; i < 100; i++) {
    const particle = PIXI.Sprite.from('path/to/particle.png');
    particle.x = Math.random() * app.screen.width;
    particle.y = Math.random() * app.screen.height;
    particles.addChild(particle);
}

Getting Started

  1. Install PixiJS using npm:

    npm install pixi.js
    
  2. Create a basic HTML file:

    <!DOCTYPE html>
    <html>
      <head>
        <script src="https://pixijs.download/release/pixi.min.js"></script>
      </head>
      <body>
        <script>
          const app = new PIXI.Application();
          document.body.appendChild(app.view);
          
          // Your PixiJS code here
        </script>
      </body>
    </html>
    
  3. Start creating your PixiJS application by adding sprites, graphics, and interactivity within the script tag.

Competitor Comparisons

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.

Pros of Cocos Engine

  • More comprehensive game development framework with built-in tools and editors
  • Better suited for complex 3D game development
  • Stronger community support and extensive documentation

Cons of Cocos Engine

  • Steeper learning curve due to its complexity
  • Heavier and more resource-intensive than PixiJS
  • Less flexibility for custom rendering pipelines

Code Comparison

PixiJS (JavaScript):

const app = new PIXI.Application();
document.body.appendChild(app.view);
const sprite = PIXI.Sprite.from('image.png');
app.stage.addChild(sprite);

Cocos Engine (TypeScript):

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    onLoad() {
        const sprite = this.node.addComponent(cc.Sprite);
        sprite.spriteFrame = cc.resources.get('image', cc.SpriteFrame);
    }
}

PixiJS is a lightweight 2D rendering engine focused on performance and ease of use. It's ideal for simple 2D games and interactive web applications. Cocos Engine, on the other hand, is a full-featured game development framework supporting both 2D and 3D games. It offers a more comprehensive set of tools but requires a deeper understanding of game development concepts.

While PixiJS allows for quick prototyping and simple implementations, Cocos Engine provides a more structured approach to game development with its component-based architecture. The choice between the two depends on the project's complexity, performance requirements, and the developer's familiarity with game development concepts.

5,970

a fresh, modern & lightweight HTML5 game engine

Pros of melonJS

  • Built-in physics engine and collision detection
  • Integrated level editor (Tiled) support
  • Smaller file size, potentially better for lightweight projects

Cons of melonJS

  • Less active community and fewer updates
  • More limited rendering capabilities
  • Steeper learning curve for beginners

Code Comparison

melonJS:

me.game.world.addChild(new me.Sprite(0, 0, {
    image: "background"
}));
me.game.world.addChild(new me.Entity(50, 50, {
    width: 32,
    height: 32
}));

PixiJS:

const sprite = PIXI.Sprite.from("background.png");
app.stage.addChild(sprite);
const graphics = new PIXI.Graphics();
graphics.beginFill(0xFF0000);
graphics.drawRect(50, 50, 32, 32);
app.stage.addChild(graphics);

melonJS is more focused on game development with built-in physics and entity systems, while PixiJS offers a more flexible and powerful rendering engine suitable for various interactive graphics applications. melonJS provides an integrated approach to game development, whereas PixiJS requires additional libraries for game-specific features but offers more flexibility in graphics manipulation.

10,014

Powerful web graphics runtime built on WebGL, WebGPU, WebXR and glTF

Pros of PlayCanvas Engine

  • Full 3D game engine with advanced features like physics and lighting
  • Integrated visual editor for easier game development
  • Better performance for complex 3D scenes and large-scale projects

Cons of PlayCanvas Engine

  • Steeper learning curve due to more complex API and 3D concepts
  • Larger file size and potentially slower initial load times
  • Less suitable for simple 2D games or applications

Code Comparison

PlayCanvas Engine (3D scene setup):

var app = new pc.Application(canvas);
var camera = new pc.Entity();
camera.addComponent('camera', { clearColor: new pc.Color(0.1, 0.1, 0.1) });
app.root.addChild(camera);
camera.setPosition(0, 0, 3);

PixiJS (2D scene setup):

const app = new PIXI.Application({ width: 800, height: 600 });
document.body.appendChild(app.view);
const sprite = PIXI.Sprite.from('image.png');
app.stage.addChild(sprite);

PlayCanvas Engine is better suited for complex 3D games and applications, offering a comprehensive set of tools and features. PixiJS, on the other hand, excels in 2D rendering and is more lightweight, making it ideal for simpler 2D games and interactive web content. The choice between the two depends on the specific requirements of your project.

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.

Pros of Babylon.js

  • More powerful 3D rendering capabilities
  • Built-in physics engine and advanced lighting features
  • Larger community and more extensive documentation

Cons of Babylon.js

  • Steeper learning curve for beginners
  • Heavier file size and potentially slower performance for simple 2D projects
  • More complex setup and configuration

Code Comparison

PixiJS (2D rendering):

const app = new PIXI.Application();
document.body.appendChild(app.view);
const sprite = PIXI.Sprite.from('image.png');
app.stage.addChild(sprite);
app.ticker.add(() => sprite.rotation += 0.01);

Babylon.js (3D rendering):

const canvas = document.getElementById('renderCanvas');
const engine = new BABYLON.Engine(canvas, true);
const scene = new BABYLON.Scene(engine);
const camera = new BABYLON.FreeCamera('camera', new BABYLON.Vector3(0, 5, -10), scene);
engine.runRenderLoop(() => scene.render());

PixiJS is more suitable for 2D graphics and games, offering simpler setup and faster performance for 2D projects. Babylon.js excels in 3D rendering and complex scenes, providing more advanced features at the cost of increased complexity and resource usage.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

PixiJS logo


npm package build status Start new PR in StackBlitz Codeflow discord chat

Examples | Getting Started | Documentation | Discord

PixiJS ⚡️

Next-Generation, Fastest HTML5 Creation Engine for the Web

  • 🚀 WebGL & WebGPU Renderers
  • ⚡️ Unmatched Performance & Speed
  • 🎨 Easy to use, yet powerful API
  • 📦 Asset Loader
  • ✋ Full Mouse & Multi-touch Support
  • ✍️ Flexible Text Rendering
  • 📐 Versatile Primitive and SVG Drawing
  • 🖼️ Dynamic Textures
  • 🎭 Masking
  • 🪄 Powerful Filters
  • 🌈 Advanced Blend Modes

PixiJS is the fastest, most lightweight 2D library available for the web, working across all devices and allowing you to create rich, interactive graphics and cross-platform applications using WebGL and WebGPU.

Setup

It's easy to get started with PixiJS! Just use our PixiJS Create CLI and get set up in just one command:

Screenshot from terminal

npm create pixi.js@latest

or to add it to an existing project:

npm install pixi.js

Usage

import { Application, Assets, Sprite } from 'pixi.js';

(async () =>
{
    // Create a new application
    const app = new Application();

    // Initialize the application
    await app.init({ background: '#1099bb', resizeTo: window });

    // Append the application canvas to the document body
    document.body.appendChild(app.canvas);

    // Load the bunny texture
    const texture = await Assets.load('https://pixijs.com/assets/bunny.png');

    // Create a bunny Sprite
    const bunny = new Sprite(texture);

    // Center the sprite's anchor point
    bunny.anchor.set(0.5);

    // Move the sprite to the center of the screen
    bunny.x = app.screen.width / 2;
    bunny.y = app.screen.height / 2;

    app.stage.addChild(bunny);

    // Listen for animate update
    app.ticker.add((time) =>
    {
        // Just for fun, let's rotate mr rabbit a little.
        // * Delta is 1 if running at 100% performance *
        // * Creates frame-independent transformation *
        bunny.rotation += 0.1 * time.deltaTime;
    });
})();

Contribute

Want to be part of the PixiJS project? Great! All are welcome! We will get there quicker together :) Whether you find a bug, have a great feature request, or you fancy owning a task from the road map above, feel free to get in touch.

Make sure to read the Contributing Guide before submitting changes.

License

This content is released under the MIT License.

Change Log

Releases

Support

We're passionate about making PixiJS the best graphics library possible. Our dedication comes from our love for the project and community. If you'd like to support our efforts, please consider contributing to our open collective.

NPM DownloadsLast 30 Days