PIXIJS 9Slice

9 Slice Problem

by Jonny Shaw

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.5.2/pixi.js"></script>

JavaScript

var app = new PIXI.Application(640, 640, {
  backgroundColor: 0x000000
}); // The PIXI Application
document.body.appendChild(app.view);

showNineSlice();

function showNineSlice() {
  var useme = new PIXI.Texture.fromImage("http://i.imgur.com/EdPfSFC.png");
  var bubble = new PIXI.mesh.NineSlicePlane(useme, 20, 41, 85, 24);
  app.stage.addChild(bubble);
  bubble.width = 200;
  bubble.height = 200;
  bubble.x = app.renderer.width / 2 - bubble.width / 2;
  bubble.y = app.renderer.height / 2 - bubble.height / 2;
}