vendor/kinetic-v5.1.0.js
function(alphaThreshold) {
            var threshold = alphaThreshold || 0,
                cachedCanvas = this._cache.canvas,
                sceneCanvas = this._getCachedSceneCanvas(),
                sceneContext = sceneCanvas.getContext(),
                hitCanvas = cachedCanvas.hit,
                hitContext = hitCanvas.getContext(),
                width = sceneCanvas.getWidth(),
                height = sceneCanvas.getHeight(),
                sceneImageData, sceneData, hitImageData, hitData, len, rgbColorKey, i, alpha;

            hitContext.clear();

            try {
                sceneImageData = sceneContext.getImageData(0, 0, width, height);
                sceneData = sceneImageData.data;
                hitImageData = hitContext.getImageData(0, 0, width, height);
                hitData = hitImageData.data;
                len = sceneData.length;
                rgbColorKey = Kinetic.Util._hexToRgb(this.colorKey);

                // replace non transparent pixels with color key
                for(i = 0; i < len; i += 4) {
                    alpha = sceneData[i + 3];
                    if (alpha > threshold) {
                        hitData[i] = rgbColorKey.r;
                        hitData[i + 1] = rgbColorKey.g;
                        hitData[i + 2] = rgbColorKey.b;
                        hitData[i + 3] = 255;
                    }
                }

                hitContext.putImageData(hitImageData, 0, 0);
            }
            catch(e) {
                Kinetic.Util.warn('Unable to draw hit graph from cached scene canvas. ' + e.message);
            }

            return this;
        }
function(alphaThreshold) {
            var threshold = alphaThreshold || 0,
                cachedCanvas = this._cache.canvas,
                sceneCanvas = this._getCachedSceneCanvas(),
                sceneContext = sceneCanvas.getContext(),
                hitCanvas = cachedCanvas.hit,
                hitContext = hitCanvas.getContext(),
                width = sceneCanvas.getWidth(),
                height = sceneCanvas.getHeight(),
                sceneImageData, sceneData, hitImageData, hitData, len, rgbColorKey, i, alpha;

            hitContext.clear();

            try {
                sceneImageData = sceneContext.getImageData(0, 0, width, height);
                sceneData = sceneImageData.data;
                hitImageData = hitContext.getImageData(0, 0, width, height);
                hitData = hitImageData.data;
                len = sceneData.length;
                rgbColorKey = Kinetic.Util._hexToRgb(this.colorKey);

                // replace non transparent pixels with color key
                for(i = 0; i < len; i += 4) {
                    alpha = sceneData[i + 3];
                    if (alpha > threshold) {
                        hitData[i] = rgbColorKey.r;
                        hitData[i + 1] = rgbColorKey.g;
                        hitData[i + 2] = rgbColorKey.b;
                        hitData[i + 3] = 255;
                    }
                }

                hitContext.putImageData(hitImageData, 0, 0);
            }
            catch(e) {
                Kinetic.Util.warn('Unable to draw hit graph from cached scene canvas. ' + e.message);
            }

            return this;
        }
function ( alphaThreshold ) { var threshold = alphaThreshold || 0 , cachedCanvas = this . _cache . canvas , sceneCanvas = this . _getCachedSceneCanvas ( ) , sceneContext = sceneCanvas . getContext ( ) , hitCanvas = cachedCanvas . hit , hitContext = hitCanvas . getContext ( ) , width = sceneCanvas . getWidth ( ) , height = sceneCanvas . getHeight ( ) , sceneImageData , sceneData , hitImageData , hitData , len , rgbColorKey , i , alpha ; hitContext . clear ( ) ; try { sceneImageData = sceneContext . getImageData ( 0 , 0 , width , height ) ; sceneData = sceneImageData . data ; hitImageData = hitContext . getImageData ( 0 , 0 , width , height ) ; hitData = hitImageData . data ; len = sceneData . length ; rgbColorKey = Kinetic . Util . _hexToRgb ( this . colorKey ) ; // replace non transparent pixels with color key for ( i = 0 ; i < len ; i += 4 ) { alpha = sceneData [ i + 3 ] ; if ( alpha > threshold ) { hitData [ i ] = rgbColorKey . r ; hitData [ i + 1 ] = rgbColorKey . g ; hitData [ i + 2 ] = rgbColorKey . b ; hitData [ i + 3 ] = 255 ; } } hitContext . putImageData ( hitImageData , 0 , 0 ) ; } catch ( e ) { Kinetic . Util . warn ( 'Unable to draw hit graph from cached scene canvas. ' + e . message ) ; } return this ; }
draw hit graph using the cached scene canvas
@method
@memberof Kinetic.Shape.prototype
@param {Integer} alphaThreshold alpha channel threshold that determines whether or not
a pixel should be drawn onto the hit graph.  Must be a value between 0 and 255.
The default is 0
@returns {Kinetic.Shape}
@example
shape.cache();
shape.drawHitFromCache();
draw hit graph using the cached scene canvas