Php 调用写字板图片,手机端写字板、画板vue组件

编程入门 行业动态 更新时间:2024-10-09 18:16:18

Php 调用<a href=https://www.elefans.com/category/jswz/34/897409.html style=写字板图片,手机端写字板、画板vue组件"/>

Php 调用写字板图片,手机端写字板、画板vue组件

一个简单的canvas写字板、画板vue组件,由于项目需求目前只提供清空功能

代码及demo

使用

1.引入组件

import draw from './inDraw/index'

components: {

draw,

},

2.使用组件,可以放在一个自定义样式的div中

:inRatio="3" //retina屏兼容,画布大小放大倍数,Number

:inLineColor="'#999'" //笔触颜色

:inLineWidth="5" //笔触宽度,Number

:inShadowBlur="5" //笔触阴影大小,Number

>

清空

3.自定义清空按钮,调用组件方法inDeleteCanvas清空画布

methods: {

drawDelete(){

this.$refs["in-draw"].inDeleteCanvas()

},

}

开发笔记

1.需要兼容retina屏一倍图模糊的问题,将画布大小设置为canvas元素的2或3倍

//this.inRatio=3;

let canvasDom=this.$refs['in-draw-canvas'];

this.inCanvasBound = canvasDom.getBoundingClientRect();

canvasDom.width=this.inCanvasBound.width*this.inRatio;

canvasDom.height=this.inCanvasBound.height*this.inRatio;

this.inCtx.lineWidth=10*this.inRatio;

2.笔触锯齿问题,设置阴影

this.inCtx.shadowBlur = 5;

this.inCtx.shadowColor = "#000";

3.适应需求在不同位置的画布,笔触实际位置为当前坐标减去画布位置

let x=(e.changedTouches[0].pageX - this.inCanvasBound.left + 0.5)*this.inRatio;

let y=(e.changedTouches[0].pageY- this.inCanvasBound.top + 0.5)*this.inRatio;

更多推荐

Php 调用写字板图片,手机端写字板、画板vue组件

本文发布于:2024-02-10 22:03:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1677534.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:写字板   画板   组件   手机   图片

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!