PDA

View Full Version : Pomegranate Fractal



freeskier89
January 3rd, 2009, 02:25 AM
Alright this is my last submission for a little bit lol. I just started playing with fractals again.



_root.createEmptyMovieClip("container",1);
var d = 1;
var radius = 5;
wind = 0;
var circles = [];
var MAXITER = 4;
function addCircle(x, y, scale) {
var mc = container.attachMovie("Circle", "circle"+d, d++);
mc._x = x;
mc._y = y;
mc.vx = Math.random()-.5;
mc.vy = Math.random()-.5;
mc.t = 0;
mc._xscale = mc._yscale=scale;
mc.colorobj = new Color(mc.coloroverlay);
circles.push({x:x, y:y, r:.25*scale, mc:mc});
mc.setHue(.3);
return mc;
}
MovieClip.prototype.setHue = function(x) {
//x = 0 - 1
x = Math.max(x*2*Math.PI, 0.01);
r = 128+128*Math.cos(x);
g = 128+128*Math.cos(x+Math.PI*2/3);
b = 128+128*Math.cos(x+Math.PI*4/3);
var hex = r << 16 | g << 8 | b;
this.colorobj.setRGB(hex);
};
var N = 0;
var startpoint = 0;
function iterate0() {
N++;
var n = circles.length;
for (i=startpoint; i<n; i++) {
var base = circles[i];
base.mc.children = [];
var t0 = xt/500*2*Math.PI*N;
var t = t0;
for (var i2 = 0; i2<3; i2++) {
t += Math.PI*2/3;
var c = addCircle(base.x+base.r/2*Math.cos(t), base.y+base.r/2*Math.sin(t), base.r*1.6);
c.setHue(N/10);
base.mc.children.push(c);
}
}
startpoint += Math.pow(3, N-1);
}
function iterate() {
N++;
var n = circles.length;
lim = 1;
for (i=0; i<n-Math.pow(3, MAXITER); i++) {
if (i>lim) {
N++;
lim += Math.pow(3, N);
}
var base = circles[i];
var t = xt/100*N*N;
for (var i2 = 0; i2<3; i2++) {
t += Math.PI*2/3;
var refcircle = base.mc.children[i2];
refcircle._x = base.mc._x+base.r/2*Math.cos(t);
refcircle._y = base.mc._y+base.r/2*Math.sin(t);
}
}
}
var xt = 0;
onEnterFrame = function () {
onMouseMove();
xt += 1;
};
function init() {
circles = [];
N = 0;
_root.createEmptyMovieClip("container",1);
addCircle(250, 150, 500).setHue(0);
for(var i =0;i<MAXITER;i++){
iterate0();
}
}
init();
//iterate();
onMouseMove = function () {
N = 0;
iterate();
};

>Preview Here< (http://ffiles.com/flash/fractals/pomegranate_fractal_2177.html)

kirupa
January 3rd, 2009, 03:04 AM
Added to list :hugegrin:

Pasquale
January 3rd, 2009, 10:10 AM
Holy frick man, you make some awesome stuff. Keep them coming :o

egoldy
January 3rd, 2009, 01:06 PM
nice work. I like this one. :)

kevin416
January 3rd, 2009, 01:46 PM
One of the groups of 3 circles is not rotating like the rest. Its one of the ones that are about 1cm in diameter.

pduquesnoy
January 12th, 2009, 05:17 PM
One of the groups of 3 circles is not rotating like the rest. Its one of the ones that are about 1cm in diameter.

Looks like line 53 should be
if(i>=lim){
(added the equal sign)

that fixed it for me : )

...Doh!
Upon further review, that only fixed it when there's a MAXITER of 2 : (

-Paul

saxx
January 13th, 2009, 02:14 AM
Haha woah that's kind of trippy :D