mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Inject HitResults fields as enumerable, so the default #toString works, and avoid listing getColor.
This commit is contained in:
parent
9e61995282
commit
99ac617ded
2 changed files with 8 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue