This repository has been archived by the owner on Nov 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_img.js
72 lines (60 loc) · 1.81 KB
/
test_img.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var nge2 = require('./build/Release/node_nge2');
var app = new nge2.NgeApp();
var quit
, dtype = nge2.DISPLAY_PIXEL_FORMAT_8888
, red = nge2.CreateColor(255, 0, 0, 255, dtype)
, yellow = nge2.CreateColor(255, 255, 0, 255, dtype)
, blue = nge2.CreateColor(0, 255, 255, 255, dtype);
var img, bg, logo
, logomask1
, logomask2;
app.init = function(end){
nge2.Init(nge2.INIT_VIDEO);
nge2.InitInput(function(key) {
console.log(key);
},
function(key) {
console.log(key);
if (key == nge2.PSP_BUTTON_UP)
quit = true;
}, 0);
nge2.SetScreenColor(255,255,255,255);
img = nge2.image_create_ex(10, 10, red, dtype);
bg = nge2.image_load("res/images/demo0.jpg", dtype, 1);
if (!bg)
console.log("can not find demo0.jpg!");
logo = nge2.image_load("res/images/nge2logo.png", nge2.DISPLAY_PIXEL_FORMAT_4444, 1);
if (!logo)
console.log("can not find nge2logo.png!");
console.log(logo);
logomask1 = nge2.CreateColor(255,255,255,128, logo.dtype);
logomask2 = nge2.CreateColor(100,100,100,255, logo.dtype);;
end();
}
app.mainloop = function(end){
try {
nge2.InputProc();
nge2.BeginScene(1);
nge2.ImageToScreen(bg, 0,0);
nge2.DrawImage(logo, 0,0,0,0, 128,0,256,256);
nge2.DrawImage(img, 0,0,0,0, 100,0,0,0);
nge2.DrawImageMask(logo, 0,0,0,0, 0,0,128,128, logomask1);
nge2.DrawImageMask(logo, 0,0,0,0, 0,272-128,128,128, logomask2);
nge2.DrawImageMask(logo, 0,0,0,0, 480-128,0,128,128, logomask2);
nge2.EndScene();
}
catch (err) {
console.log("err : " + err);
end(nge2.NGE_APP_QUIT);
return;
}
if (quit)
end(nge2.NGE_APP_QUIT);
else
end(nge2.NGE_APP_NORMAL);
}
app.fini = function(end){
nge2.Quit();
end();
}
app.startRun();