@@ -203,39 +203,36 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
203203 ctx . beginPath ( ) ;
204204 for ( var i = 0 , l = children . length ; i < l ; i ++ )
205205 children [ i ] . _draw ( ctx , param ) ;
206- var res = ctx . isPointInPath ( point . x , point . y ) ;
206+ var res = ctx . isPointInPath ( point . x , point . y , this . getWindingRule ( ) ) ;
207207 CanvasProvider . release ( ctx ) ;
208208 return res && children ;
209209/*#*/ } // options.nativeContains
210210
211211 // Compound paths are a little complex: In order to determine whether a
212- // point is inside a path or not due to the even-odd rule, we need to
212+ // point is inside a path or not due to the winding rule, we need to
213213 // check all the children and count how many intersect. If it's an odd
214214 // number, the point is inside the path. Once we know it's inside the
215215 // path, _hitTest also needs access to the first intersecting element,
216- // for the HitResult, so we collect and return a list here.
216+ // for the HitResult, so we return it here.
217217 var total = 0 ,
218- children = [ ] ;
218+ first = null ,
219+ evenOdd = this . getWindingRule ( ) === 'evenodd' ;
219220 for ( var i = 0 , l = this . _children . length ; i < l ; i ++ ) {
220221 var child = this . _children [ i ] ,
221222 winding = child . _getWinding ( point ) ;
222223 total += winding ;
223- /*
224- if (winding & 1)
225- children.push(child);
226- */
227- if ( winding )
228- children . push ( child ) ;
224+ if ( ! first && ( evenOdd ? winding & 1 : winding ) )
225+ first = child ;
229226 }
230- return total && children ; // <- non-zero // even-odd: ( total & 1 ) && children ;
227+ return ( evenOdd ? total & 1 : total ) && first ;
231228 } ,
232229
233230 _hitTest : function _hitTest ( point , options ) {
234231 var res = _hitTest . base . call ( this , point ,
235232 Base . merge ( options , { fill : false } ) ) ;
236233 if ( ! res && options . fill && this . hasFill ( ) ) {
237234 res = this . _contains ( point ) ;
238- res = res ? new HitResult ( 'fill' , res [ 0 ] ) : null ;
235+ res = res ? new HitResult ( 'fill' , res ) : null ;
239236 }
240237 return res ;
241238 } ,
@@ -253,7 +250,7 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
253250 if ( ! param . clip ) {
254251 this . _setStyles ( ctx ) ;
255252 if ( style . getFillColor ( ) )
256- ctx . fill ( ) ;
253+ ctx . fill ( style . getWindingRule ( ) ) ;
257254 if ( style . getStrokeColor ( ) )
258255 ctx . stroke ( ) ;
259256 }
0 commit comments