Commit d242bd32 by 张立顺

冲突解决

1 parent a04de189
......@@ -38,14 +38,7 @@ class Draw {
async 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)
......@@ -87,13 +80,7 @@ class Draw {
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)
......@@ -106,25 +93,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
......@@ -237,18 +207,8 @@ class Draw {
this[_ctx_].stroke()
}
drawBorder(params) {
let {
x,
y,
text,
color,
width,
radius,
opacity,
padding,
fontSize
} = params,
paddingX = 0,
let { x, y, text, color, width, radius, opacity, padding, fontSize } = params,
paddingX = 0,
paddingY = 0
if (padding && padding.length) {
paddingX = this.toRpx(padding[0])
......@@ -259,7 +219,8 @@ class Draw {
endX = this.toRpx(x) + this.getTextWidth(text) + paddingX,
startY = this.toRpx(y) - paddingY,
endY = this.toRpx(y + fontSize) + paddingY / 2,
arr = [{
arr = [
{
x: startX,
y: startY,
width: endX
......@@ -286,7 +247,8 @@ class Draw {
this[_ctx_].lineWidth = width || this.toRpx(1)
if (radius) {
radius = this.toRpx(radius)
let arcArr = [{
let arcArr = [
{
moveTo: [startX, startY + radius],
arcTo: [startX, startY, startX + radius, startY]
},
......@@ -331,16 +293,7 @@ class Draw {
}
drawLine(lineParams, callback) {
this[_ctx_].beginPath()
let {
noTransition,
opacity,
startX,
startY,
width,
color,
endX,
endY
} = lineParams
let { noTransition, opacity, startX, startY, width, color, endX, endY } = lineParams
if (!noTransition) {
startX = this.toRpx(startX)
startY = this.toRpx(startY)
......@@ -359,12 +312,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,
......@@ -387,11 +335,7 @@ class Draw {
}
return type[textDecoration][textBaseline]
}
setLineX({
textAlign,
text,
x
}) {
setLineX({ textAlign, text, x }) {
let textWidth = this.getTextWidth(text)
let type = {
left: x,
......@@ -400,13 +344,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()
......@@ -417,12 +355,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,
......@@ -432,12 +365,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)
......@@ -509,14 +437,7 @@ const checkTextDecoration = textDecoration => {
}
/**网络图片转成本地资源 */
<<<<<<< HEAD
const createLocalImg = ({
filePath,
fileId
}, callBack) => {
=======
const createLocalImg = ({ filePath, fileId }, callBack) => {
>>>>>>> dev_v3.1
wx.getImageInfo({
src: filePath,
success(res) {
......@@ -535,4 +456,4 @@ const createLocalImg = ({ filePath, fileId }, 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!