Glantern เป็นห้องสมุดที่มีไว้สำหรับชั้นแฟลช HTML5 Shim เพลิดเพลินไปกับตัวอย่างสดจาก http://hozuki.github.io/green-lantern
ภาพหน้าจอของกรณีทดสอบสามารถพบได้ที่นี่
แนะนำให้ใช้ git ดั้งเดิมกับลูกค้ารายอื่น:
git clone https://github.com/hozuki/GLantern.git หรือเป็นแพ็คเกจ NPM คุณสามารถติดตั้งผ่าน npm :
npm install glantern --saveตรวจสอบให้แน่ใจว่าคุณติดตั้ง node.js และ npm ส่วนที่เหลือค่อนข้างง่าย:
cd GLantern
npm install
gulp buildหลังจากสร้างคุณจะพบ:
build/node สำหรับ NW.JS และอิเล็กตรอนbuild/GLantern-browser.js เป็นไฟล์ JavaScript แบบเต็มรูปแบบสำหรับเบราว์เซอร์;build/GLantern-browser.min.js (และการแมปต้นทางที่สอดคล้องกัน) สำหรับเบราว์เซอร์เป็นไฟล์ย่อสำหรับความเร็วในการโหลดที่ดีขึ้น ดูหน้าตัวอย่างที่ test/visual/index.html คุณจะต้องมีสภาพแวดล้อมที่มี WebGL เช่นเบราว์เซอร์ที่ทันสมัย, NW.JS หรืออิเล็กตรอน
Glantern รองรับการนำเข้าสองรูปแบบ
อันแรกคือการนำเข้าโดยแท็ก <script> ใช้แอตทริบิวต์ src และชี้ไปที่ผลลัพธ์ที่รวบรวม:
< script type =" text/javascript " src =" GLantern-browser.min.js " > </ script > ในสภาพแวดล้อมที่รองรับ Node.js เช่น NW.JS หรืออิเล็กตรอนคุณยังสามารถใช้ไวยากรณ์ require :
const GLantern = require ( "glantern" ) ; หลังจากนำเข้ากับรูปแบบเดิมหรือสไตล์หลังวัตถุ GLantern มีให้ทั่วโลก
โครงสร้างแพ็คเกจของแฟลชจะถูกเก็บรักษาไว้ในกลนเทิร์นดังนั้นการเพิ่ม GLantern. คำนำหน้ามักจะใช้งานได้ หากคุณต้องการทำให้มันเป็นเหมือน ActionScript มากขึ้น Glantern ให้ฟังก์ชั่น injectToGlobal() เพื่อฉีด "แพ็คเกจ" ไปยังขอบเขตทั่วโลก
// 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 ( ) ;
} ดู Qa.md
ใบอนุญาต MIT
คุณจะพบสำเนาใน LICENSE.md
ส่วนหนึ่งของ Green-Lantern ใช้การดัดแปลงตาม webgl-utils.js ไฟล์ใบอนุญาตสามารถพบได้ที่นี่
ส่วนหนึ่งของ Green-Lantern ใช้การดัดแปลงตาม AwayJS.Core.geom ไฟล์ใบอนุญาตสามารถพบได้ที่นี่
ส่วนหนึ่งของกรีนแลนเทิร์นใช้การปรับตัวจากเรขาคณิตต่อต้านเม็ดเม็ดซึ่งเดิมโดย Maxim Shemanarev ใน C ++ ไฟล์ใบอนุญาตสามารถพบได้ที่นี่