mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
parent
31e2c37e0d
commit
2884894d0f
1 changed files with 13 additions and 11 deletions
|
@ -1755,16 +1755,20 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
_hitTest: function(point, options) {
|
_hitTest: function(point, options) {
|
||||||
var style = this.getStyle(),
|
var that = this,
|
||||||
|
style = this.getStyle(),
|
||||||
segments = this._segments,
|
segments = this._segments,
|
||||||
closed = this._closed,
|
closed = this._closed,
|
||||||
tolerance = options.tolerance,
|
tolerance = options.tolerance,
|
||||||
radius = 0, join, cap, miterLimit,
|
join, cap, miterLimit,
|
||||||
that = this,
|
area, loc, res,
|
||||||
area, loc, res;
|
hasStroke = options.stroke && style.hasStroke(),
|
||||||
|
hasFill = options.fill && style.hasFill(),
|
||||||
if (options.stroke) {
|
radius = hasStroke ? style.getStrokeWidth() / 2
|
||||||
radius = style.getStrokeWidth() / 2;
|
// Set radius to 0 so when we're hit-testing, the tolerance
|
||||||
|
// is used for fill too, through stroke functionality.
|
||||||
|
: hasFill ? 0 : null;
|
||||||
|
if (radius != null) {
|
||||||
if (radius > 0) {
|
if (radius > 0) {
|
||||||
join = style.getStrokeJoin();
|
join = style.getStrokeJoin();
|
||||||
cap = style.getStrokeCap();
|
cap = style.getStrokeCap();
|
||||||
|
@ -1889,12 +1893,10 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
}
|
}
|
||||||
// Don't process loc yet, as we also need to query for stroke after fill
|
// Don't process loc yet, as we also need to query for stroke after fill
|
||||||
// in some cases. Simply skip fill query if we already have a matching
|
// in some cases. Simply skip fill query if we already have a matching
|
||||||
// stroke.
|
// stroke. If we have a loc and no stroke then it's a result for fill.
|
||||||
return !loc && options.fill && this.hasFill() && this._contains(point)
|
return !loc && hasFill && this._contains(point) || loc && !hasStroke
|
||||||
? new HitResult('fill', this)
|
? new HitResult('fill', this)
|
||||||
: loc
|
: loc
|
||||||
// TODO: Do we need to transform loc back to the coordinate
|
|
||||||
// system of the DOM level on which the inquiry was started?
|
|
||||||
? new HitResult('stroke', this, { location: loc })
|
? new HitResult('stroke', this, { location: loc })
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue