Giter Site home page Giter Site logo

vue-pixi's Introduction

Vue-PIXI

v0.2.1 Based on PIXI v5.1.0

A Vue.js plugin for PIXI.js. Currently it is more a proof of concept that an actual library but it will get there eventually. Greatly inspired by Vue-gl.

Getting Started

First install the package.

npm install --save vue-pixi

Then add it to Vue.js

import Vue from 'vue'
import VuePIXI from 'vue-pixi'

Vue.use(VuePIXI)

Example

<template lang="html">
  <section>
    <pixi-renderer
      @tick="update"
      :backgroundColor="0x0078FF"
      :height="480"
      :width="640"
    >
      <pixi-container
        :x="320" :y="240"
        :rotation="-t / 40"
      >
        <pixi-sprite v-for="(sprite, key) in sprites" :key="key"
          src="/img/logo.png"
          :x="sprite.x" :y="sprite.y"
          :scaleX="sprite.scale" :scaleY="sprite.scale"
          :anchorX="0.5" :anchorY="0.5"
          :rotation="sprite.angle + t / 60" />
      </pixi-container>
    </pixi-renderer>
  </section>
</template>

<script>
export default {
  data () {
    return { t: 0, sprites: [] }
  },
  methods: {
    addSprite () {
      this.sprites.push({
        x: 640 * (0.5 - Math.random()),
        y: 480 * (0.5 - Math.random()),
        angle: 2 * Math.PI * Math.random(),
        scale: 0.25 + 0.5 * Math.random(),
      })
    },
    update (dt) { this.t += dt }
  },
  created () {
    this.addSprite()
    this.addSprite()
    this.addSprite()
  }
}
</script>

Project setup

npm install

Compiles and hot-reloads the demo for development

npm run serve

Compiles and minifies the library for production

npm run build

Lints and fixes files

npm run lint

vue-pixi's People

Contributors

granipouss avatar jjhesk avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

nejcjelovcan

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.