Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/filter-displacement

Package Overview
Dependencies
Maintainers
2
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/filter-displacement

Filter that allows offsetting of pixel values to create warping effects

  • 7.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
112K
decreased by-10.06%
Maintainers
2
Weekly downloads
 
Created

What is @pixi/filter-displacement?

@pixi/filter-displacement is a filter for the PixiJS library that allows developers to create displacement effects on display objects. This can be used to create a variety of visual effects such as water ripples, heat haze, or any effect that requires the distortion of pixels based on a displacement map.

What are @pixi/filter-displacement's main functionalities?

Basic Displacement Effect

This code demonstrates how to apply a basic displacement effect to a sprite using a displacement map. The displacement map is another image that defines how the pixels of the original image should be displaced.

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

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

const displacementSprite = PIXI.Sprite.from('path/to/displacement_map.png');
const displacementFilter = new PIXI.filters.DisplacementFilter(displacementSprite);

app.stage.addChild(displacementSprite);
sprite.filters = [displacementFilter];

displacementSprite.x = app.renderer.width / 2;
displacementSprite.y = app.renderer.height / 2;

Animating Displacement

This code snippet shows how to animate the displacement effect by moving the displacement map over time. This can create dynamic effects like moving water or shifting heat haze.

app.ticker.add(() => {
  displacementSprite.x += 1;
  displacementSprite.y += 1;
});

Other packages similar to @pixi/filter-displacement

FAQs

Package last updated on 22 Sep 2023

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