Skip to content

Commit

Permalink
refs #12844 more AMD updates for gfx from wildbill. Thanks! \!strict
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.dojotoolkit.org/src/dojox/trunk@26246 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
ccmitchellusa committed Aug 16, 2011
1 parent 1b32b2d commit dd70aad
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 109 deletions.
2 changes: 1 addition & 1 deletion gfx.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ define(["dojo/_base/lang", "./gfx/_base", "./gfx/renderer!"],
// summary:
// This the root of the Dojo Graphics package
gfxBase.switchTo(renderer);
return dojox.gfx;
return gfxBase;
});
14 changes: 7 additions & 7 deletions gfx/_base.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
define(["dojo/_base/lang", "dojox/main", "dojo/_base/html", "dojo/_base/Color", "dojo/_base/sniff", "dojo/_base/window",
define(["dojo/_base/lang", "dojo/_base/html", "dojo/_base/Color", "dojo/_base/sniff", "dojo/_base/window",
"dojo/_base/array","dojo/dom", "dojo/dom-construct","dojo/dom-geometry"],
function(lang, dojox, html, Color, has, win, arr, dom, domConstruct, domGeom){
function(lang, html, Color, has, win, arr, dom, domConstruct, domGeom){
// module:
// dojox/gfx
// summary:
// This module contains common core Graphics API used by different graphics renderers.
lang.getObject("gfx._base", true, dojox);

var g = dojox.gfx, b = g._base;

var g = lang.getObject("dojox.gfx", true),
b = g._base = {};
/*===== g = dojox.gfx; b = dojox.gfx._base; =====*/
// candidates for dojox.style (work on VML and SVG nodes)
g._hasClass = function(/*DomNode*/node, /*String*/classStr){
// summary:
Expand Down Expand Up @@ -144,7 +144,7 @@ define(["dojo/_base/lang", "dojox/main", "dojo/_base/html", "dojo/_base/Color",
// summary: returns a unique string for use with any DOM element
var id;
do{
id = dojox._scopeName + "Unique" + (++uniqueId);
id = dojo._scopeName + "xUnique" + (++uniqueId);
}while(dom.byId(id));
return id;
};
Expand Down
8 changes: 4 additions & 4 deletions gfx/_gfxBidiSupport.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
define(["dojo/_base/lang","dojo/_base/sniff", "dojo/dom", "dojo/_base/html", "dojo/_base/array",
define(["./_base", "dojo/_base/lang","dojo/_base/sniff", "dojo/dom", "dojo/_base/html", "dojo/_base/array",
"./utils", "./shape", "dojox/string/BidiEngine"],
function(lang, has, dom, html, arr, utils, shapeLib, BidiEngine){
function(g, lang, has, dom, html, arr, utils, shapeLib, BidiEngine){
lang.getObject("dojox.gfx._gfxBidiSupport", true);
var g = dojox.gfx;
/*===== g = dojox.gfx; =====*/
switch (g.renderer){
case 'vml':
g.isVml = true;
Expand Down Expand Up @@ -347,7 +347,7 @@ define(["dojo/_base/lang","dojo/_base/sniff", "dojo/dom", "dojo/_base/html", "do
extendMethod(g.Group,"createTextPath", textDirPreprocess, null);

g.createSurface = function(parentNode, width, height, textDir) {
var s = dojox.gfx[g.renderer].createSurface(parentNode, width, height);
var s = g[g.renderer].createSurface(parentNode, width, height);
var tDir = validateTextDir(textDir);

if(g.isSvgWeb){
Expand Down
8 changes: 4 additions & 4 deletions gfx/arc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
define(["dojo/_base/lang", "./matrix"],
function(lang, m){
define(["./_base", "dojo/_base/lang", "./matrix"],
function(g, lang, m){
/*=====
g = dojox.gfx;
dojox.gfx.arc = {
// summary:
// This module contains the core graphics Arc functions.
};
=====*/

lang.getObject("dojox.gfx.arc", true);
var twoPI = 2 * Math.PI, pi4 = Math.PI / 4, pi8 = Math.PI / 8,
pi48 = pi4 + pi8, curvePI4 = unitArcAsBezier(pi8);

Expand All @@ -26,7 +26,7 @@ define(["dojo/_base/lang", "./matrix"],
};
}

var arc = dojox.gfx.arc = {
var arc = g.arc = {
unitArcAsBezier: unitArcAsBezier,
curvePI4: curvePI4,
// curvePI4: Object
Expand Down
10 changes: 5 additions & 5 deletions gfx/canvas.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/window", "dojo/dom-geometry",
define(["./_base", "dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/window", "dojo/dom-geometry",
"dojo/dom", "./_base", "./shape", "./path", "./arc", "./matrix", "./decompose"],
function(lang, arr, declare, win, domGeom, dom, gfxBase, gs, pathLib, ga, m, decompose ){
function(g, lang, arr, declare, win, domGeom, dom, gfxBase, gs, pathLib, ga, m, decompose ){
/*=====
dojox.gfx.canvas = {
// module:
Expand All @@ -17,6 +17,7 @@ define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base
// graphics context between renderer implementations. See dojox.gfx._base switchRenderer
// API.
};
g = dojox.gfx;
pathLib.Path = dojox.gfx.path.Path;
pathLib.TextPath = dojox.gfx.path.TextPath;
canvas.Shape = dojox.gfx.canvas.Shape;
Expand All @@ -31,9 +32,8 @@ define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base
gs.Surface = dojox.gfx.shape.Surface;
=====*/

var canvas = lang.getObject("dojox.gfx.canvas", true);
var g = dojox.gfx,
pattrnbuffer = null,
var canvas = g.canvas = {};
var pattrnbuffer = null,
mp = m.multiplyPoint,
pi = Math.PI,
twoPI = 2 * pi,
Expand Down
3 changes: 2 additions & 1 deletion gfx/canvasWithEvents.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/_base/Color", "dojo/dom",
"dojo/dom-geometry", "./_base","./canvas", "./shape", "./matrix"],
function(lang, declare, hub, Color, dom, domGeom, g, canvas, shapeLib, m){
var canvasEvent = lang.getObject("dojox.gfx.canvasWithEvents", true);
/*=====
dojox.gfx.canvasWithEvents = {
// module:
Expand All @@ -20,6 +19,7 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/_ba
// graphics context between renderer implementations. See dojox.gfx._base switchRenderer
// API.
};
g = dojox.gfx;
var canvas.Shape = dojox.gfx.canvas.Shape;
var canvas.Group = dojox.gfx.canvas.Group;
var canvas.Image = dojox.gfx.canvas.Image;
Expand All @@ -35,6 +35,7 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/_ba
var canvasEvent.Shape = dojox.gfx.canvasWithEvents.Shape;
=====*/
var canvasEvent = g.canvasWithEvents = {};

declare("dojox.gfx.canvasWithEvents.Shape", canvas.Shape, {

Expand Down
7 changes: 4 additions & 3 deletions gfx/decompose.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(["dojo/_base/lang", "./matrix"],
function (lang, m){
define(["./_base", "dojo/_base/lang", "./matrix"],
function (g, lang, m){
/*===== g = dojox.gfx =====*/
function eq(/* Number */ a, /* Number */ b){
// summary: compare two FP numbers for equality
return Math.abs(a - b) <= 1e-6 * (Math.abs(a) + Math.abs(b)); // Boolean
Expand Down Expand Up @@ -91,7 +92,7 @@ define(["dojo/_base/lang", "./matrix"],
return result; // Object
}

return dojox.gfx.decompose = function(matrix){
return g.decompose = function(matrix){
// summary: decompose a 2D matrix into translation, scaling, and rotation components
// description: this function decompose a matrix into four logical components:
// translation, rotation, scaling, and one more rotation using SVD.
Expand Down
3 changes: 2 additions & 1 deletion gfx/fx.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define(["dojo/_base/lang", "./_base", "./matrix", "dojo/_base/Color", "dojo/_base/array", "dojo/_base/fx", "dojo/_base/connect"],
function(lang, g, m, Color, arr, fx, Hub){
var fxg = lang.getObject("dojox.gfx.fx", true);
/*===== g = dojox.gfx =====*/
var fxg = g.fx = {};

// Generic interpolators. Should they be moved to dojox.fx?

Expand Down
11 changes: 6 additions & 5 deletions gfx/gradutils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Various generic utilities to deal with a linear gradient

define(["dojo/_base/lang", "./matrix", "dojo/_base/Color"],
define(["./_base", "dojo/_base/lang", "./matrix", "dojo/_base/Color"],
function(lang, m, Color){
gradutils= lang.getObject("dojox.gfx.gradutils", true);
var C = Color;

/*===== g= dojox.gfx =====*/
var gradutils = g.gradutils = {};

function findColor(o, c){
if(o <= 0){
Expand All @@ -19,7 +20,7 @@ define(["dojo/_base/lang", "./matrix", "dojo/_base/Color"],
if(stop.offset >= o){
if(i){
var prev = c[i - 1];
return C.blendColors(new C(prev.color), new C(stop.color),
return Color.blendColors(new Color(prev.color), new Color(stop.color),
(o - prev.offset) / (stop.offset - prev.offset));
}
return stop.color;
Expand Down Expand Up @@ -56,7 +57,7 @@ define(["dojo/_base/lang", "./matrix", "dojo/_base/Color"],
return findColor(o, fill.colors); // dojo.Color
}
// simple color
return new C(fill || [0, 0, 0, 0]); // dojo.Color
return new Color(fill || [0, 0, 0, 0]); // dojo.Color
};

gradutils.reverse = function(fill){
Expand Down
11 changes: 6 additions & 5 deletions gfx/matrix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define(["dojo/_base/lang"],
function(lang){
var m = lang.getObject("gfx.matrix", true, dojox);
define(["./_base","dojo/_base/lang"],
function(g, lang){
/*===== g = dojox.gfx =====*/
var m = g.matrix = {};

// candidates for dojox.math:
var _degToRadCache = {};
Expand All @@ -23,7 +24,7 @@ define(["dojo/_base/lang"],
var matrix = m.normalize(arg[0]);
// combine matrices
for(var i = 1; i < arg.length; ++i){
var l = matrix, r = dojox.gfx.matrix.normalize(arg[i]);
var l = matrix, r = m.normalize(arg[i]);
matrix = new m.Matrix2D();
matrix.xx = l.xx * r.xx + l.xy * r.yx;
matrix.xy = l.xx * r.xy + l.xy * r.yy;
Expand Down Expand Up @@ -437,7 +438,7 @@ define(["dojo/_base/lang"],

});
// propagate Matrix2D up
dojox.gfx.Matrix2D = m.Matrix2D;
g.Matrix2D = m.Matrix2D;

return m;
});
Expand Down
39 changes: 21 additions & 18 deletions gfx/path.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
function(lang, declare, matrix, shapeLib){
define(["./_base", "dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
function(g, lang, declare, matrix, shapeLib){
/*=====
dojox.gfx.path = {
// summary:
// This module contains the core graphics Path API.
// Path command format follows the W3C SVG 1.0 Path api.
};
g = dojox.gfx;
shape.Shape = dojox.gfx.shape.Shape;
=====*/

declare("dojox.gfx.path.Path", dojox.gfx.shape.Shape, {
var path = g.path = {};
var Path = declare("dojox.gfx.path.Path", shapeLib.Shape, {
// summary: a generalized path shape

constructor: function(rawNode){
// summary: a path constructor
// rawNode: Node
// a DOM node to be used by this path object
this.shape = lang.clone(dojox.gfx.defaultPath);
this.shape = lang.clone(g.defaultPath);
this.segments = [];
this.tbbox = null;
this.absolute = true;
Expand Down Expand Up @@ -80,15 +83,15 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
},

// segment interpretation
_updateBBox: function(x, y, matrix){
_updateBBox: function(x, y, m){
// summary: updates the bounding box of path with new point
// x: Number
// an x coordinate
// y: Number
// a y coordinate

if(matrix){
var t = dojox.gfx.matrix.multiplyPoint(matrix, x, y);
if(m){
var t = matrix.multiplyPoint(m, x, y);
x = t.x;
y = t.y;
}
Expand Down Expand Up @@ -201,7 +204,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
// add an SVG path segment
var path = [segment.action];
for(i = 0; i < l; ++i){
path.push(dojox.gfx.formatNumber(n[i], true));
path.push(g.formatNumber(n[i], true));
}
if(typeof this.shape.path == "string"){
this.shape.path += path.join("");
Expand Down Expand Up @@ -354,7 +357,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
// summary: forms a path using an SVG path string
// path: String
// an SVG path string
var p = lang.isArray(path) ? path : path.match(dojox.gfx.pathSvgRegExp);
var p = lang.isArray(path) ? path : path.match(g.pathSvgRegExp);
this.segments = [];
this.absolute = true;
this.bbox = {};
Expand Down Expand Up @@ -386,7 +389,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],

this.segmented = false;
this.segments = [];
if(!dojox.gfx.lazyPathSegmentation){
if(!g.lazyPathSegmentation){
this._confirmSegmented();
}
return this; // self
Expand All @@ -396,18 +399,18 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
_2PI: Math.PI * 2
});

declare("dojox.gfx.path.TextPath", dojox.gfx.path.Path, {
var TextPath = declare("dojox.gfx.path.TextPath", Path, {
// summary: a generalized TextPath shape

constructor: function(rawNode){
// summary: a TextPath shape constructor
// rawNode: Node
// a DOM node to be used by this TextPath object
if(!("text" in this)){
this.text = lang.clone(dojox.gfx.defaultTextPath);
this.text = lang.clone(g.defaultTextPath);
}
if(!("fontStyle" in this)){
this.fontStyle = lang.clone(dojox.gfx.defaultFont);
this.fontStyle = lang.clone(g.defaultFont);
}
},
getText: function(){
Expand All @@ -416,7 +419,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
},
setText: function(newText){
// summary: sets a text to be drawn along the path
this.text = dojox.gfx.makeParameters(this.text,
this.text = g.makeParameters(this.text,
typeof newText == "string" ? {text: newText} : newText);
this._setText();
return this; // self
Expand All @@ -428,15 +431,15 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"],
setFont: function(newFont){
// summary: sets a font for text
this.fontStyle = typeof newFont == "string" ?
dojox.gfx.splitFontString(newFont) :
dojox.gfx.makeParameters(dojox.gfx.defaultFont, newFont);
g.splitFontString(newFont) :
g.makeParameters(g.defaultFont, newFont);
this._setFont();
return this; // self
}
});

return { // our hash of newly defined objects
Path: dojox.gfx.path.Path,
TextPath: dojox.gfx.path.TextPath
Path: Path,
TextPath: TextPath
};
});
6 changes: 3 additions & 3 deletions gfx/renderer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(["dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/config"],
function(lang, has, win, config){
define(["./_base","dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/config"],
function(g, lang, has, win, config){
/*=====
dojox.gfx.renderer = {
// summary:
Expand Down Expand Up @@ -71,7 +71,7 @@ define(["dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/

function loadRenderer(){
require(["dojox/gfx/" + renderer], function(module){
dojox.gfx.renderer = renderer;
g.renderer = renderer;
// memorize the renderer module
currentRenderer = module;
// now load it
Expand Down
Loading

0 comments on commit dd70aad

Please sign in to comment.