soccer-jersey-fork 1.0.53 → 1.0.55

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.
@@ -9,12 +9,12 @@ export declare const drawStripedThick: (page: Svg, primaryColor: string, seconda
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
11
  export declare const drawStriped: (page: Svg, primaryColor: string, secondaryColor: string, direction: ShirtStyleDirection, thickness?: "thin" | "thick" | "normal") => import("@svgdotjs/svg.js").Pattern;
12
- export declare const drawShirtSideStriped: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
13
12
  export declare const drawCheckered: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
14
- export declare const drawHoops: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
15
13
  export declare const drawTwoColors: (page: Svg, primaryColor: string, secondaryColor: string, bandStyle: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
16
14
  export declare const drawSingleBand: (page: Svg, primaryColor: string, secondaryColor: string, bandStyle: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
15
+ export declare const drawSingleBandThin: (page: Svg, primaryColor: string, secondaryColor: string, bandStyle: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
17
16
  export declare const drawWaves: (page: Svg, primaryColor: string, secondaryColor: string, waveStyle: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
18
17
  export declare const drawDashes: (page: Svg, primaryColor: string, secondaryColor: string, dashDirection: ShirtStyleDirection) => import("@svgdotjs/svg.js").Pattern;
19
- export declare const drawShortsSideStriped: (page: Svg, primaryColor: string, secondaryColor: string) => import("@svgdotjs/svg.js").Pattern;
20
- export declare function addShoulderStriped(page: Svg, color: string): void;
18
+ export declare const addShortSideColor: (page: Svg, color: string) => void;
19
+ export declare function addShoulderSideColor(page: Svg, color: string): void;
20
+ export declare function addShirtSideColor(page: Svg, color: string): void;
@@ -69,13 +69,6 @@ export const drawStriped = (page, primaryColor, secondaryColor, direction, thick
69
69
  return drawStripedNormal(page, primaryColor, secondaryColor, direction);
70
70
  }
71
71
  };
72
- export const drawShirtSideStriped = (page, primaryColor, secondaryColor) => {
73
- return page.pattern(51.3, 100, function (add) {
74
- add.rect(51.3, 100).fill(primaryColor);
75
- // The move 24.2 is the space between the lines
76
- add.rect(2, 55).fill(secondaryColor).move(24, 42);
77
- });
78
- };
79
72
  export const drawCheckered = (page, primaryColor, secondaryColor) => page.pattern(20, 20, function (add) {
80
73
  add.rect(20, 20).fill(primaryColor);
81
74
  add.rect(10, 10).fill(secondaryColor ? secondaryColor : "#eee");
@@ -84,10 +77,6 @@ export const drawCheckered = (page, primaryColor, secondaryColor) => page.patter
84
77
  .fill(secondaryColor ? secondaryColor : "#eee")
85
78
  .move(10, 10);
86
79
  });
87
- export const drawHoops = (page, primaryColor, secondaryColor) => page.pattern(20, 20, function (add) {
88
- add.rect(20, 20).fill(primaryColor);
89
- add.rect(20, 10).fill(secondaryColor ? secondaryColor : "#eee");
90
- });
91
80
  export const drawTwoColors = (page, primaryColor, secondaryColor, bandStyle) => {
92
81
  switch (bandStyle) {
93
82
  case "diagonalRight":
@@ -174,6 +163,31 @@ export const drawSingleBand = (page, primaryColor, secondaryColor, bandStyle) =>
174
163
  });
175
164
  }
176
165
  };
166
+ export const drawSingleBandThin = (page, primaryColor, secondaryColor, bandStyle) => {
167
+ const drawVertical = (x) => {
168
+ return page.pattern(90, 100, function (add) {
169
+ add.rect(90, 100).fill(primaryColor);
170
+ add
171
+ .rect(5, 100)
172
+ .fill(secondaryColor ? secondaryColor : "#eee")
173
+ .move(x, 0);
174
+ });
175
+ };
176
+ switch (bandStyle) {
177
+ case "horizontal":
178
+ return page.pattern(100, 90, function (add) {
179
+ add.rect(100, 90).fill(primaryColor);
180
+ add
181
+ .rect(100, 5)
182
+ .fill(secondaryColor ? secondaryColor : "#eee")
183
+ .move(0, 35);
184
+ });
185
+ case "vertical":
186
+ return drawVertical(50);
187
+ default:
188
+ return drawVertical(60);
189
+ }
190
+ };
177
191
  export const drawWaves = (page, primaryColor, secondaryColor, waveStyle) => {
178
192
  switch (waveStyle) {
179
193
  case "horizontal":
@@ -246,16 +260,19 @@ export const drawDashes = (page, primaryColor, secondaryColor, dashDirection) =>
246
260
  });
247
261
  }
248
262
  };
