soccer-jersey-fork 1.0.83 → 1.0.85

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.
@@ -267,6 +267,14 @@ export const addShortSideColor = (page, color) => {
267
267
  .stroke({ width: 2, color, linecap: "butt" });
268
268
  };
269
269
  export function addShoulderSideColor(page, color) {
270
+ // page
271
+ // .path(`m 2 35, l 16.5 -26, 19 -8`)
272
+ // .fill("none")
273
+ // .stroke({ width: 1, color, linecap: "butt" });
274
+ // page
275
+ // .path(`m 4 36, l 16.5 -25, 19 -8`)
276
+ // .fill("none")
277
+ // .stroke({ width: 1, color, linecap: "butt" });
270
278
  // left
271
279
  page
272
280
  .path(`m 0 35, l 16.5 -26, 19 -8`)
@@ -280,11 +288,11 @@ export function addShoulderSideColor(page, color) {
280
288
  }
281
289
  export function addShirtSideColor(page, color) {
282
290
  page
283
- .path(`m 25.5 45, l -0.5 50`)
291
+ .path(`m 25.5 45, c 1 10 1 40 0 50`)
284
292
  .fill("none")
285
293
  .stroke({ width: 2, color, linecap: "round" });
286
294
  page
287
- .path(`m 76 45, l 0.5 50`)
295
+ .path(`m 76.5 45, c -1 10 -1 40 0 50`)
288
296
  .fill("none")
289
297
  .stroke({ width: 2, color, linecap: "round" });
290
298
  }
@@ -37,7 +37,7 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor = s
37
37
  // eslint-disable-next-line new-cap
38
38
  const page = SVG();
39
39
  shirtStyleColor = shirtStyleColor || "#eee";
40
- let shirtFill = getPatternFill(page, shirtColor, shirtStyle, shirtStyleColor, shirtStyleDirection);
40
+ let shirtFill = getPatternFill(page, shirtColor, shirtStyle, shirtStyleColor, "shirt", shirtStyleDirection);
41
41
  // neck
42
42
  page
43
43
  .path(isBack ? pathNeckBack : pathNeck)
@@ -84,16 +84,19 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor = s
84
84
  const optimizedSleeveColor = lightenDarkenColor(sleeveColor, -10);
85
85
  sleeveStyleColor = sleeveStyleColor || "#eee";
86
86
  sleeveStyleDirection = sleeveStyleDirection || "vertical";
87
- const sleeveFill = getPatternFill(page, optimizedSleeveColor, sleeveStyle, sleeveStyleColor, sleeveStyleDirection);
87
+ const sleeveFill = getPatternFill(page, optimizedSleeveColor, sleeveStyle, sleeveStyleColor, "sleeve", sleeveStyleDirection);
88
88
  page.path(pathLeftSleeve).fill(sleeveFill);
89
89
  page.path(pathRightSleeve).fill(sleeveFill);
90
+ if (shoulderSideColor) {
91
+ addShoulderSideColor(page, shoulderSideColor);
92
+ }
90
93
  if (sleeveCuffColor) {
91
- const pathLeftSleeveCuff = "m2 36 l 17 9";
94
+ const pathLeftSleeveCuff = "m1.5 36 c 5 5 12.5 8 18.5 9";
92
95
  page
93
96
  .path(pathLeftSleeveCuff)
94
97
  .fill(sleeveCuffColor)
95
98
  .stroke({ color: sleeveCuffColor, width: 3, linecap: "round" });
96
- const pathRightSleeveCuff = "m100 36 l -18 9";
99
+ const pathRightSleeveCuff = "m100 36 c -5 5 -12.5 8 -18.5 9";
97
100
  page
98
101
  .path(pathRightSleeveCuff)
99
102
  .fill(sleeveCuffColor)
@@ -110,9 +113,6 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor = s
110
113
  .fill("none")
111
114
  .stroke({ color: shirtBottomColor, width: 3, linecap: "round" });
112
115
  }
113
- if (shoulderSideColor) {
114
- addShoulderSideColor(page, shoulderSideColor);
115
- }
116
116
  const shortsHeight = withShorts ? 40 : 0;
117
117
  if (withShorts) {
118
118
  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}`;
@@ -195,47 +195,33 @@ export default function drawSoccerJersey({ shirtColor = "plain", sleeveColor = s
195
195
  page.viewbox(`0 0 102 ${100 + (withShorts ? shortsHeight + 10 : 0)}`);
196
196
  return page.svg();
197
197
  }
198
- function getPatternFill(page, optimizedShirtColor, style, shirtStyleColor, shirtStyleDirection = "vertical") {
199
- let shirtFill;
198
+ function getPatternFill(page, baseColor, style, styleColor, type, styleDirection = "vertical") {
200
199
  switch (style) {
201
200
  case "twoColors":
202
- shirtFill = drawTwoColors(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection);
203
- break;
201
+ return drawTwoColors(page, baseColor, styleColor, styleDirection);
204
202
  case "stripedThin":
205
- shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection, "thin");
206
- break;
203
+ return drawStriped(page, baseColor, styleColor, styleDirection, "thin");
207
204
  case "stripedThick":
208
- shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection, "thick");
209
- break;
205
+ return drawStriped(page, baseColor, styleColor, styleDirection, "thick");
210
206
  case "striped":
211
- shirtFill = drawStriped(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection, "normal");
212
- break;
207
+ return drawStriped(page, baseColor, styleColor, styleDirection, "normal");
213
208
  case "dashed":
214
- shirtFill = drawDashes(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection);
215
- break;
216
- case "checkeredBig":
217
- shirtFill = drawCheckered(page, optimizedShirtColor, shirtStyleColor, "lg", shirtStyleDirection);
218
- break;
209
+ return drawDashes(page, baseColor, styleColor, styleDirection);
219
210
  case "checkered":
220
- shirtFill = drawCheckered(page, optimizedShirtColor, shirtStyleColor, "sm", shirtStyleDirection);
221
- break;
211
+ return drawCheckered(page, baseColor, styleColor, "sm", styleDirection);
212
+ case "checkeredBig":
213
+ return drawCheckered(page, baseColor, styleColor, "lg", styleDirection);
222
214
  case "diamonds":
223
- shirtFill = drawDiamonds(page, optimizedShirtColor, shirtStyleColor);
224
- break;
215
+ return drawDiamonds(page, baseColor, styleColor);
225
216
  case "singleBand":
226
- shirtFill = drawSingleBand(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection);
227
- break;
217
+ return drawSingleBand(page, baseColor, styleColor, styleDirection);
228
218
  case "singleBandThin":
229
- shirtFill = drawSingleBandThin(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection);
230
- break;
219
+ return drawSingleBandThin(page, baseColor, styleColor, styleDirection);
231
220
  case "waves":
232
- shirtFill = drawWaves(page, optimizedShirtColor, shirtStyleColor, shirtStyleDirection);
233
- break;
221
+ return drawWaves(page, baseColor, styleColor, styleDirection);
234
222
  case "cross":
235
- shirtFill = drawCrossLines(page, optimizedShirtColor, shirtStyleColor);
236
- break;
223
+ return drawCrossLines(page, baseColor, styleColor);
237
224
  default:
238
- shirtFill = optimizedShirtColor;
225
+ return baseColor;
239
226
  }
240
- return shirtFill;
241
227
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soccer-jersey-fork",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "description": "Generate soccer jerseys in SVG format",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {