Drawing random circles
Posted
by ViktorC
on Stack Overflow
See other posts from Stack Overflow
or by ViktorC
Published on 2010-06-15T08:09:02Z
Indexed on
2010/06/15
8:12 UTC
Read the original article
Hit count: 269
android
I am trying to draw a cupola circles at random positions in an Android application. I draw them on a bitmap and then draw that bitmap on the canvas. This is the function where a draw the circles:
private void drawRandomCircles(int numOfCircles) {
Canvas c = new Canvas(b);
Paint cPaint = new Paint;
cPaitn.setColor(Color.RED);
for(int i = 0; i < numOfCircles; i++) {
int x = Math.Random % 100;
int y = Math.Random % 100;
c.drawCircle(x, y, 20, cPaint)
}
}
The Bitmap b is global. And after calling this function I just draw the bitmap in the onDraw method. Now the problem is that I only get one circle drawn on the screen, no matter the size of numOfCircles.
Any clue what is happening here?
© Stack Overflow or respective owner