MCPcopy
hub / github.com/tdewolff/minify / getPatternSize

Function getPatternSize

_benchmarks/sample_echarts.js:27248–27294  ·  view source on GitHub ↗

* Get minumum length that can make a repeatable pattern. * * @return {Object} pattern width and height

()

Source from the content-addressed store, hash-verified

27246 */
27247
27248 function getPatternSize() {
27249 /**
27250 * For example, if dash is [[3, 2], [2, 1]] for X, it looks like
27251 * |--- --- --- --- --- ...
27252 * |-- -- -- -- -- -- -- -- ...
27253 * |--- --- --- --- --- ...
27254 * |-- -- -- -- -- -- -- -- ...
27255 * So the minumum length of X is 15,
27256 * which is the least common multiple of `3 + 2` and `2 + 1`
27257 * |--- --- --- |--- --- ...
27258 * |-- -- -- -- -- |-- -- -- ...
27259 */
27260 var width = 1;
27261
27262 for (var i = 0, xlen = lineBlockLengthsX.length; i < xlen; ++i) {
27263 width = getLeastCommonMultiple(width, lineBlockLengthsX[i]);
27264 }
27265
27266 var symbolRepeats = 1;
27267
27268 for (var i = 0, xlen = symbolArray.length; i < xlen; ++i) {
27269 symbolRepeats = getLeastCommonMultiple(symbolRepeats, symbolArray[i].length);
27270 }
27271
27272 width *= symbolRepeats;
27273 var height = lineBlockLengthY * lineBlockLengthsX.length * symbolArray.length;
27274
27275 if ("development" !== 'production') {
27276 var warn = function (attrName) {
27277 /* eslint-disable-next-line */
27278 console.warn("Calculated decal size is greater than " + attrName + " due to decal option settings so " + attrName + " is used for the decal size. Please consider changing the decal option to make a smaller decal or set " + attrName + " to be larger to avoid incontinuity.");
27279 };
27280
27281 if (width > decalOpt.maxTileWidth) {
27282 warn('maxTileWidth');
27283 }
27284
27285 if (height > decalOpt.maxTileHeight) {
27286 warn('maxTileHeight');
27287 }
27288 }
27289
27290 return {
27291 width: Math.max(1, Math.min(width, decalOpt.maxTileWidth)),
27292 height: Math.max(1, Math.min(height, decalOpt.maxTileHeight))
27293 };
27294 }
27295
27296 function brushDecal() {
27297 if (ctx) {

Callers 1

setPatternnSourceFunction · 0.85

Calls 2

getLeastCommonMultipleFunction · 0.85
warnFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…