Commit 92fba213 by doszhang

dos

parent 6077ed03
......@@ -55,6 +55,19 @@ var fireworkLock = false;
let posterCanvas, posterCtx;
const guardian = [
'事事顺意守',
'健康祈愿守',
'金运上升守',
'心愿成就守',
'事业向上守',
'厄运消散守',
'元气满满守',
'友谊万岁守',
'美貌一番守',
'恋爱成就守'
]
$(document).ready(function () {
if ($('.page').height() < document.documentElement.clientHeight) {
var scale = document.documentElement.clientHeight / $('.page').height();
......@@ -123,7 +136,7 @@ function createPoster(resultFlag) {
posterObj.onload = function () {
posterCtx.drawImage(posterObj, 0, 0, posterCanvas.width, posterCanvas.height);
setTimeout(function () {
// drawNum();
drawNum(resultFlag);
}, 200);
setTimeout(function () {
$('.poster-canvas').append('<img class="posterimg" />');
......@@ -136,57 +149,21 @@ function createPoster(resultFlag) {
}
}
function drawNum() {
posterCtx.font = 'normal ' + '48px normal';
let text1 = '已有';
let text2 = '人发起承诺';
let text1Width = posterCtx.measureText(text1).width;
let text2Width = posterCtx.measureText(text2).width;
posterCtx.font = 'normal ' + '80px num';
let numWidth = posterCtx.measureText(window.num).width;
let totalWidth = text1Width + 10 * 2 + numWidth + 6 * 2 + text2Width;
let text1X = 212 * 2 - totalWidth / 2;
let numX = text1X + text1Width + 10 * 2;
let text2X = numX + numWidth + 6 * 2;
txtDraw(posterCtx, window.num, '#fff', numX, 557 * 2);
posterCtx.font = 'normal ' + '48px normal';
txtDraw(posterCtx, text1, '#fff', text1X, 557 * 2);
txtDraw(posterCtx, text2, '#fff', text2X, 557 * 2);
function drawNum(resultFlag) {
const text1 = `成为樱桃小丸子的第${window.joinNum}个的`;
const text2 = `祈福伙伴,并获得「${guardian[resultFlag-1]}」`
txtDraw(posterCtx, chuan, 281, 24, 'bolder', '#748b6c');
txtDraw(posterCtx, chuan, 281, 24, 'bolder', '#748b6c');
}
function txtDraw(ctx, content, x, y, fontsize, fontweight, color, textAlign = 'left', rightReserved = 0, stroke = false) {
x = x * 2;
y = y * 2;
function txtDraw(ctx, content, top, fontsize, fontweight, color) {
top = top * 2;
fontsize = fontsize * 2;
ctx.font = fontweight + ' ' + fontsize + 'px arial';
if (stroke) {
//设置描边颜色
ctx.strokeStyle = "#494949";
//设置描边宽度
ctx.lineWidth = 7;
}
if (textAlign == 'center') {
var width = ctx.measureText(content).width;
var cx = x - width / 2;
ctx.fillStyle = color;
ctx.fillText(content, cx, y);
} else if (textAlign == 'right') {
var width = ctx.measureText(content).width;
var cx = x - width;
if (rightReserved) {
cx = x - width - rightReserved;
}
ctx.fillStyle = color;
ctx.fillText(content, cx, y);
return width;
} else {
ctx.fillStyle = color;
if (stroke) {
ctx.strokeText(content, x, y);
}
ctx.fillText(content, x, y);
}
var width = ctx.measureText(content).width;
var cx = x - width / 2;
ctx.fillStyle = color;
ctx.fillText(content, cx, y);
}
function getManBase64(canvas) {
......
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