Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
enoyee
Scriptable
提交
d8f2be1c
S
Scriptable
项目概览
enoyee
/
Scriptable
通知
9
Star
0
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Scriptable
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d8f2be1c
编写于
12月 10, 2022
作者:
AndroidLeaves
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
e4b7aab6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
3 deletion
+74
-3
test.js
test.js
+72
-1
世界杯.js
世界杯.js
+2
-2
未找到文件。
test.js
浏览文件 @
d8f2be1c
...
...
@@ -47,7 +47,78 @@ class Widget extends BaseWidget {
}
async
render
({
widgetSetting
,
family
})
{
return
await
this
.
provideWidget
(
family
,
this
.
photoHalving
());
let
widget
=
new
ListWidget
();
widget
.
setPadding
(
0
,
0
,
0
,
0
);
let
image
=
await
this
.
drawSFIcon2
();
let
imgSpan
=
widget
.
addImage
(
image
);
// let textSpan = widget.addText('HTML5 Canvas Shadow')
// textSpan.font = Font.systemFont(30)
// textSpan.textColor = Color.white()
console
.
log
(
`>>>>>>>>>
${
image
.
size
.
width
}
,
${
image
.
size
.
height
}
`
);
// Photos.save(image)
// let scale = Device.screenScale();
// imgSpan.imageSize = new Size(image.size.width / scale, image.size.height / scale);
return
widget
;
}
drawSFIcon2
=
async
(
)
=>
{
try
{
const
{
width
,
height
}
=
this
.
getWidgetSize
(
'
中号
'
)
console
.
log
(
`---------
${
width
}
`
);
const
html
=
`
<img id="silhouetteImg" src="" />
<canvas id="mainCanvas" width="
${
width
}
" height="
${
height
}
" />
`
const
js
=
`
var canvas = document.getElementById("mainCanvas");
var context = canvas.getContext("2d");
context.textBaseline= "hanging";
let width = canvas.width, height = canvas.height;
if (window.devicePixelRatio) {
canvas.style.width = width + "px";
canvas.style.height = height + "px";
canvas.height = height * window.devicePixelRatio;
canvas.width = width * window.devicePixelRatio;
context.scale(window.devicePixelRatio, window.devicePixelRatio);
}
// context.shadowOffsetX = 10;
// context.shadowOffsetY = 10;
// context.shadowBlur = 4;
// context.shadowColor = "#666666";//或使用rgb(红色,绿色,蓝色)
context.fillStyle = "#FFFFFF";
context.font = "normal 30px Arial";
context.textBaseline= "hanging";
context.fillText("HTML5 Canvas Shadow", 0, 20);
var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
context.putImageData(imgData, 0, 0);
silhouetteImg.src = canvas.toDataURL();
output = canvas.toDataURL()
`
let
wv
=
new
WebView
();
await
wv
.
loadHTML
(
html
);
const
base64Image
=
await
wv
.
evaluateJavaScript
(
js
);
const
iconImage
=
await
new
Request
(
base64Image
).
loadImage
();
return
iconImage
;
}
catch
(
error
)
{
console
.
error
(
error
);
this
.
ERRS
.
push
(
error
);
if
(
!
config
.
runsInApp
)
{
await
this
.
notify
(
'
icon绘制
'
,
`🚫
${
error
}
`
);
}
else
{
throw
error
}
}
}
// --------------------------NET START--------------------------
...
...
世界杯.js
浏览文件 @
d8f2be1c
...
...
@@ -3,7 +3,7 @@
// icon-color: red; icon-glyph: user-astronaut;
/**
* Author:LSP
* Date:2022-12-0
8
* Date:2022-12-0
9
*/
// -------------------------------------------------------
// 是否是开发环境,配合手机端调试使用,正式发布设置为false
...
...
@@ -392,7 +392,7 @@ class Widget extends BaseWidget {
});
}
return
infoArr
;
return
infoArr
.
length
>
1
?
infoArr
.
slice
(
0
,
2
)
:
infoArr
;
}
// --------------------------NET END--------------------------
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录