Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#11940 closed defect (fixed)

dojox.Colorspace typos

Reported by: bill Owned by: Tom Trenka
Priority: high Milestone: 1.6
Component: Dojox Version: 1.5
Keywords: Cc:
Blocked By: Blocking:

Description

I tried

dojox.color.Colorspace.convert({L: 1, a: 2, b: 3}, "Lab", "RGB");

and noticed the following apparent typos

  1. Shouldn't obj here be color?
this.convert=function(/* Object */color, /* string */from, /* string */to, /* Object? */kwArgs){
	if(converters[from] && converters[from][to]){
		return converters[from][to](obj, kwArgs);
	}
	console.warn("dojox.color.Colorspace::convert: Can't convert ", color, " from ", from, " to ", to, ".");
};
  1. And here, looks like confusion between the variable name "p" and "primary":
this.matrix=function(/* String */to, /* Object */primary){
	var wp=this.whitepoint(primary.whitepoint);
	var Xr = p.xr/p.yr, Yr = 1, Zr = (1-p.xr-p.yr)/p.yr;
	var Xg = p.xg/p.yg, Yg = 1, Zg = (1-p.xg-p.yg)/p.yg;
	var Xb = p.xb/p.yb, Yb = 1, Zr = (1-p.xb-p.yb)/p.yb;

	var m1 = [[ Xr, Yr, Zr ], [ Xg, Yg, Zg ], [ Xb, Yb, Zb ]];
	var m2 = [[ wp.X, wp.Y, wp.Z ]];
	var sm = dojox.math.matrix.multiply(m2, dojox.math.matrix.inverse(m1));
	var Sr = sm[0][0], Sg = sm[0][1], Sb = sm[0][2];
	var result=[
		[Sr*Xr, Sr*Yr, Sr*Zr],
		[Sg*Xg, Sg*Yg, Sg*Zg],
		[Sb*Xb, Sb*Yb, Sb*Zb]
	];
	if(to=="RGB"){ return dojox.math.inverse(result); }
	return result;
};
  1. Again in the above code
var Xb = p.xb/p.yb, Yb = 1, Zr = (1-p.xb-p.yb)/p.yb;

Probably wants to define Zb, rather than redefining Zr.

  1. Again in the above code
if(to=="RGB"){ return dojox.math.inverse(result); }

Should be

if(to=="RGB"){ return dojox.math.matrix.inverse(result); }
  1. mutliply
var rgb=dojox.math.matrix.mutliply([[ xyz.X, xyz.Y, xyz.Z ]], m); 

should be

var rgb=dojox.math.matrix.multiply([[ xyz.X, xyz.Y, xyz.Z ]], m); 

Attachments (1)

ColorSpace.patch (1.8 KB) - added by bill 9 years ago.
fixed syntax errors but no idea if this code works on not

Download all attachments as: .zip

Change History (5)

comment:1 Changed 9 years ago by bill

Owner: changed from Eugene Lazutkin to Tom Trenka

Changed 9 years ago by bill

Attachment: ColorSpace.patch added

fixed syntax errors but no idea if this code works on not

comment:2 Changed 9 years ago by Tom Trenka

(In [23212]) Step one in fixing typos and syntax errors in Colorspace. Refs #11940. !strict.

comment:3 Changed 8 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

Going to close this ticket, as dojox.color.Colorspace will probably be removed for the 2.x line of DTK (it was an old contribution from Cal Henderson, and is probably one of the least used things in DojoX).

comment:4 Changed 8 years ago by bill

Milestone: tbd1.6
Note: See TracTickets for help on using tickets.