Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
citic-fighting
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
550057c5
authored
Jun 27, 2024
by
dosZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
1aba5e20
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
Public/static/js/common.js
+9
-8
No files found.
Public/static/js/common.js
View file @
550057c5
...
@@ -327,8 +327,8 @@ function createPoster() {
...
@@ -327,8 +327,8 @@ function createPoster() {
setTimeout
(
function
()
{
setTimeout
(
function
()
{
posterCtx
.
drawImage
(
posterMask
,
0
,
0
,
640
*
2
,
1238
*
2
);
posterCtx
.
drawImage
(
posterMask
,
0
,
0
,
640
*
2
,
1238
*
2
);
drawVerticalText
(
posterCtx
,
username
,
'#595857'
,
32
*
2
,
95
*
2
,
345
*
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
);
drawVerticalText
(
posterCtx
,
company
,
'#595857'
,
32
*
2
,
95
*
2
,
505
*
2
,
true
,
5
*
2
);
$
(
'#notification_area'
).
remove
();
$
(
'#notification_area'
).
remove
();
$
(
'.upload-page'
).
hide
();
$
(
'.upload-page'
).
hide
();
...
@@ -341,7 +341,7 @@ function createPoster() {
...
@@ -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
();
// 保存当前状态
ctx
.
save
();
// 保存当前状态
// 设置字体样式,判断是否加粗
// 设置字体样式,判断是否加粗
...
@@ -350,21 +350,22 @@ function drawVerticalText(ctx, text, color, fontSize, x, y, isBold) {
...
@@ -350,21 +350,22 @@ function drawVerticalText(ctx, text, color, fontSize, x, y, isBold) {
ctx
.
fillStyle
=
color
;
// 设置字体颜色
ctx
.
fillStyle
=
color
;
// 设置字体颜色
ctx
.
textBaseline
=
'middle'
;
// 设置基准线为中间
ctx
.
textBaseline
=
'middle'
;
// 设置基准线为中间
ctx
.
textAlign
=
'center'
;
// 设置文本对齐为居中
ctx
.
textAlign
=
'center'
;
// 设置文本对齐为居中
ctx
.
lineWidth
=
10
;
// 设置描边宽度
ctx
.
lineWidth
=
2
;
// 设置描边宽度
ctx
.
strokeStyle
=
'white'
;
// 设置描边颜色
ctx
.
strokeStyle
=
'white'
;
// 设置描边颜色
// 计算每个字符的高度总和
// 计算每个字符的高度总和
,包含字间距
let
totalHeight
=
fontSize
*
text
.
length
;
let
totalHeight
=
(
fontSize
+
letterSpacing
)
*
text
.
length
-
letterSpacing
;
// 计算起始y坐标,以垂直居中
// 计算起始y坐标,以垂直居中
let
startY
=
y
-
totalHeight
/
2
+
fontSize
/
2
;
let
startY
=
y
-
totalHeight
/
2
+
fontSize
/
2
;
// 循环绘制每个字符
// 循环绘制每个字符
for
(
let
i
=
0
;
i
<
text
.
length
;
i
++
)
{
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
();
// 恢复之前的状态
ctx
.
restore
();
// 恢复之前的状态
...
...
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