/* oops, the rect example I gave is for (0,0) (2,0) */
On Sep 11, 2008, at 9:27 AM, Mike Reed wrote:
The general confusion is that the android graphics geometry is center-
line based, and consistent at all matrix transformations, while J2ME
linedrawing is more "pen" based.
As an example, when android draws a line, it basically constructs a
rectangle about the line, by moving parallel to the line by 1/2 the
strokeWidth. If there is no fancy Join (e.g. Square or Round), no
outset is performed on the line's ends. So for the line (0,0) (0,2),
it constructs the rectangle
// assuming the strokeWidth is 1.0
left = 0
top = -1/2
right = 2
bottom = 1/2
and then tries to fill the rectangle, using the standard of rounding
each coordinate to an int via (int)(coord + 0.5) // for positive coords
That said, in your example, the strokeWidth is 0, which is a special
value meaning hairline. This is pretty close to 1.0, but will draw
slightly differently at times, but much faster. (aside: hairline
stroking always draws 1-pixel wide, regardless of the matrix on the
canvas).
Stroking rectangles in hairline mode does a little extra work to be
nice to try to hit all of the corners, even if the normal hairline
drawLine path would have missed it.
But back to center-line geometry. The upshot really is, if you want to
trivially predict what pixels will be hit for stroking, put your
geometry on 1/2 pixel boundaries. Then when I outset by 1/2 the
strokeWidth, the center-line pixel will always get hit.
mike
On Sep 11, 2008, at 9:12 AM, sahn0 wrote:
Yes, p is Paint object set up as follows:
Paint p=new Paint();
p.setColor(0xFF800000);
p.setStyle(Paint.Style.STROKE);
Style.STROKE is needed for drawRect to actually draw rect, issue with
right-bottom pixel shows itself independently of Style.
On 11 сент, 19:48, Mike Reed <[EMAIL PROTECTED]> wrote:
> Might be a bug. Can you put a more complete code snippet (including
> how the paint (p) was setup) into the bug?
>
> thanks,
> mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---