Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 844481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:17:32+00:00 2026-05-15T06:17:32+00:00

I am trying to draw a cupola circles at random positions in an Android

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:17:33+00:00Added an answer on May 15, 2026 at 6:17 am

    That code doesn’t even compile. What is new Paint; for instance?

    I suggest you log your arguments to drawCircle to make sure you draw them on different locations. If Math.Random for instance is a field, it would change in between reads, which would put the circles on top of each other.

    If you intended to write Math.random() the error is that Math.random() returns a value between 0 and 1. You may want to use

    Random r = new Random();
    // your loop
        int x = r.nextInt(100);
        int y = r.nextInt(100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to draw items that end of them is an * character in
I'm trying to draw text without antialiasing on a canvas in Android. The font
Im trying to draw a globe in Android, I use OpenGL for this. However
I'm trying to draw simple 2d things in my JSP application. I found this
I'm trying to draw a nine patch onto a Canvas object on the Android.
I am trying draw an random graph which display on imageview, I try this
I am trying to draw in a web worker using html5 canvas. The worker
I'm trying to draw custom UI (a path in this case) on top of
I am trying to draw over a canvas by clicking and dragging the mouse.
basically i am trying to draw the path i.e road path. for that i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.