249
- export const drawShortsSideStriped = (page, primaryColor, secondaryColor) => {
250
- return page.pattern(53, 50, function (add) {
251
- add.rect(53, 50).fill(primaryColor);
252
- // The move 24.2 is the space between the lines
253
- add.rect(1, 40).radius(1, 1).fill(secondaryColor).move(24.5, 0);
254
- });
263
+ export const addShortSideColor = (page, color) => {
264
+ page
265
+ .path(`m 25 100, l -1 40`)
266
+ .fill("none")
267
+ .stroke({ width: 2, color, linecap: "butt" });
268
+ page
269
+ .path(`m 77 100 l 2 40`)
270
+ .fill("none")
271
+ .stroke({ width: 2, color, linecap: "butt" });
255
272
  };
256
- export function addShoulderStriped(page, color) {
273
+ export function addShoulderSideColor(page, color) {
257
274
  page
258
- .path(`m 0 34, l 16.5 -26, 18 -8`)
275
+ .path(`m 0 35, l 16.5 -26, 18 -8`)
259
276
  .fill("none")
260
277
  .stroke({ width: 2, color, linecap: "butt" });
261
278
  page
@@ -263,3 +280,13 @@ export function addShoulderStriped(page, color) {
263
280
  .fill("none")
264
281
  .stroke({ width: 2, color, linecap: "butt" });
265
282
  }
283
+ export function addShirtSideColor(page, color) {
284
+ page
285
+ .path(`m 25.5 45, l -0.5 50`)
286
+ .fill("none")
287
+ .stroke({ width: 2, color, linecap: "round" });
288
+ page
289
+ .path(`m 76 45, l 0.5 50`)
290
+ .fill("none")
291
+ .stroke({ width: 2, color, linecap: "round" });
292
+ }
@@ -11,7 +11,8 @@ export const Default = {
11
11
  args: {
12
12
  shirtText: "SJ JS",
13
13
  shirtColor: "#008800",
14
- shirtStyle: "sideStriped",
14
+ shirtStyle: "singleBandThin",
15
+ shirtStyleDirection: "vertical",
15
16
  shirtStyleColor: "red",
16
17
  sleeveColor: "#008800",
17
18
  textColor: "#fff",
@@ -26,18 +27,18 @@ export const Default = {
26
27
  x: 45,
27
28
  y: 45,
28
29
  },
29
- {
30
- src: "https://resources.simcups.com/flags/w80/264.png",
31
- width: 20,
32
- height: 20,
33
- x: 60,
34
- y: 60,
35
- },
30
+ // {
31
+ // src: "https://resources.simcups.com/flags/w80/264.png",
32
+ // width: 20,
33
+ // height: 20,
34
+ // x: 60,
35
+ // y: 60,
36
+ // },
36
37
  ],
37
38
  shortsStyle: "sideStriped",
38
39
  shortsCuffColor: "#6e6dd2",
39
- shoulderStyle: "striped",
40
- shoulderStyleColor: "red",
40
+ shoulderSideColor: "red",
41
+ shortsSideColor: "red",
41
42
  },
42
43
  };
43
44
  export const ARS = {
@@ -10,6 +10,7 @@ export interface DrawSoccerJerseyProps {
10
10
  textBackgroundColor?: string;
11
11
  shirtColor: string;
12
12
  sleeveColor: string;
13
+ shirtSideColor?: string;
13
14
  shirtStyle: ShirtStyle;
14
15
  shirtStyleColor?: string;
15
16
  shirtStyleDirection?: ShirtStyleDirection;
@@ -25,15 +26,13 @@ export interface DrawSoccerJerseyProps {
25
26
  height: number;
26
27
  }[];
27
28
  shortsColor: string;
28
- shortsStyle: ShortsStyle;
29
- shortsStyleColor?: string;
29
+ shortsSideColor?: string;
30
30
  shortsCuffColor?: string;
31
- shoulderStyle: ShoulderStyle;
32
- shoulderStyleColor?: string;
31
+ shoulderSideColor?: string;
33
32
  withBadge?: boolean;
34
33
  withShorts?: boolean;
35
34
  }
36
35
  export type ShirtStyleDirection = "diagonalRight" | "diagonalLeft" | "horizontal" | "vertical";
37
- export type ShirtStyle = "plain" | "twoColors" | "striped" | "stripedThin" | "stripedThick" | "sideStriped" | "waves" | "checkered" | "hoops" | "singleBand" | "dashed";
36
+ export type ShirtStyle = "plain" | "twoColors" | "striped" | "stripedThin" | "stripedThick" | "waves" | "checkered" | "singleBandThin" | "singleBand" | "dashed";
38
37
  export type ShoulderStyle = "plain" | "striped";
39
38
  export type ShortsStyle = "plain" | "sideStriped";
@@ -26,4 +26,4 @@ import { DrawSoccerJerseyProps } from "../types";
26
26
  * @return {string} A data URL ready for direct use as src attribute
27
27
  * on <img />
28
28
  */
29
- export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor, sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack, shirtWidth, collarColor, shoulderStyleColor, shoulderStyle, sleeveCuffColor, shortsColor, shortsCuffColor, shortsStyle, shortsStyleColor, images, withBadge, withShorts, }: DrawSoccerJerseyProps): string;
29
+ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor, sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack, shirtWidth, collarColor, shoulderSideColor, shirtSideColor, sleeveCuffColor, shortsColor, shortsCuffColor, shortsSideColor, images, withBadge, withShorts, }: DrawSoccerJerseyProps): string;
@@ -7,7 +7,7 @@
7
7
  /* eslint-disable max-len */
