兰州网站建设q.479185700惠,科技有限公司简介模板,深圳建网站公司怎么选择,登陆建设银行wap网站1. 写在前面
GPT自从去年爆发以来#xff0c;各大公司在大模型方面持续发力#xff0c;行业大模型也如雨后春笋一般发展迅速#xff0c;日常工作中比较多的应用场景还是问答模式#xff0c;作为写程序的辅助也偶尔使用。今天看到一篇翻译的博客“我用 ChatGPT#xff0c;… 1. 写在前面
GPT自从去年爆发以来各大公司在大模型方面持续发力行业大模型也如雨后春笋一般发展迅速日常工作中比较多的应用场景还是问答模式作为写程序的辅助也偶尔使用。今天看到一篇翻译的博客“我用 ChatGPT在 120 秒内做了一个飞机观测器”_CSDN资讯的博客-CSDN博客
博客内容大致Chat GPT写一个HTML用户给定自己的坐标可以实时接收飞过头顶的飞机信息。PlaneSpotter - Flight Notifier 既然可以这样那......发挥想象
本文利用免费的GPT 3.5
2. 抠图小程序
工作中做PPT经常需要透明底的图片所以也收藏了一些图片处理网站但是使用的时候要么扫码关注公众号、要么注册用户......神烦
当然也有不错的去背景网站例如Remove Background from Image, Free HD, No Signup - Pixian.AI
但是为什么不利用Chat GPT直接写一个呢说干就干
提问将图片白底变成透明底的程序支持上传图片、下载图片以单个HTML完成编程 回答在HTML中您可以使用HTML5的input元素允许用户上传图像然后使用HTML5 canvas 元素和JavaScript来处理图像将白色背景变为透明。然后您可以提供下载链接以下载处理后的图像。以下是一个完整的示例
!DOCTYPE html
html
headtitle图片白底变透明/title
/head
bodyh1图片白底变透明/h1!-- 上传图像的输入 --input typefile idimageInput acceptimage/* /!-- 用于显示处理后的图像 --canvas idoutputCanvas styledisplay: none;/canvas!-- 下载按钮 --a iddownloadLink styledisplay: none; downloadtransparent.png下载处理后的图像/ascript// 监听文件上传const imageInput document.getElementById(imageInput);imageInput.addEventListener(change, function() {const file imageInput.files[0];if (file) {const reader new FileReader();reader.onload function(e) {const img new Image();img.onload function() {// 创建Canvas用于图像处理const canvas document.getElementById(outputCanvas);canvas.width img.width;canvas.height img.height;const ctx canvas.getContext(2d);// 清空Canvasctx.clearRect(0, 0, canvas.width, canvas.height);// 在Canvas上绘制图像ctx.drawImage(img, 0, 0);// 获取图像数据const imageData ctx.getImageData(0, 0, canvas.width, canvas.height);// 处理图像数据将白色背景变为透明for (let i 0; i imageData.data.length; i 4) {// 检查像素是否为白色if (imageData.data[i] 240 imageData.data[i 1] 240 imageData.data[i 2] 240) {// 将白色像素的alpha通道设置为0即透明imageData.data[i 3] 0;}}// 在Canvas上绘制处理后的图像数据ctx.putImageData(imageData, 0, 0);// 显示下载按钮const downloadLink document.getElementById(downloadLink);downloadLink.href canvas.toDataURL(image/png);downloadLink.style.display block;};img.src e.target.result;};reader.readAsDataURL(file);}});/script
/body
/html这个HTML页面允许用户上传图像然后将白色背景变为透明并提供了下载链接以下载处理后的图像。处理过程是通过JavaScript和Canvas API完成的。
步骤代码复制并保存到HTML文件打开即用 选择白底图片试一下效果。原图与效果图对比 因为飞机有阴影效果一般再试一次 基本完成了白底--透明底小程序开发GPT3.5只用了20s就生成了一个可以直接使用的HTML页面程序赞
3. 经纬度转换
在GIS软件开发过程中会经常遇到经纬度格式转换互联网是有一些在线转换的页面也很方便今天不妨再用20s测试一下GPT3.5
提问完成经纬度格式转换的程序包含经度、纬度两种格式的输入输出以HTML单独页面程序完成 回答以下是一个HTML页面程序用于将经度和纬度之间的格式进行转换。用户可以输入经度和纬度并选择要从哪种格式转换到另一种格式。页面会在用户进行转换时显示结果。请注意这个示例支持将度分秒DMS格式转换为十进制度DD格式以及将十进制度格式转换为度分秒格式。
!DOCTYPE html
html
headtitle经纬度格式转换/title
/head
bodyh1经纬度格式转换/h1label forinputLatitude输入纬度/labelinput typetext idinputLatitude placeholder例如40.7128或40° 42 46 N /label forinputLongitude输入经度/labelinput typetext idinputLongitude placeholder例如-74.0060或74° 0 21 W /label forformatSelect选择格式/labelselect idformatSelectoption valueddToDMS十进制度 (DD) 到 度分秒 (DMS)/optionoption valuedmsToDD度分秒 (DMS) 到 十进制度 (DD)/option/selectbutton idconvertButton转换/buttonh2结果/h2p idresult/pscriptdocument.getElementById(convertButton).addEventListener(click, function() {const inputLatitude document.getElementById(inputLatitude).value;const inputLongitude document.getElementById(inputLongitude).value;const formatSelect document.getElementById(formatSelect).value;const resultElement document.getElementById(result);if (formatSelect ddToDMS) {const latitudeDMS ddToDMS(inputLatitude, latitude);const longitudeDMS ddToDMS(inputLongitude, longitude);resultElement.innerHTML 纬度 (DMS): ${latitudeDMS}br经度 (DMS): ${longitudeDMS};} else if (formatSelect dmsToDD) {const latitudeDD dmsToDD(inputLatitude, latitude);const longitudeDD dmsToDD(inputLongitude, longitude);resultElement.innerHTML 纬度 (DD): ${latitudeDD}br经度 (DD): ${longitudeDD};}});// 将十进制度 (DD) 转换为度分秒 (DMS)function ddToDMS(dd, type) {const d parseInt(dd);const m parseInt((dd - d) * 60);const s ((dd - d - m / 60) * 3600).toFixed(2);const direction (type latitude) ? (dd 0 ? N : S) : (dd 0 ? E : W);return ${Math.abs(d)}° ${m} ${s} ${direction};}// 将度分秒 (DMS) 转换为十进制度 (DD)function dmsToDD(dms, type) {const regex /(\d)°\s?(\d)?\s?(\d(\.\d)?)?\s?([NSEW])?/i;const matches regex.exec(dms);if (matches) {const degrees parseFloat(matches[1]);const minutes parseFloat(matches[2]);const seconds parseFloat(matches[3]);const direction (type latitude) ? (matches[5] S ? -1 : 1) : (matches[5] W ? -1 : 1);return (degrees minutes / 60 seconds / 3600) * direction;}return 无效输入;}/script
/body
/html这个页面允许用户输入纬度和经度选择要从哪种格式转换到另一种格式然后点击转换按钮以查看结果。支持的格式包括十进制度 (DD) 和度分秒 (DMS)。根据用户的选择页面将显示转换后的结果。
步骤代码复制并保存到HTML文件打开即用 可以输入两种格式的经纬度简直完美
4. 写在后面
GPT的确极大地方便了我们的生活以后更需要的是人类的想象力。以前很多小伙伴写这些方便的小程序兼职赚钱没有被同行干掉被新生事物GPT干掉了正如之前的方便面被外卖干掉吧谁还有好的思路的小程序也可以一起试试。
另外Chat GPT生成的程序自己也可以进行调优、调参处理本文没有进行任何代码修改。
感兴趣的小伙伴也可以试试俄罗斯方块等小游戏