dojox/gfx3d/gradient.js

  • Provides:

    • dojox.gfx3d.gradient
  • Requires:

    • dojox.gfx3d.vector in common
    • dojox.gfx3d.matrix in common
  • dojox.gfx3d.gradient

    • type
      Function
    • parameters:
      • model: (typeof dojox.gfx3d.lighting.Model)
        color model
      • material: (typeof Object)
        defines visual properties
      • center: (typeof Object)
        center of the cylinder's bottom
      • radius: (typeof Number)
        radius of the cylinder
      • from: (typeof Number)
        from position in radians
      • to: (typeof Number)
        from position in radians
      • matrix: (typeof dojox.gfx3d.Matrix3D)
        the cumulative transformation matrix
        tolerance: Number: tolerable diffirence in colors between gradient steps
    • source: [view]
        var m = dojox.gfx3d.matrix, v = dojox.gfx3d.vector, mx = m.normalize(matrix),
         f = m.multiplyPoint(mx, radius * Math.cos(from) + center.x, radius * Math.sin(from) + center.y, center.z),
         t = m.multiplyPoint(mx, radius * Math.cos(to) + center.x, radius * Math.sin(to) + center.y, center.z),
         c = m.multiplyPoint(mx, center.x, center.y, center.z), step = (to - from) / N, r = dist(f, t) / 2,
         mod = model[material.type], fin = material.finish, pmt = material.color,
         colors = [{offset: 0, color: mod.call(model, v.substract(f, c), fin, pmt)}];


        for(var a = from + step; a < to; a += step){
         var p = m.multiplyPoint(mx, radius * Math.cos(a) + center.x, radius * Math.sin(a) + center.y, center.z),
          df = dist(f, p), dt = dist(t, p);
         colors.push({offset: df / (df + dt), color: mod.call(model, v.substract(p, c), fin, pmt)});
        }
        colors.push({offset: 1, color: mod.call(model, v.substract(t, c), fin, pmt)});


        return {type: "linear", x1: 0, y1: -r, x2: 0, y2: r, colors: colors};
    • summary
      calculate a cylindrical gradient
    • chains:
      • mod: (call)
  • dojox.gfx3d

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary