Skip to content

Commit ef34e7a

Browse files
Update xo and lint code
1 parent bce64f1 commit ef34e7a

File tree

9 files changed

+1782
-1148
lines changed

9 files changed

+1782
-1148
lines changed

dist/textures.esm.js

Lines changed: 117 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
var rand = (function () {
1+
function random() {
22
return "".concat(Math.random().toString(36), "00000000000000000").replace(/[^a-z]+/g, '').slice(0, 5);
3-
});
3+
}
44

5-
var circles = (function () {
5+
function circles() {
66
var size = 20;
77
var background = '';
88
var radius = 2;
99
var complement = false;
1010
var fill = '#343434';
1111
var stroke = '#343434';
1212
var strokeWidth = 0;
13-
var id = rand();
13+
var id = random();
1414

1515
var $ = function $(selection) {
1616
var group = selection.append('defs').append('pattern').attr('id', id).attr('patternUnits', 'userSpaceOnUse').attr('width', size).attr('height', size);
@@ -22,49 +22,30 @@ var circles = (function () {
2222
group.append('circle').attr('cx', size / 2).attr('cy', size / 2).attr('r', radius).attr('fill', fill).attr('stroke', stroke).attr('stroke-width', strokeWidth);
2323

2424
if (complement) {
25-
[[0, 0], [0, size], [size, 0], [size, size]].forEach(function (corner) {
25+
for (var _i = 0, _arr = [[0, 0], [0, size], [size, 0], [size, size]]; _i < _arr.length; _i++) {
26+
var corner = _arr[_i];
2627
group.append('circle').attr('cx', corner[0]).attr('cy', corner[1]).attr('r', radius).attr('fill', fill).attr('stroke', stroke).attr('stroke-width', strokeWidth);
27-
});
28+
}
2829
}
2930
};
3031

3132
$.heavier = function (_) {
32-
if (arguments.length === 0) {
33-
radius *= 2;
34-
} else {
35-
radius *= 2 * _;
36-
}
37-
33+
radius *= arguments.length === 0 ? 2 : 2 * _;
3834
return $;
3935
};
4036

4137
$.lighter = function (_) {
42-
if (arguments.length === 0) {
43-
radius /= 2;
44-
} else {
45-
radius /= 2 * _;
46-
}
47-
38+
radius /= arguments.length === 0 ? 2 : 2 * _;
4839
return $;
4940
};
5041

5142
$.thinner = function (_) {
52-
if (arguments.length === 0) {
53-
size *= 2;
54-
} else {
55-
size *= 2 * _;
56-
}
57-
43+
size *= arguments.length === 0 ? 2 : 2 * _;
5844
return $;
5945
};
6046

6147
$.thicker = function (_) {
62-
if (arguments.length === 0) {
63-
size /= 2;
64-
} else {
65-
size /= 2 * _;
66-
}
67-
48+
size /= arguments.length === 0 ? 2 : 2 * _;
6849
return $;
6950
};
7051

@@ -79,12 +60,7 @@ var circles = (function () {
7960
};
8061

8162
$.complement = function (_) {
82-
if (arguments.length === 0) {
83-
complement = true;
84-
} else {
85-
complement = _;
86-
}
87-
63+
complement = arguments.length === 0 ? true : _;
8864
return $;
8965
};
9066

@@ -122,14 +98,88 @@ var circles = (function () {
12298
};
12399

124100
return $;
125-
});
101+
}
102+
103+
function _unsupportedIterableToArray(o, minLen) {
104+
if (!o) return;
105+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
106+
var n = Object.prototype.toString.call(o).slice(8, -1);
107+
if (n === "Object" && o.constructor) n = o.constructor.name;
108+
if (n === "Map" || n === "Set") return Array.from(o);
109+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
110+
}
111+
112+
function _arrayLikeToArray(arr, len) {
113+
if (len == null || len > arr.length) len = arr.length;
114+
115+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
116+
117+
return arr2;
118+
}
119+
120+
function _createForOfIteratorHelper(o, allowArrayLike) {
121+
var it;
122+
123+
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
124+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
125+
if (it) o = it;
126+
var i = 0;
127+
128+
var F = function () {};
129+
130+
return {
131+
s: F,
132+
n: function () {
133+
if (i >= o.length) return {
134+
done: true
135+
};
136+
return {
137+
done: false,
138+
value: o[i++]
139+
};
140+
},
141+
e: function (e) {
142+
throw e;
143+
},
144+
f: F
145+
};
146+
}
126147

127-
var lines = (function () {
148+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
149+
}
150+
151+
var normalCompletion = true,
152+
didErr = false,
153+
err;
154+
return {
155+
s: function () {
156+
it = o[Symbol.iterator]();
157+
},
158+
n: function () {
159+
var step = it.next();
160+
normalCompletion = step.done;
161+
return step;
162+
},
163+
e: function (e) {
164+
didErr = true;
165+
err = e;
166+
},
167+
f: function () {
168+
try {
169+
if (!normalCompletion && it.return != null) it.return();
170+
} finally {
171+
if (didErr) throw err;
172+
}
173+
}
174+
};
175+
}
176+
177+
function lines() {
128178
var size = 20;
129179
var stroke = '#343434';
130180
var strokeWidth = 2;
131181
var background = '';
132-
var id = rand();
182+
var id = random();
133183
var orientation = ['diagonal'];
134184
var shapeRendering = 'auto';
135185

@@ -142,7 +192,7 @@ var lines = (function () {
142192
return "M ".concat(s / 2, ", 0 l 0, ").concat(s);
143193

144194
case '1/8':
145-
return "M ".concat(s / 4, ",0 l ").concat(s / 2, ",").concat(s, " M ").concat(-s / 4, ",0 l ").concat(s / 2, ",").concat(s, " M ").concat(s * 3 / 4, ",0 l ").concat(s / 2, ",").concat(s);
195+
return "M ".concat(-s / 4, ",").concat(s, " l ").concat(s / 2, ",").concat(-s, " M ").concat(s / 4, ",").concat(s, " l ").concat(s / 2, ",").concat(-s, " M ").concat(s * 3 / 4, ",").concat(s, " l ").concat(s / 2, ",").concat(-s);
146196

147197
case '2/8':
148198
case 'diagonal':
@@ -176,48 +226,38 @@ var lines = (function () {
176226
group.append('rect').attr('width', size).attr('height', size).attr('fill', background);
177227
}
178228

179-
orientation.forEach(function (o) {
180-
group.append('path').attr('d', path(o)).attr('stroke-width', strokeWidth).attr('shape-rendering', shapeRendering).attr('stroke', stroke).attr('stroke-linecap', 'square');
181-
});
229+
var _iterator = _createForOfIteratorHelper(orientation),
230+
_step;
231+
232+
try {
233+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
234+
var o = _step.value;
235+
group.append('path').attr('d', path(o)).attr('stroke-width', strokeWidth).attr('shape-rendering', shapeRendering).attr('stroke', stroke).attr('stroke-linecap', 'square');
236+
}
237+
} catch (err) {
238+
_iterator.e(err);
239+
} finally {
240+
_iterator.f();
241+
}
182242
};
183243

184244
$.heavier = function (_) {
185-
if (arguments.length === 0) {
186-
strokeWidth *= 2;
187-
} else {
188-
strokeWidth *= 2 * _;
189-
}
190-
245+
strokeWidth *= arguments.length === 0 ? 2 : 2 * _;
191246
return $;
192247
};
193248

194249
$.lighter = function (_) {
195-
if (arguments.length === 0) {
196-
strokeWidth /= 2;
197-
} else {
198-
strokeWidth /= 2 * _;
199-
}
200-
250+
strokeWidth /= arguments.length === 0 ? 2 : 2 * _;
201251
return $;
202252
};
203253

204254
$.thinner = function (_) {
205-
if (arguments.length === 0) {
206-
size *= 2;
207-
} else {
208-
size *= 2 * _;
209-
}
210-
255+
size *= arguments.length === 0 ? 2 : 2 * _;
211256
return $;
212257
};
213258

214259
$.thicker = function (_) {
215-
if (arguments.length === 0) {
216-
size /= 2;
217-
} else {
218-
size /= 2 * _;
219-
}
220-
260+
size /= arguments.length === 0 ? 2 : 2 * _;
221261
return $;
222262
};
223263

@@ -273,9 +313,9 @@ var lines = (function () {
273313
};
274314

275315
return $;
276-
});
316+
}
277317

278-
var paths = (function () {
318+
function paths() {
279319
var width = 1;
280320
var height = 1;
281321
var size = 20;
@@ -287,7 +327,7 @@ var paths = (function () {
287327
return "M ".concat(s / 4, ",").concat(s * 3 / 4, "l").concat(s / 4, ",").concat(-s / 2, "l").concat(s / 4, ",").concat(s / 2);
288328
};
289329

290-
var id = rand();
330+
var id = random();
291331
var fill = 'transparent';
292332
var shapeRendering = 'auto';
293333

@@ -335,42 +375,22 @@ var paths = (function () {
335375
};
336376

337377
$.heavier = function (_) {
338-
if (arguments.length === 0) {
339-
strokeWidth *= 2;
340-
} else {
341-
strokeWidth *= 2 * _;
342-
}
343-
378+
strokeWidth *= arguments.length === 0 ? 2 : 2 * _;
344379
return $;
345380
};
346381

347382
$.lighter = function (_) {
348-
if (arguments.length === 0) {
349-
strokeWidth /= 2;
350-
} else {
351-
strokeWidth /= 2 * _;
352-
}
353-
383+
strokeWidth /= arguments.length === 0 ? 2 : 2 * _;
354384
return $;
355385
};
356386

357387
$.thinner = function (_) {
358-
if (arguments.length === 0) {
359-
size *= 2;
360-
} else {
361-
size *= 2 * _;
362-
}
363-
388+
size *= arguments.length === 0 ? 2 : 2 * _;
364389
return $;
365390
};
366391

367392
$.thicker = function (_) {
368-
if (arguments.length === 0) {
369-
size /= 2;
370-
} else {
371-
size /= 2 * _;
372-
}
373-
393+
size /= arguments.length === 0 ? 2 : 2 * _;
374394
return $;
375395
};
376396

@@ -423,7 +443,9 @@ var paths = (function () {
423443
};
424444

425445
return $;
426-
});
446+
}
447+
448+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
427449

428450
var main = {
429451
circles: circles,

0 commit comments

Comments
 (0)