- 新的 canvas 有什么不同吗?
看了代码片段: 建一个屏上 canvas type= 2d,然后 query 拿到 node, 再 getContext,canvas 仍然不是 HTMLCanvasElement ...... 这跟之前有差吗?还是 2.9.0 会不一样? 能不能给个 document.createElement('canvas') 或者 createOffScreenCanvas type = 2d
2019-09-06 - 如何使用 Image 对象?
使用如下代码加载图片,base64 是一个 1x1 的空白 png 转码,开发工具内 Works,真机调试报错,有人遇到过吗? let canvas = wx.createOffscreenCanvas(); let image = canvas.createImage(); image.onload = () => console.log('Works!'); image.onerror = evt => console.error('Not working!'); let base64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAEGWlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPrtzZyMkzlNsNIV0qD8NJQ2TVjShtLp/3d02bpZJNtoi6GT27s6Yyc44M7v9oU9FUHwx6psUxL+3gCAo9Q/bPrQvlQol2tQgKD60+INQ6Ium65k7M5lpurHeZe58853vnnvuuWfvBei5qliWkRQBFpquLRcy4nOHj4g9K5CEh6AXBqFXUR0rXalMAjZPC3e1W99Dwntf2dXd/p+tt0YdFSBxH2Kz5qgLiI8B8KdVy3YBevqRHz/qWh72Yui3MUDEL3q44WPXw3M+fo1pZuQs4tOIBVVTaoiXEI/MxfhGDPsxsNZfoE1q66ro5aJim3XdoLFw72H+n23BaIXzbcOnz5mfPoTvYVz7KzUl5+FRxEuqkp9G/Ajia219thzg25abkRE/BpDc3pqvphHvRFys2weqvp+krbWKIX7nhDbzLOItiM8358pTwdirqpPFnMF2xLc1WvLyOwTAibpbmvHHcvttU57y5+XqNZrLe3lE/Pq8eUj2fXKfOe3pfOjzhJYtB/yll5SDFcSDiH+hRkH25+L+sdxKEAMZahrlSX8ukqMOWy/jXW2m6M9LDBc31B9LFuv6gVKg/0Szi3KAr1kGq1GMjU/aLbnq6/lRxc4XfJ98hTargX++DbMJBSiYMIe9Ck1YAxFkKEAG3xbYaKmDDgYyFK0UGYpfoWYXG+fAPPI6tJnNwb7ClP7IyF+D+bjOtCpkhz6CFrIa/I6sFtNl8auFXGMTP34sNwI/JhkgEtmDz14ySfaRcTIBInmKPE32kxyyE2Tv+thKbEVePDfW/byMM1Kmm0XdObS7oGD/MypMXFPXrCwOtoYjyyn7BV29/MZfsVzpLDdRtuIZnbpXzvlf+ev8MvYr/Gqk4H/kV/G3csdazLuyTMPsbFhzd1UabQbjFvDRmcWJxR3zcfHkVw9GfpbJmeev9F08WW8uDkaslwX6avlWGU6NRKz0g/SHtCy9J30o/ca9zX3Kfc19zn3BXQKRO8ud477hLnAfc1/G9mrzGlrfexZ5GLdn6ZZrrEohI2wVHhZywjbhUWEy8icMCGNCUdiBlq3r+xafL549HQ5jH+an+1y+LlYBifuxAvRN/lVVVOlwlCkdVm9NOL5BE4wkQ2SMlDZU97hX86EilU/lUmkQUztTE6mx1EEPh7OmdqBtAvv8HdWpbrJS6tJj3n0CWdM6busNzRV3S9KTYhqvNiqWmuroiKgYhshMjmhTh9ptWhsF7970j/SbMrsPE1suR5z7DMC+P/Hs+y7ijrQAlhyAgccjbhjPygfeBTjzhNqy28EdkUh8C+DU9+z2v/oyeH791OncxHOs5y2AtTc7nb/f73TWPkD/qwBnjX8BoJ98VQNcC+8AAAALSURBVAgdY/gPBAAJ+wP9DLtb5wAAAABJRU5ErkJggg==\n"; image.src = base64;
2019-08-11 - 如何扩展/重写 CanvasContext?
正在使用第三方库,打算重写 CanvasContext 提供一些标准接口的支持,比如 getImageData 等,于是我: const CanvasContext = wx.createCanvasContext(canvasId, thisArg).constructor; class MyCanvasContext extends CanvasContext { getImageData(x, y, width, height) { wx.canvasGetImageData(...); } }我希望能用已经创建的 CanvasContext 来初始化 MyCanvasContext,比如: let ctx = wx.createCanvasContext(canvasId); let myCtx = new MyCanvasContext(ctx); 请教 MyCanvasContext 的构造函数应该如何写?希望不是 clone object :p
2019-08-09