git auto update

This commit is contained in:
lhy6305 2025-04-18 19:29:23 +08:00
parent ff6977c574
commit dcdb9485c2
10 changed files with 1446 additions and 929 deletions

View File

@ -1,7 +1,7 @@
<!DOCTYPE html><html>
<head><meta charset="utf-8">
<link rel="stylesheet" href="./css/main.css">
<script src="./js/0-fconsole.js"></script>
<script src="./js/0-loadfail.js"></script>
<script src="./js/0-jsloader.js"></script>
<script src="./js/0-jsloadentry.js"></script>
</head><body>

View File

@ -3,9 +3,9 @@
(async function() {
if(!(typeof scriptManager=="object"&&"loadjs" in scriptManager)) {
if(typeof loadfail=="function") {
loadfail("jsloadentry.jsscriptManager.loadjs is not defined");
loadfail("jsloadentry.js: scriptManager.loadjs is not defined");
} else {
window.alert("jsloadentry.jsscriptManager.loadjs is not defined");
window.alert("jsloadentry.js: scriptManager.loadjs is not defined");
}
return;
}
@ -13,7 +13,9 @@
scriptManager.loadjs("./js/libpolyfill.requestAnimationFrame.js");
scriptManager.loadjs("./js/libutil.js");
scriptManager.loadjs("./js/libcubicbezier.js");
scriptManager.loadjs("./js/libpixi_v891uni.min.js");
scriptManager.loadjs("./js/libtransition.js");
scriptManager.loadjs("./js/libwebglcheck.js");
scriptManager.loadjs("./js/libpixi_v891gl.min.js");
await scriptManager.waitAll();
await scriptManager.loadjs("./js/libtransition.js");
await scriptManager.loadjs("./js/libmain.js");
})();

View File

