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

小说网站设计毕业论文软文什么意思

小说网站设计毕业论文,软文什么意思,呼和浩特建设厅网站首页,南京网站建设服务画板实现的效果:可以切换画笔的粗细,颜色,还可以使用橡皮擦,还可以清除画布,然后将画的内容保存下载成一张图片: 具体用到的canvas功能有:画笔的粗细调整lineWidth,开始一个新的画笔…

画板实现的效果:可以切换画笔的粗细,颜色,还可以使用橡皮擦,还可以清除画布,然后将画的内容保存下载成一张图片:

具体用到的canvas功能有:画笔的粗细调整lineWidth,开始一个新的画笔路径beginPath,结束一个画笔路径closePath,这个可以保证不影响之前画的效果,重新开始一个画笔路径。 还有橡皮擦使用的ctx.globalCompositeOperation = 'destination-out'属性,清空画布使用的:ctx.clearRect(0, 0, canvas.width, canvas.height),保存图片使用的是let url = canvas.toDataURL('image/png')。

完整的代码如下:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>像素操作</title><style>.active {background-color: #f2a1a1;}</style></head><body><div>创建一个画布,可以使用画笔随意画画</div><div style="width: 800px; margin-top: 6px"><button class="bold">粗线条</button><button class="thin">细线条</button><input id="color" type="color" /><button class="del">橡皮擦</button><button class="clear">清空画布</button><button class="save">保存图片</button><hr /><canvas id="myCanvas" width="800" height="600"></canvas></div><script>// 获取画布const canvas = document.getElementById('myCanvas')// 获取画笔const ctx = canvas.getContext('2d')// 让画笔的拐弯处更加圆润,没有锯齿感ctx.lineCap = 'round'ctx.lineJoin = 'round'// 获取控制按钮const bold = document.querySelector('.bold')const thin = document.querySelector('.thin')const color = document.querySelector('#color')const del = document.querySelector('.del')const clear = document.querySelector('.clear')const save = document.querySelector('.save')// 添加点击事件bold.onclick = function () {ctx.lineWidth = 20bold.classList.add('active')thin.classList.remove('active')del.classList.remove('active')clear.classList.remove('active')save.classList.remove('active')}thin.onclick = function () {ctx.lineWidth = 5thin.classList.add('active')bold.classList.remove('active')del.classList.remove('active')clear.classList.remove('active')save.classList.remove('active')}color.onchange = function (e) {console.log('颜色改变了:', e.target.value)ctx.strokeStyle = e.target.value}del.onclick = function () {console.log('橡皮擦')ctx.globalCompositeOperation = 'destination-out'ctx.lineWidth = 30del.classList.add('active')bold.classList.remove('active')thin.classList.remove('active')clear.classList.remove('active')save.classList.remove('active')}clear.onclick = function () {console.log('清空画布')ctx.clearRect(0, 0, canvas.width, canvas.height)}// 保存图片save.onclick = function () {console.log('保存图片')let url = canvas.toDataURL('image/png')let a = document.createElement('a')a.href = urla.download = 'canvas.png'a.click()}// 监听画布画画事件let mouseDown = false// 鼠标按下将变量设置为truecanvas.onmousedown = function (e) {ctx.beginPath()mouseDown = truectx.moveTo(e.offsetX, e.offsetY)}// 鼠标抬起将变量设置为falsecanvas.onmouseup = function () {mouseDown = falsectx.closePath()ctx.globalCompositeOperation = 'source-over'}canvas.onmouseleave = function () {mouseDown = falsectx.closePath()}// 鼠标移动canvas.onmousemove = function (e) {if (mouseDown) {console.log('鼠标移动')ctx.lineTo(e.offsetX, e.offsetY)ctx.stroke()}}</script></body>
</html>

http://www.ds6.com.cn/news/69483.html

相关文章:

  • 安卓网页编辑器seo外包收费
  • 男人网址你懂我意思正能量流程优化
  • 做网站都是花钱吗自助建站系统破解版
  • 帮别人做非法网站自首线上推广工作内容
  • 广州网站建设易得现在百度怎么优化排名
  • 昆明网站建设ynmdwl百度搜索引擎收录
  • 网站建设制作设计营销公司南宁搜索引擎的两个基本方法
  • 东莞网站建设牛魔网a网站域名综合查询
  • 网站有后台更新不了温州seo排名公司
  • 个人做网站seonba最新交易一览表
  • 阿里云服务器如何做两个网站首页关键词怎么排名靠前
  • 施工企业负责人带班检查计划快排seo排名软件
  • 网站开发demo如何拥有自己的网站
  • 建一个商城网站多少钱自己做网站怎么做
  • 企业信息公共服务平台官网海南seo排名优化公司
  • 网站制作与防护费用百度应用
  • 长沙网站设淘宝直通车推广怎么做
  • 广告在什么网站做面点培训学校哪里有
  • 深圳做积分商城网站建设适合小学生的新闻事件
  • 网站开发中怎么联系客服浙江网站建设平台
  • 淄博网站建设公司三农关键词优化公司排行
  • 建设网站只能是公司吗品牌seo培训咨询
  • 做网站先用dw还是asp排名优化系统
  • 化工网站建设公司百度网页版主页网址
  • 使用java做后台网站千锋教育培训机构怎么样
  • 中山网站建设平台搜索引擎营销的特点包括
  • 长春网站建设网加强服务保障满足群众急需ruu7
  • 建材做哪些网站好昆山网站建设推广
  • 常用来做网站首页的是国际新闻最新消息美国
  • 网站免费建百度排名点击软件