8
8
  import { SVG } from "@svgdotjs/svg.js";
9
9
  import lightenDarkenColor from "./lighten-darken-color";
10
- import { drawHoops, drawSingleBand, drawStriped, drawCheckered, drawTwoColors, drawWaves, drawDashes, drawShortsSideStriped, drawShirtSideStriped, addShoulderStriped, } from "../patterns/patterns";
10
+ import { drawSingleBand, drawStriped, drawCheckered, drawTwoColors, drawWaves, drawDashes, addShoulderSideColor, addShortSideColor, addShirtSideColor, drawSingleBandThin, } from "../patterns/patterns";
11
11
  /**
12
12
  * @param {object} specs Specifications of the soccer jersey.
13
13
  * @param {string} specs.shirtText The text to be displayed on the shirt.
@@ -35,7 +35,7 @@ import { drawHoops, drawSingleBand, drawStriped, drawCheckered, drawTwoColors, d
35
35
  * @return {string} A data URL ready for direct use as src attribute
36
36
  * on <img />
37
37
  */
38
- export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor = "plain", sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack = false, shirtWidth = 200, collarColor, shoulderStyleColor, shoulderStyle, sleeveCuffColor, shortsColor, shortsCuffColor, shortsStyle, shortsStyleColor, images, withBadge, withShorts = true, }) {
38
+ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColor, textBackgroundColor, shirtColor = "plain", sleeveColor, shirtStyle, shirtStyleColor, shirtStyleDirection, isBack = false, shirtWidth = 200, collarColor, shoulderSideColor, shirtSideColor, sleeveCuffColor, shortsColor, shortsCuffColor, shortsSideColor, images, withBadge, withShorts = true, }) {
39
39
  // Colors and Color Optimizations
40
40
  const optimizedSleeveColor = lightenDarkenColor(sleeveColor, -10);
41
41
  const optimizedShirtColor = lightenDarkenColor(shirtColor, -10);
@@ -61,9 +61,6 @@ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColo
61
61
  case "striped":
62
62
  shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection || "vertical", "normal");
