npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@enea-entertainment/pixi-blend-modes-batch

v1.0.4

Published

Emulates BLEND_MODES.ADD using BLEND_MODES.NORMAL

Downloads

25

Readme

BlendModesBatchRenderer plugin for PixiJS

Emulates BLEND_MODES.ADD using BLEND_MODES.NORMAL and batches sprites with these blend modes into a single draw call

Notice:

unless BlendModesBatchRenderer.forceAddBlend is set to true (default is false) any blend mode other than BLEND_MODES.NORMAL and BLEND_MODES.ADD will break the batch.

If BlendModesBatchRenderer.forceAddBlend = true then all other blend modes except BLEND_MODES.NORMAL will be treated as BLEND_MODES.ADD


Installation

npm install --save-dev @enea-entertainment/pixi-blend-modes-batch

NPM

PixiJS v7: npm version ^1.0.1

PixiJS v6: npm version ^0.5.0


Build

PixiJS v7: clone master branch

PixiJS v6: clone v6 branch

npm i
npm run build

Usage

Import the plugin and register it before initializing PixiJS:

import { BlendModesBatchRenderer } from '@enea-entertainment/pixi-blend-modes-batch';
import { extensions } from 'pixi.js';

extensions.add(BlendModesBatchRenderer);

Create a scene and these 2 sprites will be rendered in single draw call:


const sprite1 = new Sprite('myTexture');

// tell pixi to use BlendModesBatchRenderer
sprite1.pluginName = BlendModesBatchRenderer.extension.name;
// this is really not needed as NORMAL mode is default
sprite1.blendMode = BLEND_MODES.NORMAL;

const sprite2 = new Sprite('myOtherTexture');

// tell pixi to use BlendModesBatchRenderer
sprite2.pluginName = BlendModesBatchRenderer.extension.name;
sprite2.blendMode = BLEND_MODES.ADD;

Instead of setting pluginName property you can use helper method convertToBlendModesBatch

const sprite1 = new Sprite('myTexture');
const sprite2 = new Sprite('myOtherTexture');

// tell pixi to use BlendModesBatchRenderer
sprite1.convertToBlendModesBatch();
sprite2.convertToBlendModesBatch();

To convert whole subtree use convertSubtreeToBlendModesBatch

import { Application } from 'pixi.js';

const app = new Application();

// add some sprites to app.stage

app.stage.convertSubtreeToBlendModesBatch();

To control the intensity of 'additive blend' set the static property on BlendModesBatchRenderer before initializing the plugin:

BlendModesBatchRenderer.intensity = 0.75;

where 0 is no effect, 1 is full effect.


You can also override default Pixi's BatchRenderer:

import { BlendModesBatchRenderer } from '@enea-entertainment/pixi-blend-modes-batch';
import { BatchRenderer, extensions } from 'pixi.js';

extensions.remove(BatchRenderer);

BlendModesBatchRenderer.extension.name = 'batch';

extensions.add(BlendModesBatchRenderer);

// init PixiJS

const sprite1 = new Sprite('myTexture');
const sprite2 = new Sprite('myOtherTexture');

sprite2.blendMode = BLEND_MODES.ADD;

From now on, all scene elements that used the default Pixi batch will use BlendModesBatchRenderer. Even newly created ones, so you don't have to set or convert anything.


Inspired by pixi-heaven


License

MIT, see LICENSE for details.