Commit 550057c5 by dosZhang

dos

parent 1aba5e20
......@@ -327,8 +327,8 @@ function createPoster() {
setTimeout(function () {
posterCtx.drawImage(posterMask, 0, 0, 640 * 2, 1238 * 2);
drawVerticalText(posterCtx, username, '#595857',32 * 2, 95 * 2, 345 * 2, true);
drawVerticalText(posterCtx, company, '#595857',32 * 2, 95 * 2, 505 * 2, true);
drawVerticalText(posterCtx, username, '#595857',32 * 2, 95 * 2, 345 * 2, true, 5 * 2);
drawVerticalText(posterCtx, company, '#595857',32 * 2, 95 * 2, 505 * 2, true, 5 * 2);
$('#notification_area').remove();
$('.upload-page').hide();
......@@ -341,7 +341,7 @@ function createPoster() {
}
}
function drawVerticalText(ctx, text, color, fontSize, x, y, isBold) {
function drawVerticalText(ctx, text, color, fontSize, x, y, isBold, letterSpacing) {
ctx.save(); // 保存当前状态
// 设置字体样式,判断是否加粗
......@@ -350,21 +350,22 @@ function drawVerticalText(ctx, text, color, fontSize, x, y, isBold) {
ctx.fillStyle = color; // 设置字体颜色
ctx.textBaseline = 'middle'; // 设置基准线为中间
ctx.textAlign = 'center'; // 设置文本对齐为居中
ctx.lineWidth = 10; // 设置描边宽度
ctx.lineWidth = 2; // 设置描边宽度
ctx.strokeStyle = 'white'; // 设置描边颜色
// 计算每个字符的高度总和
let totalHeight = fontSize * text.length;
// 计算每个字符的高度总和,包含字间距
let totalHeight = (fontSize + letterSpacing) * text.length - letterSpacing;
// 计算起始y坐标,以垂直居中
let startY = y - totalHeight / 2 + fontSize / 2;
// 循环绘制每个字符
for (let i = 0; i < text.length; i++) {
let charY = startY + i * (fontSize + letterSpacing);
// 绘制白色描边
ctx.strokeText(text[i], x, startY + i * fontSize);
ctx.strokeText(text[i], x, charY);
// 绘制文字
ctx.fillText(text[i], x, startY + i * fontSize);
ctx.fillText(text[i], x, charY);
}
ctx.restore(); // 恢复之前的状态
......
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