Commit 36fbfd31 by 张立顺

调整文件名字

1 parent 89bd9f45
......@@ -8,10 +8,8 @@ class Draw {
[_canvasObject_] = null;
[_canvas_] = null
constructor(canvasObject) {
wx.getSystemInfo().then(({
pixelRatio
}) => {
console.log(pixelRatio)
wx.getSystemInfo().then(({ pixelRatio }) => {
// console.log(pixelRatio)
this[_canvasObject_] = canvasObject
this[_pixelRatio_] = canvasObject.pixelRatio || pixelRatio || 2
const height = this.toRpx(canvasObject.height),
......@@ -38,14 +36,7 @@ class Draw {
drawImages(imageParams, callback) {
this[_ctx_].beginPath()
this[_ctx_].save()
let {
borderRadius,
height,
width,
url,
x,
y
} = imageParams
let { borderRadius, height, width, url, x, y } = imageParams
height = this.toRpx(height)
width = this.toRpx(width)
x = this.toRpx(x)
......@@ -78,13 +69,7 @@ class Draw {
if (fontSize) this[_ctx_].font = `${fontSize}px${font}`
return this[_ctx_].measureText(text).width
}
drawFill({
x,
y,
width,
height,
color
}) {
drawFill({ x, y, width, height, color }) {
height = this.toRpx(height)
width = this.toRpx(width)
x = this.toRpx(x)
......@@ -97,25 +82,8 @@ class Draw {
this[_ctx_].save()
}
drawText(textParams) {
let {
textDecoration,
textBaseline,
lineHeight,
fontWeight,
textAlign,
textWidth,
maxWidth,
fontSize,
lastFont,
opacity,
lineNum,
width,
color,
text,
x,
y
} = textParams,
font = this[_ctx_].font.split('px')[1]
let { textDecoration, textBaseline, lineHeight, fontWeight, textAlign, textWidth, maxWidth, fontSize, lastFont, opacity, lineNum, width, color, text, x, y } = textParams,
font = this[_ctx_].font.split('px')[1]
textAlign = textAlign || 'left'
textBaseline = textBaseline || 'normal'
opacity = typeof opacity === 'number' ? opacity : 1
......@@ -258,15 +226,7 @@ class Draw {
}
drawLine(lineParams, callback) {
this[_ctx_].beginPath()
let {
opacity,
startX,
startY,
width,
color,
endX,
endY
} = lineParams
let { opacity, startX, startY, width, color, endX, endY } = lineParams
startX = this.toRpx(startX)
startY = this.toRpx(startY)
width = this.toRpx(width)
......@@ -283,12 +243,7 @@ class Draw {
if (callback) callback()
}
setLineY = params => {
let {
textDecoration,
textBaseline,
fontSize,
y
} = params
let { textDecoration, textBaseline, fontSize, y } = params
let type = {
underline: {
top: y + fontSize,
......@@ -312,11 +267,7 @@ class Draw {
return type[textDecoration][textBaseline]
}
setLineX({
textAlign,
text,
x
}) {
setLineX({ textAlign, text, x }) {
let textWidth = this.getTextWidth(text)
let type = {
left: x,
......@@ -326,13 +277,7 @@ class Draw {
return type[textAlign]
}
drawRadiusRect({
borderRadius,
height,
width,
x,
y
}, callBack) {
drawRadiusRect({ borderRadius, height, width, x, y }, callBack) {
let radius = typeof borderRadius === 'string' ? ((Number(borderRadius.split('%')[0]) / 100) * width) / 2 : borderRadius / 2
radius = radius || 0
this[_ctx_].beginPath()
......@@ -343,12 +288,7 @@ class Draw {
}
if (callBack) callBack()
}
getFontWidth({
textAlign,
fontSize,
text,
x
}) {
getFontWidth({ textAlign, fontSize, text, x }) {
let type = {
left: x,
center: x - (fontSize * text.length) / 2,
......@@ -358,12 +298,7 @@ class Draw {
}
drawDecoration(params) {
let {
newText,
opacity,
y,
x
} = params
let { newText, opacity, y, x } = params
let lineX = x
let lineY = y
lineX = this.setLineX(params)
......@@ -420,4 +355,4 @@ const createLocalImg = (url, callBack) => {
}
})
}
export default Draw
\ No newline at end of file
export default Draw
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!