当前位置: 首页 > news >正文

企业网站模板购买企业级网站建设

企业网站模板购买,企业级网站建设,wordpress导航文件,wordpress视频教学因为我的一个项目是使用GitHub action来实现编译和部署的,而且这个android项目的icon很有可能会发生变化,所以需要在脚本中实现自动化生成icon的功能,所以这里就写了一个js脚本来做这个事情 这个脚本可以输入一个图片地址,然后生…

因为我的一个项目是使用GitHub action来实现编译和部署的,而且这个android项目的icon很有可能会发生变化,所以需要在脚本中实现自动化生成icon的功能,所以这里就写了一个js脚本来做这个事情

这个脚本可以输入一个图片地址,然后生成android项目的icon图标。

脚本文件内容:

const sharp = require('sharp')
const fs = require('fs-extra')
const path = require('path')
const { program } = require('commander')const DENSITIES = {mdpi: 48,hdpi: 72,xhdpi: 96,xxhdpi: 144,xxxhdpi: 192,
}program.requiredOption('-i, --input <file>', 'Path to source PNG').option('-o, --output <dir>', 'Output directory', 'res').option('--rounded', 'Apply circular mask to icons').option('--copy-to <androidResDir>', 'Copy icons to Android res directory')program.parse(process.argv)
const options = program.opts()async function generateAdaptiveIcons(input, outputDir) {for (const [dpi, size] of Object.entries(DENSITIES)) {const mipmapDir = path.join(outputDir, `mipmap-${dpi}`)await fs.ensureDir(mipmapDir)const foregroundPath = path.join(mipmapDir,'ic_launcher_foreground.png')const backgroundPath = path.join(mipmapDir,'ic_launcher_background.png')const legacyPath = path.join(mipmapDir, 'ic_launcher.png')const img = sharp(input).resize(size, size)const rounded = options.rounded? img.composite([{input: Buffer.from(`<svg><circle cx="${size / 2}" cy="${size / 2}" r="${size / 2}" fill="white"/></svg>`),blend: 'dest-in',},]): imgawait rounded.toFile(foregroundPath)await sharp({create: {width: size,height: size,channels: 4,background: '#FFFFFF',},}).png().toFile(backgroundPath)// legacy fallbackawait rounded.toFile(legacyPath)}// Generate XMLconst xmlPath = path.join(outputDir, 'mipmap-anydpi-v26')await fs.ensureDir(xmlPath)await fs.writeFile(path.join(xmlPath, 'ic_launcher.xml'),`
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"><background android:drawable="@mipmap/ic_launcher_background"/><foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>`.trim())await fs.writeFile(path.join(xmlPath, 'ic_launcher_round.xml'),`
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"><background android:drawable="@mipmap/ic_launcher_background"/><foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>`.trim())console.log('✅ Adaptive icons generated.')
};(async () => {const { input, output, copyTo } = optionsconst outPath = path.resolve(output)await generateAdaptiveIcons(input, outPath)if (copyTo) {const dest = path.resolve(copyTo)await fs.copy(outPath, dest, { overwrite: true })console.log(`📦 Icons copied to Android res dir: ${dest}`)}
})()

使用说明:

node ./generateIcons.cjs -i pakeplus.png --copy-to app/src/main/res

生成圆角图标:

node ./generateIcons.cjs -i pakeplus.png --rounded --copy-to app/src/main/res

最后生成的结果:

http://www.dtcms.com/a/419078.html

相关文章:

  • 路由器设置手机网站打不开wordpress跳转二级域名
  • MySQL在线DDL:零停机改表实战指南
  • 哪个做图网站可以挣钱马鞍山网站建设公司排名
  • 杭州公司做网站电商是干什么工作的
  • 揭秘InnoDB磁盘I/O与存储空间管理
  • 【深度相机术语与概念】
  • Android studio 依赖jar包里的类引用时红名,但能构建打包运行。解决红名异常
  • 做设计常用的素材网站网站seo啥意思
  • 云南最便宜的网站建设农村电商平台简介
  • AI时代下,我们需要新一代的金融基础软件
  • 挪威网站后缀网站服务器ip
  • Salesforce 生态中的缓存、消息队列和流处理
  • 【开源】基于STM32的无线条码扫描仪控制系统设计
  • 南京我爱我家网站建设新村二手房有限责任公司和有限公司的区别
  • WebStorm 快捷键大全(Windows / macOS 双平台对照)
  • 多线程顺序输出abc
  • CSS盒模型全面解析
  • 免费开源cms网站源码网页设计公司网站设计
  • [pytest] autouse 参数:自动使用fixture
  • 上海市建上海市建设安全协会网站wordpress盲注
  • 论文阅读三-第二章(3)
  • 在 Windows 系统上怎么使用rabbitmq相关命令,比如:rabbitmqctl list_queues 命令
  • spire.doc for .net 在word的表格最后增加行及索引超限处理办法
  • 【android 驱动开发十】中断唤醒功能-维持500ms唤醒状态
  • 微信上可以做网站吗广州专业视频制作
  • wordpress还原网站源码易语言 wordpress
  • 深入解析AppCrawler:开源自动遍历测试工具配置指南
  • 24届(华为OD)Java面经
  • 20届-测试面经-华为OD
  • 重庆seo整站优化效果百度竞价推广属于什么广告