1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| function _shadowClone(e) { var t = {}; for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]); return t; }
(function() { function ranOrNot(e, t) { var n = []; typeof t == "undefined" && (t = e, e = 0); for (; e < t; e++) n.push(e); return n } Array.prototype.randomEach = function(t) { console.log(3); if (typeof t != "function") throw new TypeError; var n = this.length, r = ranOrNot(n); while (n) { var i = Math.floor(Math.random() * n--); if (t(this[r[i]]) === !1) break; r[i] = r[n] } }, Array.prototype.forEach || (Array.prototype.forEach = function(e) { var t = this.length; if (typeof e != "function") throw new TypeError; var n = arguments[1]; for (var r = 0; r < t; r++) r in this && e.call(n, this[r], r, this) }) } )();
function _cutGrid(tag, funcJudge) { function a(a) { function h(cutLength) { var u, a = _shadowClone(cutLength); c++, u = c === l ? tag[cutType2.measure] - s: Math.floor(cutLength[cutType2.measure] * tag[cutType2.measure] / 100), a[cutType1.offset] = i + tag[cutType1.offset], a[cutType2.offset] = s + tag[cutType2.offset], a[cutType1.measure] = f, a[cutType2.measure] = u, a.colorPattern = tag.colorPattern, funcJudge(a), s += u } var f, l = a[cutType2.name].length, c = 0; u++, f = u === cutLength ? tag[cutType1.measure] - i: Math.floor(a[cutType1.measure] * tag[cutType1.measure] / 100), a.random === !1 ? a[cutType2.name].forEach(h) : a[cutType2.name].randomEach(h), s = 0, i += f } var cutType1, cutType2; tag.rows ? (cutType1 = { name: "rows", measure: "height", offset: "top" }, cutType2 = { name: "cols", measure: "width", offset: "left" }) : (cutType1 = { name: "cols", measure: "width", offset: "left" }, cutType2 = { name: "rows", measure: "height", offset: "top" }); var i = 0, s = 0, cutLength = tag[cutType1.name].length, u = 0; tag.random === !1 ? tag[cutType1.name].forEach(a) : tag[cutType1.name].randomEach(a) }
|