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

Function setPatternnSource

_benchmarks/sample_echarts.js:27189–27389  ·  view source on GitHub ↗
(pattern)

Source from the content-addressed store, hash-verified

27187 return pattern;
27188
27189 function setPatternnSource(pattern) {
27190 var keys = [dpr];
27191 var isValidKey = true;
27192
27193 for (var i = 0; i < decalKeys.length; ++i) {
27194 var value = decalOpt[decalKeys[i]];
27195 var valueType = typeof value;
27196
27197 if (value != null && !isArray(value) && valueType !== 'string' && valueType !== 'number' && valueType !== 'boolean') {
27198 isValidKey = false;
27199 break;
27200 }
27201
27202 keys.push(value);
27203 }
27204
27205 var cacheKey;
27206
27207 if (isValidKey) {
27208 cacheKey = keys.join(',') + (isSVG ? '-svg' : '');
27209 var cache = decalCache.get(cacheKey);
27210
27211 if (cache) {
27212 isSVG ? pattern.svgElement = cache : pattern.image = cache;
27213 }
27214 }
27215
27216 var dashArrayX = normalizeDashArrayX(decalOpt.dashArrayX);
27217 var dashArrayY = normalizeDashArrayY(decalOpt.dashArrayY);
27218 var symbolArray = normalizeSymbolArray(decalOpt.symbol);
27219 var lineBlockLengthsX = getLineBlockLengthX(dashArrayX);
27220 var lineBlockLengthY = getLineBlockLengthY(dashArrayY);
27221 var canvas = !isSVG && createCanvas();
27222 var svgRoot = isSVG && zr.painter.createSVGElement('g');
27223 var pSize = getPatternSize();
27224 var ctx;
27225
27226 if (canvas) {
27227 canvas.width = pSize.width * dpr;
27228 canvas.height = pSize.height * dpr;
27229 ctx = canvas.getContext('2d');
27230 }
27231
27232 brushDecal();
27233
27234 if (isValidKey) {
27235 decalCache.put(cacheKey, canvas || svgRoot);
27236 }
27237
27238 pattern.image = canvas;
27239 pattern.svgElement = svgRoot;
27240 pattern.svgWidth = pSize.width;
27241 pattern.svgHeight = pSize.height;
27242 /**
27243 * Get minumum length that can make a repeatable pattern.
27244 *
27245 * @return {Object} pattern width and height
27246 */

Callers 1

Calls 9

normalizeDashArrayXFunction · 0.85
normalizeDashArrayYFunction · 0.85
normalizeSymbolArrayFunction · 0.85
getLineBlockLengthXFunction · 0.85
getLineBlockLengthYFunction · 0.85
createCanvasFunction · 0.85
getPatternSizeFunction · 0.85
brushDecalFunction · 0.85
isArrayFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…