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

uniapp中使用leaferui使用Canvas绘制复杂异形表格的实现方法

需求:

如下图,要实现左图的样式,先实现框架,文字到时候 往里填就行了,原来的解决方案是想用css,html来实现,发现实现起来蛮麻烦的。我也没找到合适的实现方法,最后换使用canvas来实现,使用的js库是leaferui

1.安装:用game是因为有一些交互,反正体积也不大

npm install leafer-game

2.wxml

    <canvas:style="'width:'+cabox.width+'px;height:'+cabox.height+'px;'"id="leafer"type="2d":width="cabox.width":height="cabox.height"catchtouchstart="receiveEvent"catchtouchmove="receiveEvent"catchtouchend="receiveEvent"catchtouchcancel="receiveEvent"></canvas>

3.javascript

  lf = new Leafer({view: window, width: that.cabox.width, height: that.cabox.height})lf.add(Rect.one(0,0,that.cabox.width,that.cabox.height));lf.add(Rect.one({width: that.cabox.width, height: that.cabox.height, strokeWidth: 2, stroke: "black",}));lf.add(Rect.one({strokeWidth: 2,stroke: "black",width: (that.cabox.perBox * 11.5),height: (that.cabox.perBox * 11.5),x: that.cabox.perBox * 1.75,y: that.cabox.perBox * 1.75}));lf.add(Rect.one({strokeWidth: 2,stroke: "black",width: (that.cabox.perBox * 9),height: (that.cabox.perBox * 9),x: that.cabox.perBox * 3,y: that.cabox.perBox * 3}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, 0, that.cabox.perBox * 3, that.cabox.perBox * 3]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.width, 0, that.cabox.perBox * 12, that.cabox.perBox * 3]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.width, that.cabox.height, that.cabox.perBox * 12, that.cabox.perBox * 12]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, that.cabox.height, that.cabox.perBox * 3, that.cabox.perBox * 12]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.perBox*6, 0, that.cabox.perBox*6, that.cabox.height]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [that.cabox.perBox*9, 0, that.cabox.perBox*9, that.cabox.height]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, that.cabox.perBox*6, that.cabox.width, that.cabox.perBox*6]}));lf.add(Line.one({stroke: "black",strokeWidth: 2,points: [0, that.cabox.perBox*9, that.cabox.width, that.cabox.perBox*9]}));

http://www.lryc.cn/news/543755.html

相关文章:

  • 判别分析:原理推导、方法对比与Matlab实战
  • PMP项目管理—整合管理篇—4.管理项目知识
  • Makefile编写和相关语法规则
  • 点云 PCL 滤波在自动驾驶的用途。
  • NL2SQL的应用-长上下文模型在处理NL2SQL任务时,相较于传统模型,有哪些显著的优势
  • 图像处理基础(8):图像的灰度直方图、直方图均衡化、直方图规定化(匹配)
  • 探寻数组中两个不重复数字的奥秘:C 语言实战之旅
  • Mercury、LLaDA 扩散大语言模型
  • 【ESP32S3接入讯飞在线语音识别】
  • 深入了解 SSH 及其相关协议
  • 微信小程序源码逆向 MacOS
  • 【我的 PWN 学习手札】House of Husk
  • (八)趣学设计模式 之 装饰器模式!
  • 设计后端返回给前端的返回体
  • Element Plus中el-select选择器的下拉选项列表的样式设置
  • C高级(shell)
  • 子宫腺肌症是如果引起的?
  • 网络安全学习中,web渗透的测试流程是怎样的?
  • 【软考】【2025年系统分析师拿证之路】【啃书】第十四章 软件实现与测试(十五)
  • 自然语言处理NLP深探
  • 加载互联网免费地图资源并通过CesiumEarth快速浏览
  • Android 键盘输入按确认或换行 直接触发提交
  • halcon三维点云数据处理(二十七)remove_bin_for_3d_object_localization
  • XFeat:轻量级的深度学习图像特征匹配
  • [MD] AG stable
  • 微信小程序自定义导航栏实现指南
  • wav格式的音频压缩,WAV 转 MP3 VBR 体积缩减比为 13.5%、多个 MP3 格式音频合并为一个、文件夹存在则删除重建,不存在则直接建立
  • 面试问题——如何解决移动端1px 边框问题?
  • 鸿蒙开发第4篇__关于在鸿蒙应用中使用Java语言进行设计
  • 什么是Ollama?什么是GGUF?二者之间有什么关系?