gy134340 / wxml2canvas Goto Github PK
View Code? Open in Web Editor NEWone simple way to draw canvas
Home Page: https://github.com/gy134340/wxml2canvas/blob/master/utils/wxml2canvas.js
one simple way to draw canvas
Home Page: https://github.com/gy134340/wxml2canvas/blob/master/utils/wxml2canvas.js
`
1.第一点
传入的#wrapper好像没有什么用
drawCanvas: function() {
const wrapperId = '#wrapper'
const drawClassName = '.draw'
const canvasId = 'canvas-map'
wxml2canvas(wrapperId, drawClassName, canvasId).then(() => {
// canvas has been drawn
// can save the image with wx.canvasToTempFilePath and wx.saveImageToPhotosAlbum
})
},
我以为可以区域转canvas,结果是每次都是整个xml的view转,
举个例子
<text data-text="465565">AAAAAA</text>
<text data-text="465565">AAAAAA</text>
<text data-text="465565">AAAAAA</text>
<text class="draw" data-text="只有这里才会转canvas">hgjghjgghjgj</text>
<text data-text="465565">AAAAAA</text>
<text data-text="465565">AAAAAA</text>
<text data-text="465565">AAAAAA</text>
// 很明显,只有有类名draw的才会转canvas,那其他view没有draw类名的都会当空行处理
这就有点问题了,我本来要是要将
<text class="draw" data-text="只有这里才会转canvas">hgjghjgghjgj</text>
转canvas画在顶部,实际是画在中间的位置,整个有点不合理,应该是有什么就画什么,不应该出现空白。。。。
`
2.第二,如果文字中英文混合,有时也会出现乱码的情况
3.如果文字有空格也会出现错乱
bug实在太多了
drawMutipleLine 方法中这一段代码:const lineHieght = lineHeightAttr === 'normal' ? Math.round(1.2 * letterWidth) : lineHeightAttr 因为letterWidth变量是一个字符串,所以导致最后计算lineHieght为NAN,最终导致多行文本定位错位。
应改为 : const lineHieght = lineHeightAttr === 'normal' ? Math.round(1.2 * Number(letterWidth.replace('px',''))) : lineHeightAttr
demo直接跑的,模拟器上使用没问题,但是在真机上,图片就不显示了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.