I tried to take the challenge to make my own implementation, knowing nothing about the subject at all. It looks nothing like the images you showed. Then I noticed that they are using Perlin noise, and I was just using a simple random generator... Basically using the method AvengerDr suggested, drawing a circle with various displacements, deformations. (Basically drawing a jagged oval rather than a jagged circle.)
Edit: Looking at the picture you posted, it looks like they are not only using Perlin noise, but using spherical coordinates too. (Mapping to a sphere.)
On the other hand, looking at the picture from the answer in the thread that you posted a link to, the initial shapes looks very much like what I get with my attempt.
Picture prom the post:
Code (quick and dirty...)
- (void)drawRect:(NSRect)dirtyRect {
[[NSColor blackColor] set];
[NSBezierPath fillRect:dirtyRect];
[[NSColor whiteColor] set];
double centerX = [self bounds].size.width / 2.0f;
double centerY = [self bounds].size.height / 2.0f;
double x = 0.0f;
double y = 0.0f;
double radius = 100.0f;
double delta = 0.05f;
double randomValue = 0.0f;
randomValue = (double)arc4random_uniform(10000) / 10000.0f;
double scaleX = (randomValue + 0.1f);
randomValue = (double)arc4random_uniform(10000) / 10000.0f;
double scaleY = (randomValue + 0.1f);
randomValue = (double)arc4random_uniform(10000) / 10000.0f;
double clampToValue = randomValue * 200.0f;
NSBezierPath *circle = [NSBezierPath bezierPath];
BOOL isFirst = YES;
double deviationRadius = 0.0f;
for (double theta = 0.0f; theta < 2 * M_PI; theta += delta) {
randomValue = ((double)arc4random_uniform(10000) / 10000.0f) - 0.5f;
deviationRadius += randomValue * 100.0f;
if ((clampToValue - (radius - deviationRadius)) < 0.0f) {
deviationRadius += clampToValue;
}
x = sin(theta) * (radius + deviationRadius) * scaleX + centerX;
y = cos(theta) * (radius + deviationRadius) * scaleY + centerY;
if (isFirst) {
[circle moveToPoint:NSMakePoint(x, y)];
isFirst = NO;
}
else {
[circle lineToPoint:NSMakePoint(x, y)];
}
}
[circle closePath];
[circle fill];
// [circle stroke];
}