63
63
  break;
64
- case "sideStriped":
65
- shirtFill = drawShirtSideStriped(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222");
66
- break;
67
64
  case "dashed":
68
65
  shirtFill = drawDashes(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection ? shirtStyleDirection : "vertical");
69
66
  break;
@@ -73,9 +70,16 @@ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColo
73
70
  case "singleBand":
74
71
  shirtFill = drawSingleBand(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection ? shirtStyleDirection : "horizontal");
75
72
  break;
76
- case "hoops":
77
- shirtFill = drawHoops(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222");
73
+ case "singleBandThin":
74
+ shirtFill = drawSingleBandThin(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection ? shirtStyleDirection : "horizontal");
78
75
  break;
76
+ // case "hoops":
77
+ // shirtFill = drawHoops(
78
+ // page,
79
+ // optimizedShirtColor,
80
+ // shirtStyleColor ? shirtStyleColor : "#222",
81
+ // );
82
+ // break;
79
83
  case "waves":
80
84
  shirtFill = drawWaves(page, optimizedShirtColor, shirtStyleColor ? shirtStyleColor : "#222", shirtStyleDirection == "vertical" || shirtStyleDirection == "horizontal"
81
85
  ? shirtStyleDirection
@@ -179,27 +183,16 @@ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColo
179
183
  }
180
184
  drawText(page);
181
185
  }
182
- if (shoulderStyle) {
183
- switch (shoulderStyle) {
184
- case "striped": {
185
- addShoulderStriped(page, shoulderStyleColor || "red");
186
- }
187
- }
186
+ if (shirtSideColor) {
187
+ addShirtSideColor(page, shirtSideColor);
188
+ }
189
+ if (shoulderSideColor) {
190
+ addShoulderSideColor(page, shoulderSideColor);
188
191
  }
189
192
  const shortsHeight = withShorts ? 40 : 0;
190
193
  if (withShorts) {
191
194
  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}`;
192
- let shortsFill;
193
- switch (shortsStyle) {
194
- case "sideStriped": {
195
- shortsFill = drawShortsSideStriped(page, shortsColor, shortsStyleColor || "red");
196
- break;
197
- }
198
- default: {
199
- shortsFill = shortsColor;
200
- }
201
- }
202
- page.path(pathShorts).fill(shortsFill);
195
+ page.path(pathShorts).fill(shortsColor);
203
196
  page.path(pathShorts).fill(page
204
197
  .gradient("linear", function (add) {
205
198
  add.stop(0, "#000", 0.2);
@@ -208,6 +201,9 @@ export default function drawSoccerJersey({ shirtText, textColor, textOutlineColo
208
201
  })
209
202
  .from(1, 1)
210
203
  .to(1, 0));
204
+ if (shortsSideColor) {
205
+ addShortSideColor(page, shortsSideColor);
206
+ }
211
207
  if (shortsCuffColor) {
212
208
  const pathShortsCuffLeft = `m 23 138 c 5 5, 22 5, 26.5 0`;
213
209
  const pathShortsCuffRight = `m 54 138 c 5 5, 22 5, 26.5 0`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soccer-jersey-fork",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "description": "Generate soccer jerseys in SVG format",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {