title: Canvas' drawLine and drawRect not including end position?
body: <p>To my surprise I've just discovered that drawLine and drawRect don't include the ending position, i.e.:</p>
  <pre><code>canvas.drawLine(100, 100, 100, 100, paint);
  </code></pre>
  <p>or</p>
  <pre><code>RectF rect = new RectF(100, 100, 100, 100);
  canvas.drawRect(rect, paint);
  </code></pre>
  <p>won't draw anything.</p>
  <p>My paint is defined as follows:</p>
  <pre><code>Paint paint = new Paint();
  paint.setAntiAlias(false);
  paint.setStyle(Paint.Style.FILL);
  return paint;
  </code></pre>
  <p>I've tried defining my paint as FILL_AND_STROKE, but it wouldn't help.</p>
  <p>Android's drawPaint() javadoc don't even list the stopX and stopY params!</p>
  <p>So, if I want to draw a vertical line that goes exactly from beginY to endY (inclusive), I have to do the following:</p>
  <pre><code>canvas.drawLine(constX, beginY, constX, endY + 1)
  </code></pre>
  <p>Notice that I didn't add 1 to the ending X position, only to ending Y (xstays the same as I want a vertical line).</p>
  <p>My device is HTC SENSE.</p>
  <p>Edit: Simon, you're right, rather than asking a question I've just tried to share my feeling of surprise that Android does not do what its docs say in such a fundamental case as basic drawing, and make sure that I didn't do any stupid mistake on my way.</p>
  <p>To make myself clearer: drawRect's javadoc says:</p>
  <blockquote>
  <p><strong>public void drawRect (float left, float top, float right, float bottom, Paint paint)</strong></p>
  <p>Draw the specified Rect using the specified paint. The rectangle will be filled or framed based on the Style in the paint.</p>
  <p>left - The left side of the rectangle to be drawn</p>
  <p>top - The top side of the rectangle to be drawn</p>
  <p>right - The right side of the rectangle to be drawn</p>
  <p>bottom - The bottom side of the rectangle to be drawn</p>
  <p>paint - The paint used to draw the rect</p>
  </blockquote>
  <p>So, when writing</p>
  <pre><code>canvas.drawRect(x1, y1, x2, y2)
  </code></pre>
  <p>You expect a rectangle whose corners are at (x1, y1); (x1, y2); (x2, y1) and (x2, y2).</p>
  <p>Android says: wrong! They will be at (x1, y1); (x1, y2-1); (x2-1, y1) and (x2-1, y2-1).</p>
  <p>For the curious ones: set the canvas clipping:</p>
  <pre><code>canvas.clipRect(x1, y1, x2, y2)
  </code></pre>
  <p>Then try to draw a point:</p>
  <pre><code>canvas.drawPoint(x1, y1, paint);
  </code></pre>
  <p>and you get a point on the screen.</p>
  <p>Then try in the opposite corner:</p>
  <pre><code>canvas.drawPoint(x2, y2, paint);
  </code></pre>
  <p>nothing appears. nothing will appear in the remaining 2 corners as well:</p>
  <pre><code>canvas.drawPoint(x1, y2, paint);
  
  
  canvas.drawPoint(x2, y2, paint);
  </code></pre>
  <p>Still not surprising to you folks?</p>
  <p>So the conclusion is that Android treats <strong>right</strong> and <strong>bottom</strong> coordinates as exclusive, meaning that e.g. when writing:</p>
  <pre><code>canvas.clipRect(x1, y1, x2, y2)
  </code></pre>
  <p>You will get the clipping bounds of (x1, y1, x2 - 1, y2 - 1). The same goes with every method that takes <strong>right</strong> and <strong>bottom</strong> coordinates or <strong>Rect/RectF</strong> objects.</p>