MCPcopy
hub / github.com/microsoft/SandDance / gradientRef

Function gradientRef

docs/tests/v2/es6/js/sanddance.js:93897–93925  ·  view source on GitHub ↗
(g, defs, base)

Source from the content-addressed store, hash-verified

93895}
93896
93897function gradientRef(g, defs, base) {
93898 let id = g.id,
93899 type = g.gradient,
93900 prefix = type === 'radial' ? patternPrefix : ''; // check id, assign default values as needed
93901
93902 if (!id) {
93903 id = g.id = 'gradient_' + gradient_id++;
93904
93905 if (type === 'radial') {
93906 g.x1 = get(g.x1, 0.5);
93907 g.y1 = get(g.y1, 0.5);
93908 g.r1 = get(g.r1, 0);
93909 g.x2 = get(g.x2, 0.5);
93910 g.y2 = get(g.y2, 0.5);
93911 g.r2 = get(g.r2, 0.5);
93912 prefix = patternPrefix;
93913 } else {
93914 g.x1 = get(g.x1, 0);
93915 g.y1 = get(g.y1, 0);
93916 g.x2 = get(g.x2, 1);
93917 g.y2 = get(g.y2, 0);
93918 }
93919 } // register definition
93920
93921
93922 defs[id] = g; // return url reference
93923
93924 return 'url(' + (base || '') + '#' + prefix + id + ')';
93925}
93926
93927function get(val, def) {
93928 return val != null ? val : def;

Callers

nothing calls this directly

Calls 1

getFunction · 0.70

Tested by

no test coverage detected