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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:01:42+00:00 2026-06-04T06:01:42+00:00

Above is an example image generated by using rand() to get random coordinates and

  • 0

lol

Above is an example image generated by using rand() to get random coordinates and add a constant to the pixel value at those coordinates. This is how it looks from a few thousand iterations. I’m using the rand() from stdlib.h in Mac OS X Lion, giving it time(NULL) as the seed.

You can clearly see the vertical lines, as if the ones with an odd x-coordinate have higher values than those with even x-coordinates.

How would I implement a better algorithm, or where can I find one that doesn’t have many dependencies? (I would prefer a header-only file).

Here’s the code (sorry it took me so long):

void generate(int iterations = 1) {
 for (unsigned int x = 0;x < (area * 4);++x) {
  map[rand() % area] += 1;
 }
 number a = min();
 number b = max();
 for (int i = 0;i < area;++i) {
  map[i] -= a;
  map[i] /= b;
 }
}

Map contains double-floats and is later turned into RGB values.

  • 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-04T06:01:44+00:00Added an answer on June 4, 2026 at 6:01 am

    Have you tried arc4random()? It provides much stronger and more uniform random values than rand().

    You could also try SecRandomCopyBytes(), which is part of Security.framework. This basically just reads from /dev/random.

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

Sidebar

Related Questions

This library rotates an image. http://jsfiddle.net/PjDnu/ In the above example, it does rotate, but
Code as reference: http://jsbin.com/aboca3/2/edit In this example above (thank you SLaks) I am truncating
I am trying to add an image into a document using WordML. I have
I'm having touble in making my random generated image (which is read as a
I am trying to print an ASP.NET Image using the example here . When
I cannot find a simple example about my question above: how can i detect
I am trying to find an example of placing an element above the Table
+2-1+18*+7-21+3*-4-5+6x29 The above string is an example of the kind of string I'm trying
I am creating URLs in my website as http://example.com/register/ http://example.com/login/ I am creating above
As the title suggest, I would like to do the above. Example below: library(stringr)

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.