Commit 9633a0fc by doszhang

dos

parent fbd27c9d
...@@ -395,8 +395,10 @@ function drawFlagItem(initialPosition) { ...@@ -395,8 +395,10 @@ function drawFlagItem(initialPosition) {
let nodeList = $('.poster-page .poster-list .flag-item'); let nodeList = $('.poster-page .poster-list .flag-item');
for (let i = 0; i < flagStack.length; i++) { for (let i = 0; i < flagStack.length; i++) {
let top = initialPosition + $(nodeList[i]).offset().top; let top = initialPosition + $(nodeList[i]).offset().top;
let textTop = initialPosition + $(nodeList[i]).find('.flag-text').offset().top;
posterCtx.drawImage(noBg, pxToRem(105), top, pxToRem(44), pxToRem(39)); posterCtx.drawImage(noBg, pxToRem(105), top, pxToRem(44), pxToRem(39));
flagNoDraw(posterCtx, i + 1, 14, '#222222', pxToRem(129), top + pxToRem(28)); flagNoDraw(posterCtx, i + 1, 14, '#222222', pxToRem(129), top + pxToRem(28));
flagTextDraw(posterCtx, flagStack[i], 16, '#222222', pxToRem(167), textTop);
} }
} }
} }
...@@ -862,18 +864,19 @@ function flagNoDraw(ctx, content, fontsize, color, x, y) { ...@@ -862,18 +864,19 @@ function flagNoDraw(ctx, content, fontsize, color, x, y) {
ctx.fillStyle = color; ctx.fillStyle = color;
ctx.fillText(content, cx, y); ctx.fillText(content, cx, y);
} }
flagTextDraw(posterCtx, '测试测试测试测试测试测试测试测试', 12, '#fff', 0, 0);
function flagTextDraw(ctx, content, fontsize, color, x, y) { function flagTextDraw(ctx, content, fontsize, color, x, y) {
let length = calculateStringLength(content); let length = calculateStringLength(content);
if (length < 14) {
ctx.font = fontsize + 'px normal';
ctx.fillStyle = color;
ctx.fillText(content, x, y);
} else {
let lineArr = []; let lineArr = [];
for (let i = 0; i < content.length; i += 14) { for (let i = 0; i < content.length; i += 14) {
lineArr.push(content.substr(i, 14)); lineArr.push(content.substr(i, 14));
} }
console.log(lineArr);
if (length < 14) {
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment