soccer-jersey-fork 1.0.39 → 1.0.43
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Svg } from "@svgdotjs/svg.js";
|
|
2
2
|
import { ShirtStyleDirection } from "../types";
|
|
3
|
-
declare const drawStriped: (page: Svg, primaryColor: string, secondaryColor: string, thickness?: "thin" | "thick" | "normal") => import("@svgdotjs/svg.js").Pattern;
|
|
3
|
+
declare const drawStriped: (page: Svg, primaryColor: string, secondaryColor: string, direction: ShirtStyleDirection, thickness?: "thin" | "thick" | "normal") => import("@svgdotjs/svg.js").Pattern;
|
|
4
4
|
declare const drawCheckered: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
|
|
5
5
|
declare const drawHoops: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
|
|
6
6
|
declare const drawTwoColors: (page: Svg, primaryColor: string, secondaryColor: string, bandStyle: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
|
package/lib/patterns/patterns.js
CHANGED
|
@@ -1,22 +1,72 @@
|
|
|
1
|
-
const drawStripedThick = (page, primaryColor, secondaryColor) =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
const drawStripedThick = (page, primaryColor, secondaryColor, direction) => {
|
|
2
|
+
switch (direction) {
|
|
3
|
+
case "horizontal": {
|
|
4
|
+
// Define a pattern tile tall enough for both stripes
|
|
5
|
+
const stripeHeight = 10; // The thickness of your primary stripe
|
|
6
|
+
const gapHeight = 8; // The thickness of your secondary stripe
|
|
7
|
+
const patternHeight = stripeHeight + gapHeight; // The total height of the repeating pattern tile
|
|
8
|
+
return page.pattern(20, patternHeight, function (add) {
|
|
9
|
+
// Draw the thick primary stripe at the top of the tile
|
|
10
|
+
add.rect(20, stripeHeight).fill(primaryColor);
|
|
11
|
+
// Draw the thick secondary stripe below it.
|
|
12
|
+
// It starts at a y-position equal to the stripe's height.
|
|
13
|
+
add
|
|
14
|
+
.rect(20, gapHeight)
|
|
15
|
+
.move(0, stripeHeight)
|
|
16
|
+
.fill(secondaryColor ? secondaryColor : "#eee");
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
default: {
|
|
20
|
+
return page.pattern(20, 4, function (add) {
|
|
21
|
+
add.rect(20, 4).fill(primaryColor);
|
|
22
|
+
add
|
|
23
|
+
.rect(10, 4)
|
|
24
|
+
.move(6, 0)
|
|
25
|
+
.fill(secondaryColor ? secondaryColor : "#eee");
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const drawStripedThin = (page, primaryColor, secondaryColor, direction) => {
|
|
31
|
+
switch (direction) {
|
|
32
|
+
case "horizontal": {
|
|
33
|
+
return page.pattern(20, 5, function (add) {
|
|
34
|
+
add.rect(20, 8).fill(secondaryColor);
|
|
35
|
+
add.rect(20, 4).fill(primaryColor);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
default: {
|
|
39
|
+
return page.pattern(8, 4, function (add) {
|
|
40
|
+
add.rect(8, 4).fill(primaryColor);
|
|
41
|
+
add.rect(1, 4).fill(secondaryColor ? secondaryColor : "#eee");
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const drawStripedNormal = (page, primaryColor, secondaryColor, direction) => {
|
|
47
|
+
switch (direction) {
|
|
48
|
+
case "horizontal": {
|
|
49
|
+
return page.pattern(20, 8, function (add) {
|
|
50
|
+
add.rect(20, 8).fill(secondaryColor);
|
|
51
|
+
add.rect(20, 5).fill(primaryColor);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
default: {
|
|
16
55
|
return page.pattern(10, 4, function (add) {
|
|
17
56
|
add.rect(10, 4).fill(primaryColor);
|
|
18
57
|
add.rect(5, 4).fill(secondaryColor ? secondaryColor : "#eee");
|
|
19
58
|
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const drawStriped = (page, primaryColor, secondaryColor, direction, thickness = "normal") => {
|
|
63
|
+
switch (thickness) {
|
|
64
|
+
case "thick":
|
|
65
|
+
return drawStripedThick(page, primaryColor, secondaryColor, direction);
|
|
66
|
+
case "thin":
|
|
67
|
+
return drawStripedThin(page, primaryColor, secondaryColor, direction);
|
|
68
|
+
default:
|
|
69
|
+
return drawStripedNormal(page, primaryColor, secondaryColor, direction);
|
|
20
70
|
}
|
|
21
71
|
};
|
|
22
72
|
const drawCheckered = (page, primaryColor, secondaryColor) => page.pattern(20, 20, function (add) {
|
|
@@ -53,13 +53,13 @@ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColo
|
|
|
53
53
|
shirtFill = drawTwoColors(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection ? shirtStyleDirection : "vertical");
|
|
54
54
|
break;
|
|
55
55
|
case "stripedThin":
|
|
56
|
-
shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", "thin");
|
|
56
|
+
shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection || "vertical", "thin");
|
|
57
57
|
break;
|
|
58
58
|
case "stripedThick":
|
|
59
|
-
shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", "thick");
|
|
59
|
+
shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection || "vertical", "thick");
|
|
60
60
|
break;
|
|
61
61
|
case "striped":
|
|
62
|
-
shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222");
|
|
62
|
+
shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection || "vertical", "normal");
|
|
63
63
|
break;
|
|
64
64
|
case "dashed":
|
|
65
65
|
shirtFill = drawDashes(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection ? shirtStyleDirection : "vertical");
|