What follows below is more than what you're asking for (from what I can tell), but it so happens I was just playing around with this same thing.
The circle produced by this code is rendered with heavy Perlin perturbations. Un-comment the line that sets the Perlin variable to = 1 to see the unadulterated circle.
The code allows for the circle to be produced using either pixels or points. I'm using points here with an alpha channel. It takes a few seconds for the figure to begin to appear. Turn up the color values if it's too dark for your monitor.
It's a rough sketch, not intended as exemplary. But it should have what you need, and then some.
- // Study: drawing a form with pixels, without scanning the full pixel array.
- // R.A. Roberton, 2012
- float centerX, centerY, radialX, radialY, theta, rad;
- color paint;
- float shade;
- float perlinX, perlinY;
- void setup() {
- // size(600, 400, P2D);
- size(screen.width, screen.height, P2D);
- background(0, 0, 5);
- noStroke();
- centerX = width/2;
- centerY = height/2;
- loadPixels();
- frameRate(200);
- }
- void draw() {
- for (int i = 0; i < 100; i++) {
- // rad = 150;
- rad = random((height * .3) - cos(theta) * 5, height * .3);
- // theta = random(2*PI);
- theta += .1; // Play with me! Default .1 .
- radialX = centerX + sin(theta) * rad * perlinX;
- radialY = centerY + cos(theta) * rad * perlinY;
- radialX = constrain(radialX, 0, width - 1); // Keep pixArray in bounds.
- radialY = constrain(radialY, 0, height - 1);
- // Optional distance map. Lots of possibilities with map values.
- // float shade = dist(centerX, centerY, radialX, radialY);
- // paint = color(int(map(shade, 0, 255, -100, 255)), 0, 0, 25);
- // noiseDetail(4, .5);
- perlinX = noise(sin(theta) * 51.5) * 1.75; // Optional Perlin perturbation.
- perlinY = noise(cos(theta) * 51.3) * 1.75;
- // perlinX = 1; perlinY = 1; // Use this to cancel perlin.
-
- // pixels[int(radialX) + (int(radialY) * width)] = paint;
- // updatePixels();
-
- stroke(55, 0, 200, random(25)); // Use point instead of pixels for alpha.
- // stroke(paint);
- point(radialX, radialY);
-
- println(frameRate);
- }
- }