Inject HitResults fields as enumerable, so the default #toString works, and avoid listing getColor.

This commit is contained in:
Jürg Lehni 2012-09-30 14:07:27 -07:00
parent 9e61995282
commit 99ac617ded
2 changed files with 8 additions and 4 deletions

View file

@ -28,8 +28,10 @@ HitResult = Base.extend(/** @lends HitResult# */{
// Inject passed values, so we can be flexible about the HitResult
// properties.
// This allows the definition of getters too, e.g. for 'pixel'.
if (values)
if (values) {
values.enumerable = true;
this.inject(values);
}
},
/**

View file

@ -393,9 +393,11 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
var that = this;
return new HitResult('pixel', that, {
offset: point.add(that._size.divide(2)).round(),
// Becomes HitResult#color
getColor: function() {
return that.getPixel(this.offset);
// Inject as Bootstrap accessor, so #toString renders well too
color: {
get: function() {
return that.getPixel(this.offset);
}
}
});
}