Skip to content

Instantly share code, notes, and snippets.

@nasser
Last active November 17, 2021 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasser/83fdd0ccf7c4b826b502ddcc4355302b to your computer and use it in GitHub Desktop.
Save nasser/83fdd0ccf7c4b826b502ddcc4355302b to your computer and use it in GitHub Desktop.
a pixi.js boilerplate scene in a single 16 line self-contained html file
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reset-css@5.0.1/reset.min.css">
<script type="module">
import * as PIXI from "https://cdnjs.cloudflare.com/ajax/libs/pixi.js/6.2.0/browser/pixi.min.mjs"
let app = new PIXI.Application()
document.body.appendChild(app.view)
window.onresize = function() {
app.renderer.resize(window.innerWidth, window.innerHeight)
app.stage.position = { x:window.innerWidth/2, y:window.innerHeight/2 }
}
window.onresize()
const dog = PIXI.Sprite.from('https://placedog.net/500?random')
dog.anchor.set(.5)
app.stage.addChild(dog)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment