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 8370983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:02:59+00:00 2026-06-09T14:02:59+00:00

I am trying to create a sprayer like effect when user touches the screen.

  • 0

I am trying to create a sprayer like effect when user touches the screen.

The user has the option of choosing a color, so the effect should be with the user’s color choice.

How to implement that spray effect?

  • 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-06-09T14:03:01+00:00Added an answer on June 9, 2026 at 2:03 pm

    You’d just use the common draw part on the canvas… then specify a radius to be drawn to. Then using the ‘random’ function, draw (x) number of dots inside the area of the circle you defined using the radius for as long as the user is pressing down. If you need more exact help please let me know.

    [Edit]
    This is going to be very pseudo-code. But you should very easily be able to make your code work from this.

    // This needs to happen in the down press on the canvas
    if(currentBrush == Brush.SPRAY_CAN){
        int dotsToDrawAtATime = 20;
        double brushRadius = 1.0; // This is however large they set the brush size, could be (1), could be whatever the max size of your brush is, e.g., (50), but set it based on what they choose
    
        for (int i = 0; i < dotsToDrawAtATime; i++){
            // Pick a random color for single dot to draw
            // Get the circumference of the circle (2*pi*brushRadius), based on the X/Y that the user input when they pressed down. Pick a random spot inside that area, and draw a single dot. As this is a for loop, it will happen 20 different times for this one occurrence.
        }
    }
    

    [Edit 2]
    If you’re going to use this, I would highly consider incorporating Iain_b’s way of doing this. Please take his post into consideration.

    [Edit 3]
    Here’s an image… maybe this will help you to understand…

    enter image description here

    [Edit 4]

    Here’s my code updated with lain_b’s added part to help simplify it.

    // This needs to happen in the down press on the canvas
    if(currentBrush == Brush.SPRAY_CAN){
        int dotsToDrawAtATime = 20;
        double brushRadius = 1.0; // This is however large they set the brush size, could be (1), could be whatever the max size of your brush is, e.g., (50), but set it based on what they choose
    
        for (int i = 0; i < dotsToDrawAtATime; i++){
            // Pick a random color for single dot to draw
            ...
    
            // Get the location to draw to
            int x = touchedX + Random.nextGaussian()*brushRadius;
            int y = touchedY + Random.nextGaussian()*brushRadius;
    
            // Draw the point, using the random color, and the X/Y value
            ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create a scaling layout for an Android application. The whole screen should
I am trying create a layout. There are several inner layouts that should like
I am trying create a small web application that allows a user to login
I am trying create the image enlargement effect when you hover your mouse over
I'm trying create a log specifically for logging user account activity. I created this
I'm trying create a simple audio stream server like a concept proof, but I'm
I'm trying create pagination on my page. The user can select the number of
I'm trying create simple application in C++. This application has to read from file
Trying to create a grails ant task that has other environments besides prod for
I'm trying to create a Temp Table that has a key field that auto

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.