Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-libs
Commits
16f7f97d
Commit
16f7f97d
authored
Jun 24, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
放假前提交一波
parent
589c0357
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
176 additions
and
99 deletions
+176
-99
jump-high.json
dist/customs/jump-high.json
+1
-1
pick-image.json
dist/processes/other/pick-image.json
+1
-1
resize-image.json
dist/processes/other/resize-image.json
+1
-1
show-toast.json
dist/processes/view/show-toast.json
+30
-1
main.js
src/custom/jump-high/debug/main.js
+1
-5
main.js.map
src/custom/jump-high/debug/main.js.map
+1
-1
utils.ts
src/custom/jump-high/src/game/utils.ts
+1
-1
index.ts
src/process/other/pick-image/index.ts
+101
-14
index.ts
src/process/other/resize-image/index.ts
+17
-72
meta.json
src/process/view/show-toast/meta.json
+22
-2
No files found.
dist/customs/jump-high.json
View file @
16f7f97d
This diff is collapsed.
Click to expand it.
dist/processes/other/pick-image.json
View file @
16f7f97d
...
...
@@ -6,7 +6,7 @@
"success"
],
"id"
:
"pick-image"
,
"script"
:
"
var input = document.createElement('input');
\n
input.type = 'file';
\n
input.onchange = function (e) {
\n
processImage(input.files[0], function (imgData) {
\n
next('success', imgData);
\n
});
\n
};
\n
input.click();
\n
function processImage(file, callback) {
\n
var reader = new FileReader();
\n
reader.readAsDataURL(file);
\n
reader.onload = function (e) {
\n
callback(reader.result);
\n
}
;
\n
}
\n
"
,
"script"
:
"
pick(function (imgData) {
\n
next('success', imgData);
\n
});
\n
function getExif(img, callback) {
\n
EXIF.getData(img, function () {
\n
var allMetaData = EXIF.getAllTags(this);
\n
callback(allMetaData);
\n
});
\n
}
\n
function pick(callback) {
\n
var fileInput = document.createElement(
\"
input
\"
);
\n
fileInput.type =
\"
file
\"
;
\n
fileInput.accept =
\"
image/*
\"
;
\n
fileInput.style.display =
\"
none
\"
;
\n
document.body.insertBefore(fileInput, document.body.firstChild);
\n
fileInput.addEventListener(
\"
change
\"
, function (evt) {
\n
var mime = {
\"
png
\"
:
\"
image/png
\"
,
\"
jpg
\"
:
\"
image/jpeg
\"
,
\"
jpeg
\"
:
\"
image/jpeg
\"
,
\"
bmp
\"
:
\"
image/bmp
\"
};
\n
var file = evt.target.files[0];
\n
var type = file.type;
\n
if (!type) {
\n
type = mime[file.name.match(/
\\
.([^
\\
.]+)$/i)[1]];
\n
}
\n
var fileReader = new FileReader();
\n
fileReader.onload = function () {
\n
getExif(file, function (exif) {
\n
var orientation = -1;
\n
if (exif) {
\n
orientation = exif[
\"
Orientation
\"
];
\n
}
\n
var image = new Image();
\n
image.onload = function () {
\n
var canvas = document.createElement(
\"
canvas
\"
);
\n
var ctx = canvas.getContext(
\"
2d
\"
);
\n
canvas.width = image.width;
\n
canvas.height = image.height;
\n
if (orientation > 4) {
\n
canvas.width = image.height;
\n
canvas.height = image.width;
\n
}
\n
ctx.clearRect(0, 0, canvas.width, canvas.height);
\n
switch (orientation) {
\n
case 2:
\n
ctx.translate(canvas.width, 0);
\n
ctx.scale(-1, 1);
\n
break;
\n
case 3:
\n
ctx.translate(canvas.width, canvas.height);
\n
ctx.rotate(Math.PI);
\n
break;
\n
case 4:
\n
ctx.translate(0, canvas.height);
\n
ctx.scale(1, -1);
\n
break;
\n
case 5:
\n
ctx.rotate(0.5 * Math.PI);
\n
ctx.scale(1, -1);
\n
break;
\n
case 6:
\n
ctx.rotate(0.5 * Math.PI);
\n
ctx.translate(0, -image.height);
\n
break;
\n
case 7:
\n
ctx.rotate(0.5 * Math.PI);
\n
ctx.translate(canvas.width, -canvas.height);
\n
ctx.scale(-1, 1);
\n
break;
\n
case 8:
\n
ctx.rotate(-0.5 * Math.PI);
\n
ctx.translate(-canvas.height, 0);
\n
break;
\n
default:
\n
ctx.transform(1, 0, 0, 1, 0, 0);
\n
}
\n
ctx.drawImage(image, 0, 0);
\n
var imagetype =
\"
png
\"
;
\n
if (orientation !== -1) {
\n
imagetype =
\"
jpeg
\"
;
\n
}
\n
var resultURL =
\"\"
;
\n
if (imagetype ===
\"
jpg
\"
|| imagetype ===
\"
jpeg
\"
) {
\n
resultURL = canvas.toDataURL(
\"
image/
\"
+ imagetype);
\n
}
\n
else {
\n
resultURL = canvas.toDataURL(
\"
image/
\"
+ imagetype);
\n
}
\n
callback(resultURL);
\n
image.parentNode.removeChild(image);
\n
fileInput.parentNode.removeChild(fileInput);
\n
};
\n
image.src = fileReader.result;
\n
image.style.display =
\"
none
\"
;
\n
document.body.appendChild(image);
\n
fileInput.value =
\"\"
;
\n
});
\n
};
\n
fileReader.readAsDataURL(file);
\n
}, false);
\n
fileInput.click()
;
\n
}
\n
"
,
"group"
:
"other"
,
"type"
:
"builtin"
}
dist/processes/other/resize-image.json
View file @
16f7f97d
...
...
@@ -38,7 +38,7 @@
"success"
],
"id"
:
"resize-image"
,
"script"
:
"var width = engine.findVariable('width', args, props);
\n
var height = engine.findVariable('height', args, props);
\n
var cutType = engine.findVariable('cutType', args, props);
\n
var type = engine.findVariable('type', args, props);
\n
var quality = engine.findVariable('quality', args, props);
\n
var img = args;
\n
if (typeof args === 'string') {
\n
img = new Image();
\n
img.onload = function () {
\n
deal();
\n
};
\n
img.onerror = function (e) {
\n
console.log(e);
\n
};
\n
img.src = args;
\n
}
\n
else {
\n
deal();
\n
}
\n
function
getExif(callback) {
\n
EXIF.getData(img, function () {
\n
var allMetaData = EXIF.getAllTags(this);
\n
callback(allMetaData);
\n
});
\n
}
\n
function deal() {
\n
getExif(function (allMetaData) {
\n
var m = cutType === 'inner' ? Math.min : Math.max;
\n
var r = m(width / img.width, height / img.height);
\n
var imgWidth = img.width * r;
\n
var imgHeight = img.height * r;
\n
var x = (width - imgWidth) / 2;
\n
var y = (height - imgHeight) / 2;
\n
var canvas = document.createElement('canvas');
\n
canvas.width = width;
\n
canvas.height = height;
\n
var ctx = canvas.getContext('2d');
\n
ctx.translate(x, y);
\n
ctx.scale(r, r);
\n
allMetaData.Orientation = 1;
\n
if (allMetaData.Orientation) {
\n
var orientation = allMetaData.Orientation;
\n
switch (orientation) {
\n
case 2:
\n
ctx.translate(img.width, 0);
\n
ctx.scale(-1, 1);
\n
break;
\n
case 3:
\n
ctx.translate(img.width, img.height);
\n
ctx.rotate(Math.PI);
\n
break;
\n
case 4:
\n
ctx.translate(0, img.height);
\n
ctx.scale(1, -1);
\n
break;
\n
case 5:
\n
ctx.rotate(-0.5 * Math.PI);
\n
ctx.scale(-1, 1);
\n
ctx.translate(x / r - y / r, y / r - x / r);
\n
break;
\n
case 6:
\n
ctx.rotate(-0.5 * Math.PI);
\n
ctx.translate(-img.width + y / r - x / r, y / r - x / r);
\n
break;
\n
case 7:
\n
ctx.rotate(0.5 * Math.PI);
\n
ctx.scale(-1, 1);
\n
ctx.translate(-img.width + y / r - x / r, -img.height + x / r - y / r);
\n
break;
\n
case 8:
\n
ctx.rotate(-0.5 * Math.PI);
\n
ctx.translate(-img.width + y / r - x / r, -x / r + y / r);
\n
break;
\n
}
\n
}
\n
ctx.drawImage(img, 0, 0);
\n
var dataUrl = canvas.toDataURL('image/' + type, quality);
\n
next('success', dataUrl);
\n
}
);
\n
}
\n
"
,
"script"
:
"var width = engine.findVariable('width', args, props);
\n
var height = engine.findVariable('height', args, props);
\n
var cutType = engine.findVariable('cutType', args, props);
\n
var type = engine.findVariable('type', args, props);
\n
var quality = engine.findVariable('quality', args, props);
\n
var img = args;
\n
if (typeof args === 'string') {
\n
img = new Image();
\n
img.onload = function () {
\n
deal();
\n
};
\n
img.onerror = function (e) {
\n
console.log(e);
\n
};
\n
img.src = args;
\n
}
\n
else {
\n
deal();
\n
}
\n
function
deal() {
\n
var m = cutType === 'inner' ? Math.min : Math.max;
\n
var r = m(width / img.width, height / img.height);
\n
var imgWidth = img.width * r;
\n
var imgHeight = img.height * r;
\n
var x = (width - imgWidth) / 2;
\n
var y = (height - imgHeight) / 2;
\n
var canvas = document.createElement('canvas');
\n
canvas.width = width;
\n
canvas.height = height;
\n
var ctx = canvas.getContext('2d');
\n
ctx.translate(x, y);
\n
ctx.scale(r, r);
\n
ctx.drawImage(img, 0, 0);
\n
var dataUrl = canvas.toDataURL('image/' + type, quality);
\n
next('success', dataUrl
);
\n
}
\n
"
,
"group"
:
"other"
,
"type"
:
"builtin"
}
dist/processes/view/show-toast.json
View file @
16f7f97d
...
...
@@ -6,13 +6,42 @@
},
"text"
:
{
"type"
:
"string"
,
"alias"
:
"内容"
"alias"
:
"文本内容"
},
"labelAlign"
:
{
"alias"
:
"文本对齐"
,
"type"
:
"enum"
,
"enum"
:
[
{
"label"
:
"左对齐"
,
"value"
:
"left"
},
{
"label"
:
"居中对齐"
,
"value"
:
"center"
},
{
"label"
:
"右对齐"
,
"value"
:
"right"
}
],
"default"
:
"center"
},
"labSize"
:
{
"alias"
:
"文本大小"
,
"type"
:
"number"
,
"default"
:
30
},
"padding"
:
{
"type"
:
"number"
,
"default"
:
10
,
"alias"
:
"边距"
},
"bgAlpha"
:
{
"type"
:
"number"
,
"default"
:
0.7
,
"alias"
:
"背景透明度"
},
"paddingH"
:
{
"type"
:
"number"
,
"alias"
:
"横向边距"
...
...
src/custom/jump-high/debug/main.js
View file @
16f7f97d
...
...
@@ -13,11 +13,8 @@
engine
.
injectProp
(
props
,
p
);
}
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
uuid
);
}
function
getTextureByName
(
name
)
{
return
getTexture
(
getAssetByName
(
name
).
uuid
);
return
engine
.
Texture
.
from
(
getAssetByName
(
name
).
uuid
);
}
function
getBlockAsset
(
type
)
{
return
engine
.
getAssetByName
(
props
.
blockAssets
[
type
]);
...
...
@@ -853,7 +850,6 @@
};
return
GameView
;
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
var
JumpHigh
=
(
function
(
_super
)
{
tslib
.
__extends
(
JumpHigh
,
_super
);
...
...
src/custom/jump-high/debug/main.js.map
View file @
16f7f97d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/custom/jump-high/src/game/utils.ts
View file @
16f7f97d
...
...
@@ -8,7 +8,7 @@ export function getTexture(uuid) {
}
export
function
getTextureByName
(
name
)
{
return
getTexture
(
getAssetByName
(
name
).
uuid
);
return
engine
.
Texture
.
from
(
getAssetByName
(
name
).
uuid
);
}
export
function
getBlockAsset
(
type
)
{
...
...
src/process/other/pick-image/index.ts
View file @
16f7f97d
...
...
@@ -2,19 +2,106 @@
* Created by rockyl on 2019-11-16.
*/
let
input
=
document
.
createElement
(
'input'
);
input
.
type
=
'file'
;
input
.
onchange
=
function
(
e
)
{
processImage
(
input
.
files
[
0
],
(
imgData
)
=>
{
next
(
'success'
,
imgData
);
})
};
input
.
click
();
pick
(
function
(
imgData
)
{
next
(
'success'
,
imgData
);
});
function
processImage
(
file
,
callback
)
{
let
reader
=
new
FileReader
();
reader
.
readAsDataURL
(
file
);
reader
.
onload
=
function
(
e
)
{
callback
(
reader
.
result
)
}
function
getExif
(
img
,
callback
)
{
EXIF
.
getData
(
img
,
function
()
{
let
allMetaData
=
EXIF
.
getAllTags
(
this
);
callback
(
allMetaData
)
});
}
function
pick
(
callback
)
{
let
fileInput
=
document
.
createElement
(
"input"
);
fileInput
.
type
=
"file"
;
fileInput
.
accept
=
"image/*"
;
fileInput
.
style
.
display
=
"none"
;
document
.
body
.
insertBefore
(
fileInput
,
document
.
body
.
firstChild
);
fileInput
.
addEventListener
(
"change"
,
function
(
evt
)
{
let
mime
=
{
"png"
:
"image/png"
,
"jpg"
:
"image/jpeg"
,
"jpeg"
:
"image/jpeg"
,
"bmp"
:
"image/bmp"
};
let
file
=
evt
.
target
.
files
[
0
];
let
type
=
file
.
type
;
if
(
!
type
)
{
type
=
mime
[
file
.
name
.
match
(
/
\.([^\.]
+
)
$/i
)[
1
]];
}
let
fileReader
=
new
FileReader
();
fileReader
.
onload
=
function
()
{
getExif
(
file
,
(
exif
)
=>
{
//let exif = EXIF.readFromBinaryFile(arrayBuffer);
let
orientation
=
-
1
;
if
(
exif
)
{
orientation
=
exif
[
"Orientation"
];
}
let
image
=
new
Image
();
image
.
onload
=
function
()
{
let
canvas
=
document
.
createElement
(
"canvas"
);
let
ctx
=
canvas
.
getContext
(
"2d"
);
canvas
.
width
=
image
.
width
;
canvas
.
height
=
image
.
height
;
if
(
orientation
>
4
)
{
canvas
.
width
=
image
.
height
;
canvas
.
height
=
image
.
width
;
}
ctx
.
clearRect
(
0
,
0
,
canvas
.
width
,
canvas
.
height
);
switch
(
orientation
)
{
case
2
:
// horizontal flip
ctx
.
translate
(
canvas
.
width
,
0
);
ctx
.
scale
(
-
1
,
1
);
break
;
case
3
:
// 180° rotate left
ctx
.
translate
(
canvas
.
width
,
canvas
.
height
);
ctx
.
rotate
(
Math
.
PI
);
break
;
case
4
:
ctx
.
translate
(
0
,
canvas
.
height
);
ctx
.
scale
(
1
,
-
1
);
break
;
case
5
:
ctx
.
rotate
(
0.5
*
Math
.
PI
);
ctx
.
scale
(
1
,
-
1
);
break
;
case
6
:
ctx
.
rotate
(
0.5
*
Math
.
PI
);
ctx
.
translate
(
0
,
-
image
.
height
);
break
;
case
7
:
ctx
.
rotate
(
0.5
*
Math
.
PI
);
ctx
.
translate
(
canvas
.
width
,
-
canvas
.
height
);
ctx
.
scale
(
-
1
,
1
);
break
;
case
8
:
ctx
.
rotate
(
-
0.5
*
Math
.
PI
);
ctx
.
translate
(
-
canvas
.
height
,
0
);
break
;
default
:
ctx
.
transform
(
1
,
0
,
0
,
1
,
0
,
0
);
}
ctx
.
drawImage
(
image
,
0
,
0
);
let
imagetype
=
"png"
;
if
(
orientation
!==
-
1
)
{
imagetype
=
"jpeg"
;
}
let
resultURL
=
""
;
if
(
imagetype
===
"jpg"
||
imagetype
===
"jpeg"
)
{
resultURL
=
canvas
.
toDataURL
(
"image/"
+
imagetype
);
}
else
{
resultURL
=
canvas
.
toDataURL
(
"image/"
+
imagetype
);
}
callback
(
resultURL
);
image
.
parentNode
.
removeChild
(
image
);
fileInput
.
parentNode
.
removeChild
(
fileInput
);
};
image
.
src
=
fileReader
.
result
;
image
.
style
.
display
=
"none"
;
document
.
body
.
appendChild
(
image
);
fileInput
.
value
=
""
;
});
};
fileReader
.
readAsDataURL
(
file
);
},
false
);
fileInput
.
click
();
}
src/process/other/resize-image/index.ts
View file @
16f7f97d
...
...
@@ -7,7 +7,6 @@ const height = engine.findVariable('height', args, props);
const
cutType
=
engine
.
findVariable
(
'cutType'
,
args
,
props
);
const
type
=
engine
.
findVariable
(
'type'
,
args
,
props
);
const
quality
=
engine
.
findVariable
(
'quality'
,
args
,
props
);
let
img
=
args
;
if
(
typeof
args
===
'string'
)
{
img
=
new
Image
();
...
...
@@ -18,79 +17,25 @@ if (typeof args === 'string') {
console
.
log
(
e
);
};
img
.
src
=
args
;
}
else
{
deal
();
}
function
getExif
(
callback
)
{
EXIF
.
getData
(
img
,
function
()
{
var
allMetaData
=
EXIF
.
getAllTags
(
this
);
callback
(
allMetaData
)
});
else
{
deal
();
}
function
deal
()
{
getExif
((
allMetaData
)
=>
{
let
m
=
cutType
===
'inner'
?
Math
.
min
:
Math
.
max
;
let
r
=
m
(
width
/
img
.
width
,
height
/
img
.
height
);
let
imgWidth
=
img
.
width
*
r
;
let
imgHeight
=
img
.
height
*
r
;
let
x
=
(
width
-
imgWidth
)
/
2
;
let
y
=
(
height
-
imgHeight
)
/
2
;
let
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
width
;
canvas
.
height
=
height
;
let
ctx
=
canvas
.
getContext
(
'2d'
);
//ctx.strokeStyle = 'blue';
//ctx.strokeRect(0, 0, width, height);
ctx
.
translate
(
x
,
y
);
ctx
.
scale
(
r
,
r
);
allMetaData
.
Orientation
=
1
;
if
(
allMetaData
.
Orientation
)
{
let
orientation
=
allMetaData
.
Orientation
;
switch
(
orientation
)
{
case
2
:
//水平翻转
ctx
.
translate
(
img
.
width
,
0
);
ctx
.
scale
(
-
1
,
1
);
break
;
case
3
:
//180°
ctx
.
translate
(
img
.
width
,
img
.
height
);
ctx
.
rotate
(
Math
.
PI
);
break
;
case
4
:
//垂直翻转
ctx
.
translate
(
0
,
img
.
height
);
ctx
.
scale
(
1
,
-
1
);
break
;
case
5
:
//逆时针90°+水平翻转
ctx
.
rotate
(
-
0.5
*
Math
.
PI
);
ctx
.
scale
(
-
1
,
1
);
ctx
.
translate
(
x
/
r
-
y
/
r
,
y
/
r
-
x
/
r
);
break
;
case
6
:
//逆时针90°
ctx
.
rotate
(
-
0.5
*
Math
.
PI
);
ctx
.
translate
(
-
img
.
width
+
y
/
r
-
x
/
r
,
y
/
r
-
x
/
r
);
break
;
case
7
:
//顺时针90°+垂直翻转
ctx
.
rotate
(
0.5
*
Math
.
PI
);
ctx
.
scale
(
-
1
,
1
);
ctx
.
translate
(
-
img
.
width
+
y
/
r
-
x
/
r
,
-
img
.
height
+
x
/
r
-
y
/
r
);
break
;
case
8
:
//顺时针90°
ctx
.
rotate
(
-
0.5
*
Math
.
PI
);
ctx
.
translate
(
-
img
.
width
+
y
/
r
-
x
/
r
,
-
x
/
r
+
y
/
r
);
break
;
}
}
ctx
.
drawImage
(
img
,
0
,
0
);
let
dataUrl
=
canvas
.
toDataURL
(
'image/'
+
type
,
quality
);
next
(
'success'
,
dataUrl
);
})
let
m
=
cutType
===
'inner'
?
Math
.
min
:
Math
.
max
;
let
r
=
m
(
width
/
img
.
width
,
height
/
img
.
height
);
let
imgWidth
=
img
.
width
*
r
;
let
imgHeight
=
img
.
height
*
r
;
let
x
=
(
width
-
imgWidth
)
/
2
;
let
y
=
(
height
-
imgHeight
)
/
2
;
let
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
width
;
canvas
.
height
=
height
;
let
ctx
=
canvas
.
getContext
(
'2d'
);
ctx
.
translate
(
x
,
y
);
ctx
.
scale
(
r
,
r
);
ctx
.
drawImage
(
img
,
0
,
0
);
let
dataUrl
=
canvas
.
toDataURL
(
'image/'
+
type
,
quality
);
next
(
'success'
,
dataUrl
);
}
src/process/view/show-toast/meta.json
View file @
16f7f97d
...
...
@@ -6,13 +6,33 @@
},
"text"
:
{
"type"
:
"string"
,
"alias"
:
"内容"
"alias"
:
"文本内容"
},
"labelAlign"
:
{
"alias"
:
"文本对齐"
,
"type"
:
"enum"
,
"enum"
:
[
{
"label"
:
"左对齐"
,
"value"
:
"left"
},
{
"label"
:
"居中对齐"
,
"value"
:
"center"
},
{
"label"
:
"右对齐"
,
"value"
:
"right"
}
],
"default"
:
"center"
},
"labSize"
:
{
"alias"
:
"文本大小"
,
"type"
:
"number"
,
"default"
:
30
},
"padding"
:
{
"type"
:
"number"
,
"default"
:
10
,
"alias"
:
"边距"
},
"bgAlpha"
:
{
"type"
:
"number"
,
"default"
:
0.7
,
"alias"
:
"背景透明度"
},
"paddingH"
:
{
"type"
:
"number"
,
"alias"
:
"横向边距"
...
...
@@ -46,4 +66,4 @@
"output"
:
[
"success"
]
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment