title: getImageData returns wrong opacity on the right side of the canvas
body: <p>I'm trying to get the opacity of a gradient of the mouse position when it's over a canvas. However when the mouse is close to the right edge returns 0 instead of 255.</p>
  <p>This behavior seems to change on different sizes. On small sizes the opacity returned doesn't reach 255.</p>
  <p>How i can get the correct opacity regardless the size?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const canvas = document.getElementById("canvas");
  const context = canvas.getContext("2d", { alpha: true});
  
  const gradient = context.createLinearGradient( 0, 0 , canvas.width, 0);
  gradient.addColorStop( 0, "rgba(0, 0, 0, 0)" );
  gradient.addColorStop( 1, "rgba(0, 0, 0, 1)" );
  
  context.fillStyle = gradient;
  context.fillRect( 0, 0, canvas.width, canvas.height);
  
  canvas.addEventListener("mousemove", function() {
      const p = document.getElementById("result");
    const x = event.offsetX;
    const y = event.offsetY;
    const imageData = context.getImageData( x, y, 1, 1)
    
    p.textContent = imageData.data;
  })</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#canvas {
    width: 100%;
    height: 30px;
  }
  
  #result {
    margin-top: 10px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
    &lt;canvas id="canvas"&gt;&lt;/canvas&gt;
    
    &lt;p id="result"&gt;&lt;/p&gt;
    
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>