Point

The simplest of these is simply drawing a point. To draw a point, we use the drawPoint method on the Canvas object, passing in the x and y position as well as a Paint object.

canvas.drawPoint(199,201,paint);

The size of the point that is drawn is dependent on the stroke width of the Paint object. The following code will render as shown in Figure 4-4.

Paint paint = new Paint(); paint.setColor(Color.GREEN); paint.setStrokeWidth(100); canvas.drawPoint(199,201,paint);

Figure 4-4. Point drawn using a Paint object that has a stroke width set to 100; it doesn't look much like a point due to the exceptionally large stroke width. In many cases, a point would be a single pixel, having a stroke width of 1.

Was this article helpful?

0 0

Post a comment