Git Product home page Git Product logo

Comments (2)

nuthinking avatar nuthinking commented on May 22, 2024

Taking inspiration from the repo native-component-list I managed to animate a filter. Performances are not that bad.

import React from 'react';
import { Dimensions } from 'react-native';
import GLWrap from './GLWrap';
import './BeforePIXI';
import * as filters from 'pixi-filters';
import * as PIXI from 'pixi.js';

PIXI.filters = { ...(PIXI.filters || {}), ...filters };

const filter = new PIXI.filters.PixelateFilter();

const PixiView = GLWrap('pixi.js sprite rendering', async gl => {
  const { scale: resolution } = Dimensions.get('window');
  const width = gl.drawingBufferWidth / resolution;
  const height = gl.drawingBufferHeight / resolution;
  const app = new PIXI.Application({
    context: gl,
    width,
    height,
    resolution,
    backgroundColor: 0xffffff,
  });

  const asset = Expo.Asset.fromModule(require('./assets/images/kylie.png'));
  await asset.downloadAsync();
  const image = new HTMLImageElement(asset);
  const sprite = PIXI.Sprite.from(image);
  sprite.filters= [filter];
  app.stage.addChild(sprite);
  app.ticker.add(() => {
    filter.size = 100 + Math.cos(Date.now()*0.001)*200;
    gl.endFrameEXP();
  });
});

export default class App extends React.Component {
  render() {
    return <PixiView />;
  }
}

from expo-pixi.

EvanBacon avatar EvanBacon commented on May 22, 2024

Nice solution! Looks like we should surface an update function so you can try and keep it reacty. :]

from expo-pixi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.