soccer-jersey-fork 1.0.25 → 1.0.26
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.
|
@@ -16,8 +16,8 @@ export const Default = {
|
|
|
16
16
|
collarColor: "red",
|
|
17
17
|
sleeveCuffColor: "yellow",
|
|
18
18
|
shortColor: "black",
|
|
19
|
-
|
|
20
|
-
src:
|
|
19
|
+
customImageConfig: {
|
|
20
|
+
src: "https://resources.simcups.com/flags/w80/264.png",
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -12,13 +12,14 @@ export interface DrawSoccerJerseyProps {
|
|
|
12
12
|
shirtWidth?: number;
|
|
13
13
|
collarColor?: string;
|
|
14
14
|
sleeveCuffColor?: string;
|
|
15
|
-
|
|
15
|
+
customImageConfig?: {
|
|
16
16
|
src: string;
|
|
17
17
|
width?: number;
|
|
18
18
|
height?: number;
|
|
19
19
|
x?: number;
|
|
20
20
|
y?: number;
|
|
21
21
|
};
|
|
22
|
-
withDefaultBadge?: boolean;
|
|
23
22
|
shortColor: string;
|
|
23
|
+
withDefaultBadge?: boolean;
|
|
24
|
+
withShorts?: boolean;
|
|
24
25
|
}
|
|
@@ -27,4 +27,4 @@ import { DrawSoccerJerseyProps } from "../types";
|
|
|
27
27
|
* @return {string} A data URL ready for direct use as src attribute
|
|
28
28
|
* on <img />
|
|
29
29
|
*/
|
|
30
|
-
export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor, sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack, shirtWidth, collarColor, sleeveCuffColor,
|
|
30
|
+
export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor, sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack, shirtWidth, collarColor, sleeveCuffColor, customImageConfig, shortColor, withDefaultBadge, withShorts, }: DrawSoccerJerseyProps): string;
|
|
@@ -30,7 +30,7 @@ import { drawHoops, drawSingleBand, drawStriped, drawCheckered, drawTwoColor, dr
|
|
|
30
30
|
* @return {string} A data URL ready for direct use as src attribute
|
|
31
31
|
* on <img />
|
|
32
32
|
*/
|
|
33
|
-
export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor = "plain", sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack = false, shirtWidth = 200, collarColor, sleeveCuffColor,
|
|
33
|
+
export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor = "plain", sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack = false, shirtWidth = 200, collarColor, sleeveCuffColor, customImageConfig, shortColor, withDefaultBadge = true, withShorts = true, }) {
|
|
34
34
|
// Colors and Color Optimizations
|
|
35
35
|
const optimizedSleeveColor = lightenDarkenColor(sleeveColor, -10);
|
|
36
36
|
const optimizedShirtColor = lightenDarkenColor(shirtColor, -10);
|
|
@@ -90,17 +90,19 @@ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColo
|
|
|
90
90
|
})
|
|
91
91
|
.from(1, 1)
|
|
92
92
|
.to(1, 0));
|
|
93
|
-
if (collarColor) {
|
|
94
|
-
const pathCollar = "m35 0 q 17 20 30 0";
|
|
95
|
-
page.path(pathCollar).fill("none").stroke({ color: collarColor, width: 2 });
|
|
96
|
-
}
|
|
97
|
-
// badge
|
|
98
93
|
if (!isBack) {
|
|
99
|
-
if (
|
|
94
|
+
if (collarColor) {
|
|
95
|
+
const pathCollar = "m35 0 q 17 20 30 0";
|
|
96
|
+
page
|
|
97
|
+
.path(pathCollar)
|
|
98
|
+
.fill("none")
|
|
99
|
+
.stroke({ color: collarColor, width: 2 });
|
|
100
|
+
}
|
|
101
|
+
if (customImageConfig) {
|
|
100
102
|
page
|
|
101
|
-
.image(
|
|
102
|
-
.size(
|
|
103
|
-
.move(
|
|
103
|
+
.image(customImageConfig.src)
|
|
104
|
+
.size(customImageConfig.width || 20, customImageConfig.height || 20)
|
|
105
|
+
.move(customImageConfig.x || 40, customImageConfig.y || 45);
|
|
104
106
|
}
|
|
105
107
|
if (withDefaultBadge) {
|
|
106
108
|
page
|
|
@@ -168,9 +170,13 @@ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColo
|
|
|
168
170
|
.center(50, 35);
|
|
169
171
|
}
|
|
170
172
|
drawText(page);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
const shortsHeight = withShorts ? 40 : 0;
|
|
174
|
+
if (withShorts) {
|
|
175
|
+
page.width(shirtWidth);
|
|
176
|
+
const pathShorts = `m 23 98 c 5 6, 50 6, 56 0 l 2 ${shortsHeight} c 0 5, -27 5, -27.5 0 l -2 -10, -2 10, c 0 5, -27 5, -27.5 0 l 1 -${shortsHeight}`;
|
|
177
|
+
page.path(pathShorts).fill(shortColor);
|
|
178
|
+
}
|
|
179
|
+
// +10 is some extra room with the shorts height, so the total should be 150
|
|
180
|
+
page.viewbox(`0 0 102 ${100 + shortsHeight + 10}`);
|
|
175
181
|
return page.svg();
|
|
176
182
|
}
|