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

pixi-picture

v2.0.4

Published

PixiJS v7 backport to v5, advanced filter renderer, implements advanced blending modes

Downloads

62

Readme

@pixi/picture - PixiJS Picture Kit

Compatible with PixiJS 7.2.0 and up. No guarantee for earlier versions!

Usage

import * as PIXI from 'pixi.js';
import {Sprite, getBlendFilter} from '@pixi/picture';
// hacked sprite or tilingSprite
const sprite = new Sprite();
sprite.blendMode = PIXI.BLEND_MODES.OVERLAY;
// for other kind of elements
const graphics = new PIXI.Graphics();
graphics.filters = [getBlendFilter(PIXI.BLEND_MODES.OVERLAY)];

Tutorials

  • http://www.shukantpal.com/blog/pixijs/pixijs-picture-kit/

Known bugs

  • renderer.render(stage, {transform}) produces wrong result if transform has scale

Blend-modes emulated through filters

Allows to use blendModes that are not available in pure webgl implementation, such as PIXI.BLEND_MODES.OVERLAY.

Please, don't add children to sprite if you use those blendModes.

Use import { Sprite } from '@pixi/picture' instead of PIXI.Sprite (do not use Sprite.from). You can re-export it instead of pixi sprite if you use custom pixi build.

Overlay example

Logic: if sprite has special blendMode, push corresponding filter getBlendFilter(blendMode), if area is too small (<1px), dont draw at all.

If you want to use this with any components - just look in the source of Sprite how its done.

Assigning a filter to component directly container.filters = [getBlendFilter(blendMode)] should work too.

To be fixed: At the moment this implementation is a bit worse than v4, it uses extra pass for filter.

Heavenly filter feature

Enables backdropSampler uniform in filters, works only if you render stage to renderTexture or you have a filter somewhere in parents.

Sample DisplacementFilter takes everything from container and applies it as a displacement texture on backdrop.

Note: Currently, if there is a filter that uses backdrop on the element - all filters use resolution from backdrop, you cannot set custom resolution for them!

Displacement example

Pixelate example

Drawing from main framebuffer

Since version 3.0.1, pixi-picture finally does not need filter above it. However, that comes with a problem: WebGL main framebuffer is flipped by Y.

You have to use backdropSampler_flipY uniform in your blend filters to transform Y coord in case renderTexture was flipped.

If specified useContextAlpha: false in renderer creation parameters, main framebuffer is RGB and not RGBA, its not possible to copyTex it, you will see corresponding warning message in the console.

When using MaskFilter with maskBefore=true, input is automatically flipped by Y. This operation is not needed if your base filter does not care about flipping Y, for example BlurFilter or ColorMatrixFilter. In this case, you can specify maskFilter.safeFlipY=true, that will turn off extra flipping.

Vanilla JS, UMD build

All pixiJS v6 plugins has special umd build suited for vanilla. Navigate pixi-picture npm package, take dist/pixi-picture.umd.js file.

<script src='lib/pixi.js'></script>
<script src='lib/pixi-picture.umd.js'></script>
let sprite = new PIXI.picture.Sprite();

Previous versions

For PixiJS v5 and prior see README pixi-v5 branch, or just use npm package pixi-picture For PixiJS v6 see pixi-v6 branch , npm version 3.0.6

How to build

pnpm install
pnpm run build