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

做ps找图的网站有哪些响应式设计是什么意思

做ps找图的网站有哪些,响应式设计是什么意思,提供衡水网站建设,做的好的网站着陆页使用html2canvas进行截图操作 在 Vue 中使用 ​​html2canvas​​ 将 HTML 元素#xff08;如包含贝塞尔曲线的 Canvas/SVG#xff09;转换为图片 下载html2canvas npm install html2canvas在页面中使用#xff0c;要截取哪个div的内容#xff0c;先给这个div加一个ref标…使用html2canvas进行截图操作 在 Vue 中使用 ​​html2canvas​​ 将 HTML 元素如包含贝塞尔曲线的 Canvas/SVG转换为图片 下载html2canvas npm install html2canvas在页面中使用要截取哪个div的内容先给这个div加一个ref标识如ref“html_container” 主要用到的 具体代码 templatediv classCanvasPage refhtml_container!-- 未处理时的canvas画布数据 --canvas :idcanvas 002 :styleposition: absolute; /canvas!-- 使用赛贝尔曲线以及笔锋处理之后的画布数据 --canvas:idcanvas 001pointerdown.stoponPointerDown:styleposition: absolute; touchstartonTouchstart/canvasdiv classCanvasPageSaveel-button clicktoSave typeprimary保存当前页面/el-button/div/div /templatescript setup import { ref, reactive, onMounted } from vue; import { Bezier } from bezier-js; import html2canvas from html2canvas let html_container ref(null); let canvas, ctx; let canvasCover, ctxCover; const winH window.innerHeight,winW window.innerWidth;let isMove false; // canvas初始化 const initCanvas () {canvas document.getElementById(canvas001);ctx canvas.getContext(2d, {antialias: true, // 抗锯齿});canvas.width winW; // canvas宽度canvas.height winH; // canvas高度ctx.lineWidth 2; // 画线默认宽度ctx.strokeStyle red; // 设置颜色// 复制出来一份原始的canvas画线数据canvasCover document.getElementById(canvas002);ctxCover canvasCover.getContext(2d, {antialias: true, // 抗锯齿});canvasCover.width winW; // canvas宽度canvasCover.height winH; // canvas高度ctxCover.lineWidth 2; // 画线默认宽度ctxCover.strokeStyle red; // 设置颜色 };let startx ref(0), //起始坐标starty ref(0),pointerId ref(null);let points []; // 收集所有点的数据// pointerdown同时处理鼠标、触摸屏和触控笔。 const onPointerDown (e) {points [];isMove true;const { offsetX, offsetY } e;pointerId e.pointerId;startx.value offsetX;starty.value offsetY;canvas.addEventListener(pointermove, onDrawMove);canvas.addEventListener(pointerup, onDrawUp); };/* 单个触摸事件 */ // 处理移动逻辑 const onDrawMove (e) {if (isMove) {const { offsetX, offsetY } e;if (pointerId ! e.pointerId) return;// 原始画线数据ctxCover.beginPath();ctxCover.lineWidth 2; // 设置线条粗细ctxCover.moveTo(startx.value, starty.value);ctxCover.lineTo(offsetX, offsetY);ctxCover.stroke();ctxCover.closePath();startx.value offsetX;starty.value offsetY;points.push({x: offsetX,y: offsetY,});e.preventDefault();} } // 处理释放逻辑 const onDrawUp (e) {ctx.closePath();// 鼠标释放时处理线条将处理过的数据显示之前的数据清空drawSmoothLine();points [];isMove false;document.removeEventListener(pointermove, onDrawMove);document.removeEventListener(pointerup, onDrawUp); } // 优化线条 const drawSmoothLine () {isMove false;if (points.length 1) {let num1 200; // 补点数let num2 20; // 从后面开始变细的点数const startWidth 2; // 设置线条粗细const endWidth 0; // 最后变细的宽度ctxCover.clearRect(0, 0, canvasCover.width, canvasCover.height); // 清除原始数据// 在释放的时候使用贝塞尔曲线重新处理画出来的线ctx.lineWidth startWidth;// 设置线条粗细// 使用赛贝尔曲线让线条更丝滑const bez new Bezier(points);const pointOnCurve bez.getLUT(num1); // 补点ctx.beginPath();ctx.moveTo(pointOnCurve[0].x, pointOnCurve[0].y);// 截取从开始截取到需要变细的位置正常画线pointOnCurve.slice(0, -num2).forEach((p) ctx.lineTo(p.x, p.y)); ctx.stroke();// 笔锋设置线从哪个位置开始按一定比例变细pointOnCurve.slice(-num2).forEach((p, px) {const lineWidth startWidth ((endWidth - startWidth) * px) / num2;ctx.lineWidth lineWidth;ctx.lineTo(p.x, p.y);ctx.stroke();});ctx.lineWidth startWidth;ctx.closePath();} };const toSave () {// html2canvas截取工具第一个参数是截取的元素这里使用的ref第二个参数是相应的配置html2canvas(html_container.value, {background: transparent,useCORS: true}).then((canvas) {const base64 canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, );// console.log(data:image/png;base64,${base64});// 可选自动下载图片const link document.createElement(a);link.download bezier-curve.png;link.href data:image/png;base64,${base64};link.click();}); } onMounted(() {initCanvas(); }); /scriptstyle scoped langscss .CanvasPage {width: 100%;height: 100%;background-color: #044444;position: relative;.CanvasPageSave {position: absolute;left: 0;top: 0;} } /style
http://www.zqtcl.cn/news/445793/

相关文章:

  • 家教网站建设的推广猪八戒网站做私活赚钱吗
  • 男女做那种的视频网站asp.net做网站怎么样
  • 给企业做网站怎么收钱郑州网站顾问
  • readme.md做网站设计网页的快捷网站
  • 做双语网站用什么cms系统好百度后台管理
  • 什么网站可以做试卷企业的oa管理系统
  • 经典网站模板自己做pc网站建设
  • 网站有源码之后怎么建设网站河北加工活外发加工网
  • 什么网站可以做自媒体外包小程序
  • 建网站_网站内容怎么做网络营销的广告形式
  • 静态网站怎么做留言板关键词有哪些
  • 开发软件自学步骤朝阳seo推广
  • Wordpress有用么网络推广seo怎么做
  • 企业做网站的注意事项深圳市建网站
  • 代做网站关键词怎么自创网页
  • 网站建设资金申请报告深圳物流公司收费标准
  • 全能企业网站管理系统做教案比较好的网站
  • 昆明做网站竞价单页营销型网站建设
  • 网站注销备案查询厦门好的做网站公司
  • 大学生兼职网站做ppt数字化营销模式及特点
  • 网站虚拟主机1gwordpress自定义头像插件
  • 网站建设的栏目策划长沙网站制作价
  • h5商城网站怎么建立建设银行网站号
  • 养殖舍建设网站网站设计建设流程图
  • 麦包包的网站建设分析陕西城乡建设部网站
  • 网站测评必须做灯笼制作手工简单又漂亮
  • 购物网站建设的意义与目的wordpress 插件 加速
  • 大型html5浅蓝色网站设计公司dede模板网店怎么开店详细教程
  • 一个阿里云怎么做两个网站吗樱花16q808a
  • 如何利用服务器做网站网站建设朝阳