soccer-jersey-fork 1.0.64 → 1.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/draw-soccer-jersey.js +38 -35
- package/package.json +1 -1
|
@@ -98,11 +98,6 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor, sh
|
|
|
98
98
|
.fill("none")
|
|
99
99
|
.stroke({ color: collarColor, width: 2 });
|
|
100
100
|
}
|
|
101
|
-
if (images && images.length > 0) {
|
|
102
|
-
for (const { src, width = 20, height = 20, x = 45, y = 45 } of images) {
|
|
103
|
-
page.image(src).size(width, height).move(x, y);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
101
|
if (withBadge) {
|
|
107
102
|
page
|
|
108
103
|
.circle(8)
|
|
@@ -142,36 +137,6 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor, sh
|
|
|
142
137
|
.fill(sleeveCuffColor)
|
|
143
138
|
.stroke({ color: sleeveCuffColor, width: 3, linecap: "round" });
|
|
144
139
|
}
|
|
145
|
-
if (texts) {
|
|
146
|
-
for (const textItem of texts) {
|
|
147
|
-
const { text, color, size, outlineColor, backgroundColor, x, y } = textItem;
|
|
148
|
-
const drawText = (elem) => {
|
|
149
|
-
return elem
|
|
150
|
-
.text(text)
|
|
151
|
-
.fill(lightenDarkenColor(color ? color : "#fff", -50))
|
|
152
|
-
.font({
|
|
153
|
-
family: "Monospace",
|
|
154
|
-
size,
|
|
155
|
-
style: "bold",
|
|
156
|
-
})
|
|
157
|
-
.stroke({
|
|
158
|
-
color: outlineColor || color,
|
|
159
|
-
width: 0.5,
|
|
160
|
-
})
|
|
161
|
-
.center(x, y);
|
|
162
|
-
};
|
|
163
|
-
if (backgroundColor) {
|
|
164
|
-
// eslint-disable-next-line new-cap
|
|
165
|
-
const draftShirtTextElem = drawText(SVG());
|
|
166
|
-
const dimens = draftShirtTextElem.bbox();
|
|
167
|
-
page
|
|
168
|
-
.rect(dimens.width + 4, dimens.height + 4)
|
|
169
|
-
.fill(lightenDarkenColor(backgroundColor, 10))
|
|
170
|
-
.center(x, y);
|
|
171
|
-
}
|
|
172
|
-
drawText(page);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
140
|
if (shirtSideColor) {
|
|
176
141
|
addShirtSideColor(page, shirtSideColor);
|
|
177
142
|
}
|
|
@@ -228,6 +193,44 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor, sh
|
|
|
228
193
|
});
|
|
229
194
|
}
|
|
230
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Texts and images should be placed at last so they won't get covered by shirt and shorts
|
|
198
|
+
*/
|
|
199
|
+
if (texts && texts.length > 0) {
|
|
200
|
+
for (const textItem of texts) {
|
|
201
|
+
const { text, color, size, outlineColor, backgroundColor, x, y } = textItem;
|
|
202
|
+
const drawText = (elem) => {
|
|
203
|
+
return elem
|
|
204
|
+
.text(text)
|
|
205
|
+
.fill(lightenDarkenColor(color ? color : "#fff", -50))
|
|
206
|
+
.font({
|
|
207
|
+
family: "Monospace",
|
|
208
|
+
size,
|
|
209
|
+
style: "bold",
|
|
210
|
+
})
|
|
211
|
+
.stroke({
|
|
212
|
+
color: outlineColor || color,
|
|
213
|
+
width: 0.5,
|
|
214
|
+
})
|
|
215
|
+
.center(x, y);
|
|
216
|
+
};
|
|
217
|
+
if (backgroundColor) {
|
|
218
|
+
// eslint-disable-next-line new-cap
|
|
219
|
+
const draftShirtTextElem = drawText(SVG());
|
|
220
|
+
const dimens = draftShirtTextElem.bbox();
|
|
221
|
+
page
|
|
222
|
+
.rect(dimens.width + 4, dimens.height + 4)
|
|
223
|
+
.fill(lightenDarkenColor(backgroundColor, 10))
|
|
224
|
+
.center(x, y);
|
|
225
|
+
}
|
|
226
|
+
drawText(page);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (images && images.length > 0) {
|
|
230
|
+
for (const { src, width = 20, height = 20, x = 45, y = 45 } of images) {
|
|
231
|
+
page.image(src).size(width, height).move(x, y);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
231
234
|
page.width(shirtWidth);
|
|
232
235
|
// +10 is some extra room with the shorts height, so the total should be 150
|
|
233
236
|
page.viewbox(`0 0 102 ${100 + (withShorts ? shortsHeight + 10 : 0)}`);
|