/*
 * Copyright (c) 2011 Kevin Decker (http://www.incaseofstairs.com/)
 * See LICENSE for license information
 */
$(document).ready(function() {
    function drawGradient(x, y, r1, r2) {
        var radialGradient = context.createRadialGradient(x, y, r1, x, y, r2);
        radialGradient.addColorStop(0, "red");
        radialGradient.addColorStop(1, "green");
        context.fillStyle = radialGradient;

        context.beginPath();
        context.arc(x, y, r2, 0, 360, false);
        context.fill();
        context.closePath();
    }
    var canvas = document.getElementById("imageDisplay"),
        context = canvas.getContext("2d");

    context.fillRect(0,0,50,50);

    var linearGradient = context.createLinearGradient(100, 100, 100, 600);
    linearGradient.addColorStop(0.0, "black");
    linearGradient.addColorStop(0.5, "red");
    linearGradient.addColorStop(1.0, "blue");
    context.fillStyle = linearGradient;
    context.fillRect(100,100,500,600);

    drawGradient(75, 75, 25, 55);
    drawGradient(225, 75, 5, 55);

    var img = document.createElement("img");
    $(img).load(function() {
        context.drawImage(img, 100, 100);

        edgeContext = ImageDataUtils.getEdgeContext(canvas);
    });

    img.src = "test/css-gradient-dropdown-menu.gif";

    setTimeout(function() {
        var mousedown = jQuery.Event("mousedown");
        mousedown.pageX = 189;
        mousedown.pageY = 503;

        var mousemove = jQuery.Event("mousemove");
        mousemove.pageX = 189;
        mousemove.pageY = 142;

        var mouseup = jQuery.Event("mouseup");
        mouseup.pageX = 189;
        mouseup.pageY = 142;

        $(canvas).trigger(mousedown)
                .trigger(mousemove)
                .trigger(mouseup);
    }, 500);
});

@@ -1293,32 +1293,83 @@
 ut(function() %7B%0A
+        var offset = $(%22#imageDisplay%22).offset();%0A%0A
         var mous
@@ -1466,16 +1466,158 @@
 = 503;%0A%0A
+        mousedown.pageX = 366;%0A        mousedown.pageY = 100;%0A        mousedown.pageX += offset.left;%0A        mousedown.pageY += offset.top;%0A%0A
         
@@ -1734,45 +1734,60 @@
     
-var 
 mouse
-up = jQuery.Event(%22mouseup%22)
+move.pageX = 366;%0A        mousemove.pageY = 600
 ;%0A  
@@ -1801,22 +1801,33 @@
 ouse
-up
+move
 .pageX 
++
 = 
-189
+offset.left
 ;%0A  
@@ -1841,22 +1841,32 @@
 ouse
-up
+move
 .pageY 
++
 = 
-142
+offset.top
 ;%0A%0A 
@@ -1966,15 +1966,31 @@
 ger(
+jQuery.Event(%22
 mouseup
+%22)
 );%0A 

Test data updates