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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:51:23+00:00 2026-06-05T00:51:23+00:00

I need a function which will generate three numbers so I can use them

  • 0

I need a function which will generate three numbers so I can use them as RGB pattern for my SVG.
While this is simple, I also need to make sure I’m not using the same color twice.
How exactly do I do that? Generate one number at a time with simple rand (seed time active) and then what? I don’t want to exclude a number, but maybe the whole pattern?
I’m kind of lost here.

To be precise, by first calling of this function I will get for example 218 199 154 and by second I’ll get 47 212 236 which definitely are two different colors. Any suggestions?

Also I think a struct with int r, int g, int b would be suitable for this?

Edit: Colors should be different to the human eye. Sorry for not mentioning this earlier.

  • 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-05T00:51:24+00:00Added an answer on June 5, 2026 at 12:51 am

    You could use a set to store the generated colors.
    First instanciate a new set.
    Then, every time you generate a color, look if the value is present in your set.
    If the record exists, skip it and retry for a new colour. If not, you can use it but dont forget to cache it in the Set after.
    This may become not performant if you need to generate a big quantity of colour.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a function that will generate 2 random numbers between x
I need a function which will check for the existing URLs in a string.
I need to write a TSQL user defined function which will accept a string
I need to implement a simp^le find function which will retrieve the 1st occurence
I often need to use a function which performs and action X is condition
I have a problem. I need to use the function which passes one argument
i'm a beginner to php. i need to use php function which process some
I am beginner in python, and I need to use some thirdparty function which
In my Application I need to call a function(Which update the valuesof textviews),I need
I need to be able to create a seperate function which creates a total

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.