soccer-jersey-fork 1.0.64 → 1.0.66
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.
|
@@ -8,7 +8,7 @@ import { ShirtStyleDirection } from "../types";
|
|
|
8
8
|
export declare const drawStripedThick: (page: Svg, primaryColor: string, secondaryColor: string, direction: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
|
|
9
9
|
export declare const drawStripedThin: (page: Svg, primaryColor: string, secondaryColor: string, direction: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
|
|
10
10
|
export declare const drawStripedNormal: (page: Svg, primaryColor: string, secondaryColor: string, direction: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
|
|
11
|
-
export declare const drawCheckered: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
|
|
11
|
+
export declare const drawCheckered: (page: Svg, primaryColor: string, secondaryColor: string, direction?: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
|
|
12
12
|
export declare const drawDiamonds: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
|
|
13
13
|
export declare const drawTwoColors: (page: Svg, primaryColor: string, secondaryColor: string, bandStyle: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
|
|
14
14
|
export declare const drawSingleBand: (page: Svg, primaryColor: string, secondaryColor: string, bandStyle: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
|
package/lib/patterns/patterns.js
CHANGED
|
@@ -89,15 +89,25 @@ export const drawStripedNormal = (page, primaryColor, secondaryColor, direction)
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
export const drawCheckered = (page, primaryColor, secondaryColor) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
export const drawCheckered = (page, primaryColor, secondaryColor, direction) => {
|
|
93
|
+
const draw = () => {
|
|
94
|
+
return page.pattern(20, 20, function (add) {
|
|
95
|
+
add.rect(20, 20).fill(primaryColor);
|
|
96
|
+
add.rect(10, 10).fill(secondaryColor ? secondaryColor : "#eee");
|
|
97
|
+
add
|
|
98
|
+
.rect(10, 10)
|
|
99
|
+
.fill(secondaryColor ? secondaryColor : "#eee")
|
|
100
|
+
.move(10, 10);
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
switch (direction) {
|
|
104
|
+
case "diagonalLeft": {
|
|
105
|
+
return draw().rotate(45);
|
|
106
|
+
}
|
|
107
|
+
default: {
|
|
108
|
+
return draw();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
101
111
|
};
|
|
102
112
|
export const drawDiamonds = (page, primaryColor, secondaryColor) => page.pattern(5, 5, function (add) {
|
|
103
113
|
add.rect(5, 5).fill(primaryColor);
|
|
@@ -57,7 +57,7 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor, sh
|
|
|
57
57
|
shirtFill = drawDashes(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection ? shirtStyleDirection : "vertical");
|
|
58
58
|
break;
|
|
59
59
|
case "checkered":
|
|
60
|
-
shirtFill = drawCheckered(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222");
|
|
60
|
+
shirtFill = drawCheckered(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection);
|
|
61
61
|
break;
|
|
62
62
|
case "diamonds":
|
|
63
63
|
shirtFill = drawDiamonds(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222");
|
|
@@ -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)}`);
|