Socket
Socket
Sign inDemoInstall

pixi.js

Package Overview
Dependencies
Maintainers
3
Versions
387
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixi.js

PixiJS — The HTML5 Creation Engine =============


Version published
Weekly downloads
135K
decreased by-0.38%
Maintainers
3
Weekly downloads
 
Created

What is pixi.js?

Pixi.js is a fast 2D rendering engine that uses WebGL and HTML5 Canvas to create interactive graphics and animations. It is widely used for creating games, interactive applications, and other visual content on the web.

What are pixi.js's main functionalities?

Creating a Basic Application

This code initializes a new Pixi.js application with a specified width and height, and appends the canvas element to the document body.

const app = new PIXI.Application({ width: 800, height: 600 });
document.body.appendChild(app.view);

Loading and Displaying a Sprite

This code loads an image and creates a sprite from it. The sprite is then positioned at the center of the canvas and added to the stage.

PIXI.Loader.shared.add('bunny', 'path/to/bunny.png').load((loader, resources) => {
  const bunny = new PIXI.Sprite(resources.bunny.texture);
  bunny.x = app.renderer.width / 2;
  bunny.y = app.renderer.height / 2;
  bunny.anchor.set(0.5);
  app.stage.addChild(bunny);
});

Animating a Sprite

This code adds an animation loop that rotates the sprite continuously. The `delta` parameter ensures smooth animation regardless of the frame rate.

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

Creating Graphics

This code creates a new graphics object, draws a filled rectangle, and adds it to the stage.

const graphics = new PIXI.Graphics();
graphics.beginFill(0xDE3249);
graphics.drawRect(50, 50, 100, 100);
graphics.endFill();
app.stage.addChild(graphics);

Other packages similar to pixi.js

FAQs

Package last updated on 19 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc