Skip to content

sherpal/scala-js-pixi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-js-pixi

Scala-js facade for PixiJS (v4).

Pixi is an awesome framework for 2D rendering on canvas, using either webgl or canvas-2d rendering.

This facade allows you to use Pixi from Scala with Scala-js.

The facade is far from complete. However, adding missing pieces according to your needs should be straightforward.

Documentation

The PixiJS documentation is great and there is nothing to be added to it from here. Source files point to the relevant documentation web page.

Examples

Pixi has many examples usage of the framework.

You will find the translation of (most of) these examples in the pixi-examples part of the project.

In order to run it, you first need to download all the assets here and put them in pixi-examples/html/required. Compile the project with the fastOptJS command in sbt.

Then, open a server in the root directory, and head over localhost:[port]/pixi-examples/html. You can then select the example you want to see in action. There's a link to the official PIXI example. As you can see, most of the changes from the JavaScript code to the Scala code goes along the lines:

  • copy-paste the JavaScript code
  • change PIXI.SomeClass to SomeClass
  • changing var to val
  • removing the semi-colon at end of lines
  • changing for loops into for comprehensions

Adding the canvas to the DOM is done automatically in PIXIExample.

Random thoughts

  • Until proven otherwise, all classes are final
  • We don't wrap PIXI in more convenient Scala classes, since there're already convenient as is. The major drawback is that js.Array can't be Scala collections.
  • Some examples have slightly been adapted to better correspond to a "Scala way of doing". See, e.g., the demos/Dragging example.

About

Scala-js facade for PixiJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published