source: [view]
var o;
if(fill){
switch(fill.type){
case "linear":
var angle = Math.atan2(fill.y2 - fill.y1, fill.x2 - fill.x1),
rotation = m.rotate(-angle),
projection = m.project(fill.x2 - fill.x1, fill.y2 - fill.y1),
p = m.multiplyPoint(projection, pt),
pf1 = m.multiplyPoint(projection, fill.x1, fill.y1),
pf2 = m.multiplyPoint(projection, fill.x2, fill.y2),
scale = m.multiplyPoint(rotation, pf2.x - pf1.x, pf2.y - pf1.y).x,
o = m.multiplyPoint(rotation, p.x - pf1.x, p.y - pf1.y).x / scale;
break;
case "radial":
var dx = pt.x - fill.cx, dy = pt.y - fill.cy,
o = Math.sqrt(dx * dx + dy * dy) / fill.r;
break;
}
return findColor(o, fill.colors); // dojo.Color
}
// simple color
return new C(fill || [0, 0, 0, 0]); // dojo.Color