标签:raw new turn 替换 complete wim load lis url
1 let widget = await createWidget(); 2 if (!config.runsInWidget) { 3 await widget.presentLarge(); 4 } 5 Script.setWidget(widget); 6 Script.complete(); 7 async function createWidget() { 8 let widget = new ListWidget(); // 图片 9 let bg = await getImage(‘https://images.cnblogs.com/cnblogs_com/jwyblogs/1576071/o_201009005448bg.jpg‘); 10 widget.backgroundImage = await shadowImage(bg); 11 return w; 12 } 13 async function getImage(url) { 14 let r = await new Request(url); 15 return await r.loadImage(); 16 } 17 async function shadowImage(img) { 18 let ctx = new DrawContext(); 19 ctx.size = img.size; 20 ctx.drawImageInRect(img, new Rect(0, 0, img.size[‘width‘], img.size[‘height‘])); 21 let res = await ctx.getImage(); 22 return res; 23 }
使用时只需要替换createWidget()方法中的url即可,替换成自己的图片路径
图片路径来源:
将需要展示的图片上传至博客园相册中即可得到链接。
标签:raw new turn 替换 complete wim load lis url
原文地址:https://www.cnblogs.com/jwyblogs/p/13784018.html