dojox/gfx/gradutils.js

  • Provides:

    • dojox.gfx.gradutils
  • Requires:

    • dojox.gfx.matrix in common
  • dojox.gfx.gradutils.getColor

    • type
      Function
    • parameters:
      • fill: (typeof Object)
        fill object
      • pt: (typeof dojox.gfx.Point)
        point where to sample a color
    • 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
    • summary
      sample a color from a gradient using a point
    • returns
      dojo.Color
  • dojox.gfx.gradutils.reverse

    • type
      Function
    • parameters:
      • fill: (typeof Object)
        fill object
    • source: [view]
        if(fill){
         switch(fill.type){
          case "linear":
          case "radial":
           fill = dojo.delegate(fill);
           if(fill.colors){
            var c = fill.colors, l = c.length, i = 0, stop,
             n = fill.colors = new Array(c.length);
            for(; i < l; ++i){
             stop = c[i];
             n[i] = {
              offset: 1 - stop.offset,
              color: stop.color
             };
            }
            n.sort(function(a, b){ return a.offset - b.offset; });
           }
           break;
         }
        }
        return fill; // Object
    • summary
      reverses a gradient
    • returns
      Object
  • dojox.gfx.gradutils

    • type
      Object
    • summary
  • dojox.gfx

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary