Giter Site home page Giter Site logo

expo-pixi's Introduction

expo-pixi

Tools to use Pixi.js in Expo!

To get started: yarn add expo-pixi in your Expo project and import it with import ExpoPixi from 'expo-pixi';.

Functions

ExpoPixi.application(props): PIXI.Application

A helper function to create a PIXI.Application from a WebGL context. EXGL knows to end a frame when the function: endFrameEXP is called on the GL context.

context is the only required prop.

Learn more about PIXI.Application props

ExpoPixi.textureAsync(resource: any): Promise

ExpoPixi.spriteAsync(resource: any): Promise

a helper function to resolve the asset passed in. textureAsync accepts:

You cannot send in relative string paths as Metro Bundler looks for static resources.


ExpoPixi.sprite({ localUri: string, width: number, height: number }): PIXI.Sprite

ExpoPixi.texture({ localUri: string, width: number, height: number }): PIXI.Texture

Pixi.js does a type check so we wrap our asset in a HTMLImageElement shim.

ExpoPixi.Sketch

A component used for drawing smooth signatures and sketches.

See the sketch example on how to save the images!

Notice: the edges and ends are not rounded as this is not supported in PIXI yet: Issue

Props

Property Type Default Description
strokeColor number 0x000000 Color of the lines
strokeWidth number 10 Weight of the lines
strokeAlpha number 1 Opacity of the lines
onChange () => PIXI.Renderer null Invoked whenever a user is done drawing a line
onReady () => WebGLRenderingContext null Invoked when the GL context is ready to be used

ExpoPixi.FilterImage

A Image component that uses PIXI.Filter

Props

Property Type Default Description
resizeMode string null Currently only supports cover, and contain
filters Array<PIXI.Filter> null Array of filters to apply to the image
source number, string, Expo.Asset null Source can be a static resource, image url (not {uri}), or an Expo.Asset

Example

Snack

import React from 'react';
import Expo from 'expo';
import ExpoPixi from 'expo-pixi';

export default () => (
  <Expo.GLView
    style={{ flex: 1 }}
    onContextCreate={async context => {
      const app = ExpoPixi.application({ context });
      const sprite = await ExpoPixi.spriteAsync(
        'http://i.imgur.com/uwrbErh.png',
      );
      app.stage.addChild(sprite);
    }}
  />
);

NPM

expo-pixi's People

Contributors

evanbacon avatar tsapeta avatar

Watchers

 avatar

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.