module.exports = class Shape extends require './element'module.exports = class Shape extends require './element' constructor: ->
superCopy the element regions if they were set from named arguments
if regions = @regions
@regions = {}
@regions[name] = region for name, region of regions draw: -> thisHelper method, to get element regions that match the event.
getEventRegions: (event) ->
result = nullProceed only if event coordinates are localized
if event and (x = event.localX)? and (y = event.localY)?Walk through the element regions
for name, $ of @regionsand add the region to the result if event localized coordinates are within the region rectangle.
if $[0] <= x <= ($[0] + $[2]) and $[1] <= y <= ($[1] + $[3])Initialize result only if at least one region matches
result or= {}
result[name] = $
return resultCapture mousemove events passing through this shape
mousemoveCaptureListener: (event) ->
superProceed only for valid event
if eventCheck if there are any regions that match the event, store them in the event and set this shape as event target
event.target = this if event.regions = @getEventRegions event
return this mousedownCaptureListener: (event) ->
superProceed only for valid event
if eventCheck if there are any regions that match the event, store them in the event and set this shape as event target
event.target = this if event.regions = @getEventRegions event
return this mouseupCaptureListener: (event) ->
superProceed only for valid event
if eventCheck if there are any regions that match the event, store them in the event and set this shape as event target
event.target = this if event.regions = @getEventRegions event
return this