Commit 97f41592 by doszhang

dos

parent c69e776c
...@@ -216,6 +216,15 @@ function hideShare() { ...@@ -216,6 +216,15 @@ function hideShare() {
} }
function creatPoster() { function creatPoster() {
if(nowTemplate == 5)
{
if($('[name=customize]').val() == '')
{
my_notify('请填写自定义文字');
return false;
}
else
{
var canvasinfo = initCanvas('#posterCanvas',1050,1698); var canvasinfo = initCanvas('#posterCanvas',1050,1698);
posterCanvas = canvasinfo[0]; posterCanvas = canvasinfo[0];
posterctx = canvasinfo[1]; posterctx = canvasinfo[1];
...@@ -244,8 +253,41 @@ function creatPoster() { ...@@ -244,8 +253,41 @@ function creatPoster() {
} }
} }
} }
}
}
else
{
var canvasinfo = initCanvas('#posterCanvas',1050,1698);
posterCanvas = canvasinfo[0];
posterctx = canvasinfo[1];
var posterObj = new Image();
posterObj.src = '/Public/static/image2/poster.png';
posterObj.onload = function() {
posterctx.drawImage(posterObj,0,0,posterCanvas.width,posterCanvas.height);
var headimgObj = new Image();
headimgObj.src = getManBase64(uploadCanvas);
headimgObj.onload = function() {
posterctx.drawImage(headimgObj,51*2,184*2,387*2,387*2);
var frameimg = new Image();
frameimg.src = '/Public/static/image2/frame' + nowTemplate + '.png';
frameimg.onload = function() {
posterctx.drawImage(frameimg,51*2,184*2,387*2,387*2);
txtDraw(posterctx, $('[name=customize]').val(), 41, 'normal', '#fff', 51,184);
$('#poster').attr('src',getManBase64(posterCanvas));
$('.upload-page').fadeOut(300);
$('.poster-page').fadeIn(300);
}
}
}
}
} }
function backToUpload() { function backToUpload() {
...@@ -393,14 +435,12 @@ function initGame() { ...@@ -393,14 +435,12 @@ function initGame() {
$('.customize').hide(); $('.customize').hide();
} }
function txtDraw(ctx, content, fontsize, fontweight, color) { function txtDraw(ctx, content, fontsize, fontweight, color, cx=0, cy=0) {
var contentArr = content.split(''); var contentArr = content.split('');
if(contentArr.length == 1) if(contentArr.length == 1)
{ {
x = 255; x = (255+cx) * 2;
y = 276; y = (276+cy) * 2;
x = x * 2;
y = y * 2;
fontsize = fontsize * 2; fontsize = fontsize * 2;
ctx.font = fontweight + ' '+fontsize+'px zkkh'; ctx.font = fontweight + ' '+fontsize+'px zkkh';
...@@ -410,8 +450,8 @@ function txtDraw(ctx, content, fontsize, fontweight, color) { ...@@ -410,8 +450,8 @@ function txtDraw(ctx, content, fontsize, fontweight, color) {
} }
else if(contentArr.length == 2) else if(contentArr.length == 2)
{ {
x = 236; x = 236+cx;
y = 276; y = 276+cy+cx;
x = x * 2; x = x * 2;
y = y * 2; y = y * 2;
fontsize = fontsize * 2; fontsize = fontsize * 2;
...@@ -423,8 +463,8 @@ function txtDraw(ctx, content, fontsize, fontweight, color) { ...@@ -423,8 +463,8 @@ function txtDraw(ctx, content, fontsize, fontweight, color) {
} }
else if(contentArr.length == 3) else if(contentArr.length == 3)
{ {
x = 236; x = 236+cx;
y = 259; y = 255+cy;
x = x * 2; x = x * 2;
y = y * 2; y = y * 2;
fontsize = fontsize * 2; fontsize = fontsize * 2;
...@@ -433,16 +473,16 @@ function txtDraw(ctx, content, fontsize, fontweight, color) { ...@@ -433,16 +473,16 @@ function txtDraw(ctx, content, fontsize, fontweight, color) {
ctx.fillStyle = color; ctx.fillStyle = color;
ctx.fillText(contentArr[0] + contentArr[1], x, y); ctx.fillText(contentArr[0] + contentArr[1], x, y);
x = 255; x = 255+cx;
y = 302; y = 295+cy;
x = x * 2; x = x * 2;
y = y * 2; y = y * 2;
ctx.fillText(contentArr[2], x, y); ctx.fillText(contentArr[2], x, y);
} }
else if(contentArr.length == 4) else if(contentArr.length == 4)
{ {
x = 236; x = 236+cx;
y = 255; y = 255+cy;
x = x * 2; x = x * 2;
y = y * 2; y = y * 2;
fontsize = fontsize * 2; fontsize = fontsize * 2;
...@@ -451,8 +491,8 @@ function txtDraw(ctx, content, fontsize, fontweight, color) { ...@@ -451,8 +491,8 @@ function txtDraw(ctx, content, fontsize, fontweight, color) {
ctx.fillStyle = color; ctx.fillStyle = color;
ctx.fillText(contentArr[0] + contentArr[1], x, y); ctx.fillText(contentArr[0] + contentArr[1], x, y);
x = 236; x = 236+cx;
y = 295; y = 295+cy;
x = x * 2; x = x * 2;
y = y * 2; y = y * 2;
ctx.fillText(contentArr[2] + contentArr[3], x, y); ctx.fillText(contentArr[2] + contentArr[3], x, y);
......
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