@ -18,24 +18,28 @@
if(document.readyState=="complete") {
document.body.appendChild(sc);
} else {
window.addEventListener("load", function() {
var hfn=function() {
window.removeEventListener("load", hfn);
document.body.appendChild(sc);
});
};
window.addEventListener("load", hfn);
}
sc.addEventListener(("readyState" in sc?"readystatechange":"load"), function() {
console.info("script "+pth+" loaded successfully.");
console.debug("script "+pth+" loaded successfully.");
scriptManager.loadingcount--;
sc.remove();
resolve();
});
sc.addEventListener("error", function() {
window.loadfail("script "+pth+" load failed");
sc.remove();
reject();
});
scriptManager.loadingcount++;
return ret;
};
scriptManager.isDone=function() {
@ -44,7 +48,13 @@
scriptManager.waitAll=async function() {
return new Promise(function(resolve, reject) {
var i;
i=setInterval(function() {
if(scriptManager.loadingcount==0) {
clearInterval(i);
resolve();
}
}, 100);
});
};

270
js/libmain.js Normal file
View File

@ -0,0 +1,270 @@
//libmain.js
(function() {
if(typeof PIXI!="object") {
if(typeof loadfail=="function") {
loadfail("libmain.js: object PIXI(type of "+(typeof PIXI)+") is not defined");
} else {
window.alert("libmain.js: object PIXI(type of "+(typeof PIXI)+") is not defined");
}
return;
}
var main_stage= {};
(function() { //init canvas and frame
console.log("[libmain] setting up basic pixi application...");
//set up main canvas element
main_stage.width=1920;
main_stage.height=1080;
var mainframe=document.getElementById("mainframe");
var canvas=document.getElementById("stagecanvas");
if(mainframe===null) {
mainframe=document.createElement("div");
mainframe.id="mainframe";
document.body.appendChild(mainframe);
}
mainframe.style.display="inline-block";
mainframe.style.display="inline-block";
mainframe.style.zIndex=0;
mainframe.style.backgroundColor="#000000";
if(canvas===null) {
canvas=document.createElement("canvas");
canvas.id="stagecanvas";
mainframe.appendChild(canvas);
}
canvas.style.width="100%";
canvas.style.height="100%";
canvas.style.display="inline-block";
canvas.style.position="absolute";
canvas.style.zIndex=1;
main_stage.mainframe=mainframe;
main_stage.canvas=canvas;
//document resize handler
main_stage.resize=function() {
var res=libutil.calcresize(document.body.clientWidth, document.body.clientHeight, main_stage.width, main_stage.height);
mainframe.style.width=res[0]+"px";
mainframe.style.height=res[1]+"px";
mainframe.style.left=res[2]+"px";
mainframe.style.top=res[3]+"px";
};
window.addEventListener("resize", main_stage.resize);
main_stage.resize();
//setup pixi application
if(window.suppgl) {
main_stage.renderer=new PIXI.Renderer({"view":canvas, "antialias":true, "transparent":true, "backgroundAlpha":0, "width":main_stage.width, "height":main_stage.height});
} else {
main_stage.renderer=new PIXI.CanvasRenderer({"view":canvas, "antialias":true, "transparent":true, "backgroundAlpha":0, "width":main_stage.width, "height":main_stage.height});
}
main_stage.stage=new PIXI.Container();
main_stage.stage.sortableChildren=true;
main_stage.render=function() {
requestAnimationFrame(main_stage.render);
main_stage.renderer.render(main_stage.stage);
};
main_stage.render();
})();
(function() { //api functions
console.log("[libmain] initalizing api functions...");
main_stage.addVideoPIXI=function(pth, width, height, left, top) { //[DEPRECIATED] return=PIXI.Sprite
if(arguments.length<=1||isNaN(Number(width))) {
width=main_stage.renderer.screen.width;
}
if(arguments.length<=2||isNaN(Number(height))) {
height=main_stage.renderer.screen.height;
}
if(arguments.length<=3||isNaN(Number(left))) {
left=0;
}
if(arguments.length<=4||isNaN(Number(top))) {
top=0;
}
var tex=PIXI.Texture.from(pth);
var spr=PIXI.Sprite.from(tex);
spr.width=width;
spr.height=height;
spr.position.x=left;
spr.position.y=top;
spr.anchor.x=0;
spr.anchor.y=0;
main_stage.stage.addChild(spr);
tex.baseTexture.on("loaded", function() {
setTimeout(function() {
tex.baseTexture.resource.source.pause();
tex.baseTexture.resource.source.currentTime=0;
}, 0);
});
spr.play=function() {
tex.baseTexture.resource.source.play();
};
spr.pause=function() {
tex.baseTexture.resource.source.pause();
};
spr.stop=function() {
tex.baseTexture.resource.source.pause();
tex.baseTexture.resource.source.currentTime=0;
};
spr.seek=function(t) {
tex.baseTexture.resource.source.currentTime=t;
};
spr.mute=function(t) {
tex.baseTexture.resource.source.muted=t;
};
spr.loop=function(t) {
tex.baseTexture.resource.source.loop=t;
};
return spr;
};
main_stage.addVideo=function(pth, width, height, left, top) { //return=HTMLVideoElement
if(arguments.length<=1||isNaN(Number(width))) {
width=main_stage.renderer.screen.width;
}
if(arguments.length<=2||isNaN(Number(height))) {
height=main_stage.renderer.screen.height;
}
if(arguments.length<=3||isNaN(Number(left))) {
left=0;
}
if(arguments.length<=4||isNaN(Number(top))) {
top=0;
}
width*=100;
width/=main_stage.renderer.screen.width;
height*=100;
height/=main_stage.renderer.screen.height;
left*=100;
left/=main_stage.renderer.screen.width;
top*=100;
top/=main_stage.renderer.screen.height;
var elem=document.createElement("video");
elem.src=pth;
elem.load();
elem.style.pointerEvents="none";
elem.style.left=left+"%";
elem.style.top=top+"%";
elem.style.width=width+"%";
elem.style.height=height+"%";
elem.style.position="absolute";
elem.style.display="inline-block";
elem.style.zIndex=-1;
elem.destroy=function() {
elem.parentNode.removeChild(elem);
elem=null;
};
elem.setposi=function(x, y) {
x*=100;
x/=main_stage.renderer.screen.width;
y*=100;
y/=main_stage.renderer.screen.height;
elem.style.left=x+"%";
elem.style.top=y+"%";
};
main_stage.mainframe.appendChild(elem);
return elem;
};
main_stage.addAudio=function(pth) { //return=HTMLAudioElement
var elem=document.createElement("audio");
elem.style.display="none";
elem.src=pth;
elem.load();
elem.destroy=function() {
elem.parentNode.removeChild(elem);
elem=null;
};
main_stage.mainframe.appendChild(elem);
return elem;
};
main_stage.addText=function(text, left, top, cfg) { //return=PIXI.Sprite
if(arguments.length<=1||isNaN(Number(left))) {
left=0;
}
if(arguments.length<=2||isNaN(Number(top))) {
top=0;
}
if(arguments.length<=3||!(cfg instanceof Object)) {
cfg= {"fontFamily":"Arial", "fontSize":35, "fill":0xffffff, "align":"left"};
}
var spr=new PIXI.Text(text, cfg);
spr.position.x=left;
spr.position.y=top;
spr.anchor.x=0.5;
spr.anchor.y=0.5;
main_stage.stage.addChild(spr);
return spr;
};
main_stage.addShape=function(name, left, top, width, height) { //return=PIXI.Sprite
var shape=null;
for(var a=0; a<main_stage.shapes.length; a++) {
if(main_stage.shapes[a].name==name) {
shape=main_stage.shapes[a];
break;
}
}
if(shape===null) {
console.error("shape \""+name+"\" is not defined.");
return false;
}
if(arguments.length<=1||isNaN(Number(left))) {
left=0;
}
if(arguments.length<=2||isNaN(Number(top))) {
top=0;
}
if(arguments.length<=3||isNaN(Number(width))) {
width=shape.canvas.width;
}
if(arguments.length<=4||isNaN(Number(height))) {
height=shape.canvas.height;
}
var tex=PIXI.Texture.from(shape.canvas);
var spr=PIXI.Sprite.from(tex);
spr.width=width;
spr.height=height;
spr.position.x=left;
spr.position.y=top;
spr.anchor.x=0.5;
spr.anchor.y=0.5;
main_stage.stage.addChild(spr);
return spr;
};
main_stage.addImage=function(pth, left, top, width, height) { //return=PIXI.Sprite
var tex=PIXI.Texture.from(pth);
if(arguments.length<=1||isNaN(Number(left))) {
left=0;
}
if(arguments.length<=2||isNaN(Number(top))) {
top=0;
}
if(arguments.length<=3||isNaN(Number(width))) {
width=tex.width;
}
if(arguments.length<=4||isNaN(Number(height))) {
height=tex.height;
}
var spr=PIXI.Sprite.from(tex);
spr.width=width;
spr.height=height;
spr.position.x=left;
spr.position.y=top;
spr.anchor.x=0.5;
spr.anchor.y=0.5;
main_stage.stage.addChild(spr);
return spr;
};
})();
window.main_stage=main_stage;
console.log("[libmain] all components initialized successfully.");
})();

1098
js/libpixi_v891gl.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,27 +2,27 @@
if(typeof libutil!="object") {
if(typeof loadfail=="function") {
loadfail("libtransition.jsobject libutil(type of "+(typeof libutil)+") is not defined");
loadfail("libtransition.js: object libutil(type of "+(typeof libutil)+") is not defined");
} else {
window.alert("libtransition.jsobject libutil is not defined");
window.alert("libtransition.js: object libutil(type of "+(typeof libutil)+") is not defined");
}
return;
}
if(typeof Bezier!="function") {
if(typeof loadfail=="function") {
loadfail("libtransition.jsclass Bezier(type of "+(typeof Bezier)+") is not defined");
loadfail("libtransition.js: class Bezier(type of "+(typeof Bezier)+") is not defined");
} else {
window.alert("libtransition.jsclass Bezier is not defined");
window.alert("libtransition.js: class Bezier is not defined");
}
return;
}
if(typeof requestAnimationFrame!="function") {
if(typeof loadfail=="function") {
loadfail("libtransition.jsfunction requestAnimationFrame(type of "+(typeof requestAnimationFrame)+") is not defined");
loadfail("libtransition.js: function requestAnimationFrame(type of "+(typeof requestAnimationFrame)+") is not defined");
} else {
window.alert("libtransition.jsfunction requestAnimationFrame is not defined");
window.alert("libtransition.js: function requestAnimationFrame is not defined");
}
return;
}

View File

@ -17,8 +17,38 @@
}
return Math.min(Math.max(val, min), max);
};
};
window.libutil=libutil;
libutil.calcresize=function(cw, ch, ew, eh) { //return=[width,height,left,top]
if(cw/ew<ch/eh) {
return [cw, cw/ew*eh, 0, (ch-cw/ew*eh)/2];
} else {
return [ch/eh*ew, ch, (cw-ch/eh*ew)/2, 0];
}
};
libutil.encodeHtmlSpecChars=function(html) {
var elem=document.createElement("div");
var txt=document.createTextNode(html);
elem.appendChild(txt);
return elem.innerHTML;
};
libutil.decodeHtmlSpecChars=function(str) {
var elem=document.createElement("div");
elem.innerHTML=str;
return elem.innerText||elem.textContent;
};
libutil.preloadFont=function(name) {
var elem=document.createElement("div");
elem.style.fontFamily=name;
elem.innerHTML=String(Math.random());
document.body.appendChild(elem);
setTimeout(function() {
document.body.removeChild(elem);
}, 0);
};
window.libutil=libutil;
})();

18
js/libwebglcheck.js Normal file
View File

@ -0,0 +1,18 @@
//libwebglcheck.js
(function() {
window.suppgl=false;
var cv=document.createElement("canvas");
var gl=cv.getContext("webgl")||cv.getContext("experimental-webgl");
if(gl!==null&&"WebGLRenderingContext" in window&&gl instanceof window.WebGLRenderingContext) {
console.log("libwebglcheck.js: the browser supports webgl");
window.suppgl=true;
} else {
//console.log("libwebglcheck.js: the browser does NOT support webgl");
window.loadfail("libwebglcheck.js: the browser does NOT support webgl");
return;
}
})();