GLantern is a library intended for a Flash-HTML5 shim layer. Enjoy the live preview from http://hozuki.github.io/green-lantern.
Screenshots of test cases can be found here.
Native git is highly recommended against other clients:
git clone https://github.com/hozuki/GLantern.gitOr, as an NPM package, you can install it via npm:
npm install glantern --saveMake sure you have Node.js and NPM installed. The rest is quite simple:
cd GLantern
npm install
gulp buildAfter building, you will find:
build/node directory for NW.js and Electron;build/GLantern-browser.js file as the full, concatenated JavaScript file for browsers;build/GLantern-browser.min.js (and corresponding source mapping) for browsers, as the
minimized file for a better loading speed.See the demo page at test/visual/index.html. You will need an environment with WebGL, like
modern browsers, NW.js, or Electron.
GLantern supports two styles of importing.
The first one is importing by <script> tag. Use its src attribute and point it to the compiled result:
<script type="text/javascript" src="GLantern-browser.min.js"></script>In environments that support Node.js, like NW.js or Electron, you can also use the require syntax:
const GLantern = require("glantern");After importing with either the former or the latter style, the GLantern object is globally available.
The package structure of Flash is preserved in GLantern, so adding a GLantern. prefix usually
works. If you want to make it more like ActionScript, GLantern provides a injectToGlobal() function
to inject the "packages" to the global scope.
// Check if GLantern is supported
if (GLantern.isSupported()) {
const lantern = new GLantern.EngineBase();
const canvas = document.createElement("canvas");
lantern.initialize(canvas, 682, 438);
document.body.appendChild(lantern.view);
window.addEventListener("unload", function () {
lantern.dispose();
});
draw(true, this);
} else {
const prompt = document.createElement("span");
prompt.textContent = "Oops, GLantern is not supported on your browser.";
document.body.appendChild(prompt);
}
/**
* Draws a rectangle.
*/
function draw() {
function createShape(alpha) {
const s = new GLantern.flash.display.Shape(lantern.stage, lantern.stage);
lantern.stage.addChild(s);
s.alpha = alpha;
return s;
}
const shape1 = createShape(1);
shape1.graphics.beginFill(0xffffff);
shape1.graphics.drawRect(0, 0, 540, 383);
shape1.graphics.endFill();
}See QA.md.
The MIT License
You will also find a copy in LICENSE.md.
Part of Green-Lantern uses modifications based on webgl-utils.js. Its license file
can be found here.
Part of Green-Lantern uses modifications based on AwayJS.Core.geom. Its license file can be found
here.
Part of Green-Lantern uses adaptations from Anti-Grain Geometry, originally by Maxim Shemanarev in C++. Its license file can be found here.