Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
pingan-maruko
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
92fba213
authored
Jun 17, 2020
by
doszhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
6077ed03
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
48 deletions
+25
-48
Public/static/js/common.js
+25
-48
No files found.
Public/static/js/common.js
View file @
92fba213
...
@@ -55,6 +55,19 @@ var fireworkLock = false;
...
@@ -55,6 +55,19 @@ var fireworkLock = false;
let
posterCanvas
,
posterCtx
;
let
posterCanvas
,
posterCtx
;
const
guardian
=
[
'事事顺意守'
,
'健康祈愿守'
,
'金运上升守'
,
'心愿成就守'
,
'事业向上守'
,
'厄运消散守'
,
'元气满满守'
,
'友谊万岁守'
,
'美貌一番守'
,
'恋爱成就守'
]
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
if
(
$
(
'.page'
).
height
()
<
document
.
documentElement
.
clientHeight
)
{
if
(
$
(
'.page'
).
height
()
<
document
.
documentElement
.
clientHeight
)
{
var
scale
=
document
.
documentElement
.
clientHeight
/
$
(
'.page'
).
height
();
var
scale
=
document
.
documentElement
.
clientHeight
/
$
(
'.page'
).
height
();
...
@@ -123,7 +136,7 @@ function createPoster(resultFlag) {
...
@@ -123,7 +136,7 @@ function createPoster(resultFlag) {
posterObj
.
onload
=
function
()
{
posterObj
.
onload
=
function
()
{
posterCtx
.
drawImage
(
posterObj
,
0
,
0
,
posterCanvas
.
width
,
posterCanvas
.
height
);
posterCtx
.
drawImage
(
posterObj
,
0
,
0
,
posterCanvas
.
width
,
posterCanvas
.
height
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
// drawNum(
);
drawNum
(
resultFlag
);
},
200
);
},
200
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$
(
'.poster-canvas'
).
append
(
'<img class="posterimg" />'
);
$
(
'.poster-canvas'
).
append
(
'<img class="posterimg" />'
);
...
@@ -136,57 +149,21 @@ function createPoster(resultFlag) {
...
@@ -136,57 +149,21 @@ function createPoster(resultFlag) {
}
}
}
}
function
drawNum
()
{
function
drawNum
(
resultFlag
)
{
posterCtx
.
font
=
'normal '
+
'48px normal'
;
const
text1
=
`成为樱桃小丸子的第
${
window
.
joinNum
}
个的`
;
let
text1
=
'已有'
;
const
text2
=
`祈福伙伴,并获得「
${
guardian
[
resultFlag
-
1
]}
」`
let
text2
=
'人发起承诺'
;
txtDraw
(
posterCtx
,
chuan
,
281
,
24
,
'bolder'
,
'#748b6c'
);
let
text1Width
=
posterCtx
.
measureText
(
text1
).
width
;
txtDraw
(
posterCtx
,
chuan
,
281
,
24
,
'bolder'
,
'#748b6c'
);
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
txtDraw
(
ctx
,
content
,
x
,
y
,
fontsize
,
fontweight
,
color
,
textAlign
=
'left'
,
rightReserved
=
0
,
stroke
=
false
)
{
function
txtDraw
(
ctx
,
content
,
top
,
fontsize
,
fontweight
,
color
)
{
x
=
x
*
2
;
top
=
top
*
2
;
y
=
y
*
2
;
fontsize
=
fontsize
*
2
;
fontsize
=
fontsize
*
2
;
ctx
.
font
=
fontweight
+
' '
+
fontsize
+
'px arial'
;
ctx
.
font
=
fontweight
+
' '
+
fontsize
+
'px arial'
;
if
(
stroke
)
{
var
width
=
ctx
.
measureText
(
content
).
width
;
//设置描边颜色
var
cx
=
x
-
width
/
2
;
ctx
.
strokeStyle
=
"#494949"
;
ctx
.
fillStyle
=
color
;
//设置描边宽度
ctx
.
fillText
(
content
,
cx
,
y
);
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
);
}
}
}
function
getManBase64
(
canvas
)
{
function
getManBase64
(
canvas
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment