|
|
@@ -3,8 +3,8 @@ class DrawCanvas {
|
|
|
constructor() {
|
|
|
this._ctx = null
|
|
|
this._canvas = null
|
|
|
- this._executionArr = []
|
|
|
- this._pathArr = []
|
|
|
+ this._executionArr = [] //每移动一笔的数据
|
|
|
+ this._pathArr = [] //抬起落下为一笔
|
|
|
this._style = null
|
|
|
this._matrix = null
|
|
|
}
|
|
|
@@ -16,14 +16,14 @@ class DrawCanvas {
|
|
|
canvas.height = height
|
|
|
this._canvas = canvas
|
|
|
this._ctx = ctx
|
|
|
- this._matrix = ctx.getTransform() //矩阵
|
|
|
- this._executionArr = [] //每移动一笔的数据
|
|
|
- this._pathArr = [] //抬起落下为一笔
|
|
|
+ this._matrix = ctx.getTransform() //IOS真机矩阵没有返回完整参数,导致无法旋转
|
|
|
+ this._executionArr = []
|
|
|
+ this._pathArr = []
|
|
|
// 添加路径底图
|
|
|
const path = this.sPath2cPath(dicTypePath)
|
|
|
if (path) {
|
|
|
this._ctx.stroke(path)
|
|
|
- this._ctx.clip(path) //IOS 下裁切后无法继续画图
|
|
|
+ // this._ctx.clip(path) //IOS真机裁切后,导致无法画图
|
|
|
}
|
|
|
callBack()
|
|
|
console.log('初始化完成');
|
|
|
@@ -79,9 +79,9 @@ class DrawCanvas {
|
|
|
img.src = url
|
|
|
img.onload = () => {
|
|
|
const fillStyle = this._ctx.createPattern(img, 'repeat')
|
|
|
- console.log('画笔样式', fillStyle);
|
|
|
+ console.log('画笔样式', fillStyle, this._matrix);
|
|
|
// 旋转 + 矩阵变化
|
|
|
- if (angle && this._matrix) {
|
|
|
+ if (angle && this._matrix && this._matrix.rotateSelf) {
|
|
|
this._matrix.rotateSelf(angle)
|
|
|
fillStyle.setTransform(this._matrix)
|
|
|
}
|