Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-deckform-filler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-deckform-filler
Commits
edf07860
Commit
edf07860
authored
Oct 24, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tune
parent
696ceae9
Pipeline
#41250
passed with stages
in 2 minutes and 26 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
24 deletions
+34
-24
src/app.service.ts
src/app.service.ts
+9
-13
src/draw-text/draw-text.service.ts
src/draw-text/draw-text.service.ts
+25
-11
No files found.
src/app.service.ts
View file @
edf07860
...
...
@@ -34,11 +34,7 @@ export class AppService extends ConsoleLogger {
const
directDrawFields
=
[
'
name
'
,
'
event
'
,
'
lastInitial
'
]
as
const
;
for
(
const
field
of
directDrawFields
)
{
if
(
!
dto
[
field
])
continue
;
await
this
.
drawTextService
.
drawTextInBox
(
doc
,
dto
[
field
],
Coordinates
[
field
],
);
this
.
drawTextService
.
drawTextInBox
(
doc
,
dto
[
field
],
Coordinates
[
field
]);
}
this
.
log
(
`Filled direct draw fields.`
);
if
(
dto
.
date
)
{
...
...
@@ -59,7 +55,7 @@ export class AppService extends ConsoleLogger {
dateChars
[
7
],
];
for
(
let
i
=
0
;
i
<
datePrintStr
.
length
;
i
++
)
{
await
this
.
drawTextService
.
drawTextInBox
(
this
.
drawTextService
.
drawTextInBox
(
doc
,
datePrintStr
[
i
],
moveRight
(
Coordinates
.
dateFirst
,
i
),
...
...
@@ -72,7 +68,7 @@ export class AppService extends ConsoleLogger {
const
totalCounts
=
[
ydk
.
main
.
length
,
ydk
.
extra
.
length
,
ydk
.
side
.
length
];
for
(
let
i
=
0
;
i
<
3
;
++
i
)
{
await
this
.
drawTextService
.
drawTextInBox
(
this
.
drawTextService
.
drawTextInBox
(
doc
,
totalCounts
[
i
].
toString
(),
moveRight
(
Coordinates
.
totalFirst
,
i
),
...
...
@@ -84,7 +80,7 @@ export class AppService extends ConsoleLogger {
const
copyFirstPageToBottom
=
async
()
=>
{
const
[
newPage
]
=
await
doc
.
copyPages
(
doc
,
[
0
]);
doc
.
addPage
(
newPage
);
this
.
drawTextService
.
duplicateOperations
(
doc
,
0
,
doc
.
getPageCount
()
-
1
);
//
this.drawTextService.duplicateOperations(doc, 0, doc.getPageCount() - 1);
};
const
cards
=
[...
new
Set
([...
ydk
.
main
,
...
ydk
.
extra
,
...
ydk
.
side
])];
...
...
@@ -142,7 +138,7 @@ export class AppService extends ConsoleLogger {
spaces
=
20
,
)
=>
{
const
groupedCards
=
Object
.
values
(
_
.
groupBy
(
cards
,
(
id
)
=>
id
));
const
drawCardsOnPage
=
async
(
const
drawCardsOnPage
=
(
currentPageCards
:
number
[][],
pageIndex
:
number
,
)
=>
{
...
...
@@ -160,20 +156,20 @@ export class AppService extends ConsoleLogger {
).
toException
();
}
await
this
.
drawTextService
.
drawTextInBox
(
this
.
drawTextService
.
drawTextInBox
(
doc
,
qty
.
toString
(),
moveDown
(
cord
.
qty
,
j
),
pageIndex
,
);
await
this
.
drawTextService
.
drawTextInBox
(
this
.
drawTextService
.
drawTextInBox
(
doc
,
cardData
[
`
${
dto
.
lang
||
'
sc
'
}
_name`
],
moveDown
(
cord
.
name
,
j
),
pageIndex
,
);
}
await
this
.
drawTextService
.
drawTextInBox
(
this
.
drawTextService
.
drawTextInBox
(
doc
,
_
.
sumBy
(
currentPageCards
,
(
s
)
=>
s
.
length
).
toString
(),
moveDown
(
cord
.
qty
,
spaces
),
...
...
@@ -183,7 +179,7 @@ export class AppService extends ConsoleLogger {
const
usePages
=
_
.
chunk
(
groupedCards
,
spaces
);
await
ensurePages
(
usePages
.
length
-
1
);
for
(
let
i
=
0
;
i
<
usePages
.
length
;
++
i
)
{
await
drawCardsOnPage
(
usePages
[
i
],
i
);
drawCardsOnPage
(
usePages
[
i
],
i
);
}
};
await
drawCards
(
filterType
(
1
),
Coordinates
.
main
.
monsters
);
...
...
src/draw-text/draw-text.service.ts
View file @
edf07860
...
...
@@ -42,12 +42,12 @@ export class DrawTextService {
/**
* 在指定矩形内绘制文本(改为仅记录步骤;仍保持 async 签名以兼容调用端)
*/
async
drawTextInBox
(
drawTextInBox
(
doc
:
PDFDocument
,
text
:
string
,
options
:
DrawTextOptions
,
pageCount
=
0
,
)
:
Promise
<
void
>
{
pageCount
=
-
1
,
)
{
if
(
!
text
)
return
;
const
ops
=
this
.
ensureOps
(
doc
);
ops
.
push
({
...
...
@@ -88,14 +88,26 @@ export class DrawTextService {
// 4) 回放并实际绘制
for
(
const
op
of
ops
)
{
if
(
op
.
kind
===
'
drawTextInBox
'
)
{
await
this
.
drawTextInBoxWithFont
(
doc
,
subsetFont
,
op
.
text
,
op
.
options
,
op
.
pageIndex
,
);
const
runOp
=
async
(
pc
:
number
)
=>
{
if
(
op
.
kind
===
'
drawTextInBox
'
)
{
await
this
.
drawTextInBoxWithFont
(
doc
,
subsetFont
,
op
.
text
,
op
.
options
,
pc
,
);
}
};
if
(
op
.
pageIndex
===
-
1
)
{
// 应用到所有页面
const
pageCount
=
doc
.
getPageCount
();
for
(
let
i
=
0
;
i
<
pageCount
;
++
i
)
{
await
runOp
(
i
);
}
}
else
{
// 仅应用到指定页面
await
runOp
(
op
.
pageIndex
);
}
}
...
...
@@ -192,6 +204,7 @@ export class DrawTextService {
});
}
/*
duplicateOperations(doc: PDFDocument, fromPage: number, toPage: number) {
const ops = this.operations.get(doc);
if (!ops) return;
...
...
@@ -207,4 +220,5 @@ export class DrawTextService {
}
ops.push(...newOps);
}
*/
}
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