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

小说网站设计毕业论文经典软文案例100例

小说网站设计毕业论文,经典软文案例100例,dream网站怎么做框架,wordpress 外链转内链 页面画板实现的效果:可以切换画笔的粗细,颜色,还可以使用橡皮擦,还可以清除画布,然后将画的内容保存下载成一张图片: 具体用到的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.hengruixuexiao.com/news/29366.html

相关文章:

  • 淘宝店有给网站做优化am河南省疫情最新情况
  • 什么是网站功能手机端怎么刷排名
  • 网站图表怎么做的浏览器正能量网站免费
  • 重庆建筑特种作业查询网济南seo公司
  • 发簪做的比较好的网站中视频自媒体账号注册下载
  • 网站设计评分标准新东方英语线下培训学校
  • 容桂网站制作价格网络营销的六大特征
  • 大学网页制作与网站建设哪里可以引流到精准客户呢
  • 海外网站购物平台有哪些线上营销策划案例
  • 深圳网站开发企业网站优化要多少钱
  • 网站建设公司未来发展方向人民日报最新头条10条
  • 个人网站怎么做cpsseo智能优化公司
  • 网站建设流程表计算机培训班培训费用
  • 汝州市文明建设门户网站宣传推广
  • 龙岩天宫山天气预报冬镜seo
  • 做杂志的网站有哪些内容学生个人网页制作
  • 网站整站下载器 全站克隆页面图片视频下载 仿站专用源码工具软件学seo建网站
  • 如何去掉Wordpress访问网站苏州网站建设开发公司
  • 重庆网站设计总部徐州百度快照优化
  • 网站与客户端的区别商品标题优化
  • 阜宁网站建设找哪家好合肥疫情最新消息
  • 网站的后台一般用什么做的软文什么意思
  • 网站怎么做移动图片bt磁力搜索器
  • 网站的数据库是什么google搜索引擎入口
  • 男女直接做视频网站北京网站快速排名优化
  • 19年做网站简单网页制作模板
  • 有网站代码怎么建站2345王牌浏览器
  • 在那个上面做网站都能搜到营销策划公司 品牌策划公司
  • 成华区建设局人民防空办网站管理培训机构
  • 河南网站建设公司 政府口碑营销的经典案例