Commit 85bfda95 by doszhang

dos

parent e9c0463a
......@@ -394,12 +394,9 @@ function drawFlagItem(initialPosition) {
redline.src = picUrl + 'flag-redline.png';
let nodeList = $('.poster-page .poster-list .flag-item');
for (let i = 0; i < flagStack.length; i++) {
console.log($(nodeList[i]));
let top = initialPosition + $(nodeList[i]).offset().top;
// console.log('top:' + top);
posterCtx.drawImage(noBg, pxToRem(105), top, pxToRem(44), pxToRem(39));
flagNoDraw(posterCtx, i + 1, 24, 'normal', '#222222', pxToRem(127), top + pxToRem(20));
}
}
}
......@@ -854,4 +851,31 @@ function checkIt(bind, maxNum) {
function pxToRem(px) {
return (px / 20) * fontSize;
}
function flagNoDraw(ctx, content, fontsize, fontweight, color, x, y) {
x = x * 2;
y = y * 2;
fontsize = fontsize * 2;
ctx.font = fontweight + ' ' + fontsize + 'px';
var width = ctx.measureText(content).width;
var cx = x - width / 2;
ctx.fillStyle = color;
ctx.fillText(content, cx, y);
}
function calculateStringLength(str) {
var len = 0; //中英字符长度计数
//计算
for (i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);
if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) //英文字母状态
{
len++;
} else //中文状态
{
len += 2;
}
}
return str;
}
\ No newline at end of file
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