Commit 97f41592 by doszhang

dos

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