int minMalformedLifeTime = (int)random(500,700);
int minLifeTime = (int)random(5,15);
int arteryTime = (int)random(400,500);
int malformedTime = arteryTime + minMalformedLifeTime;
float malformDiv = random(1,3);
float normalDiv = random(8,18);
float arteryDiv = random(24,50);
float bumpMul = 1.618033988;
float minDiam = random(0.5,2);
public int rootLifeTime = 0;
public bool endOfLife = false;
vein(int x,int y,float vx, float vy) {
location = new PVector(x, y);
velocity = new PVector(vx,vy);
diameter = random(24,35);
vein(vein parent, int rootLife) {
location = parent.location.get();
velocity = parent.velocity.get();
float area = PI*sq(parent.diameter/2);
float newDiam = sqrt(area/2/PI)*2;
diameter = random()>0.99 ? parent.diameter : newDiam;
parent.diameter = newDiam;
if (!endOfLife && diameter>minDiam) {
PVector bump = new PVector(random(-1, 1), random(-1, 1));
if(rootLifeTime < arteryTime) {
bump.mult(bumpMul/arteryDiv);
}else if(rootLifeTime < malformedTime){
bump.mult(bumpMul/malformDiv);
if (lifeTime > minMalformedLifeTime && random() < 0.04) {
for(int i = 0; i < 2; i++)
veins = (vein[]) append(veins, new vein(this,rootLifeTime));
bump.mult(bumpMul/normalDiv);
if (lifeTime > minLifeTime && random() < 0.014) {
veins = (vein[]) append(veins, new vein(this,rootLifeTime));
color back = color(187,187,187,255);
size(window.innerWidth, window.innerHeight);
seed = (int)random(0,99999);
colorv1 = color(black,black,black,11);
noiseOffset = random(0,999);
veins[0] = new vein(random(width/2 - 60,width/2 + 60),height+50,0,-1);
for(int i = 0; i <30; i++)
for (int i=0;i<veins.length;i++) {
PVector loc = veins[i].location;
float diam = noise(veins[i].rootLifeTime/400 + noiseOffset)*(veins[i].diameter)*3;
ellipse(loc.x, loc.y, diam, diam);
if(deadCount == veins.length){
console.log("All done.");
int mx = (int)random(5,20);
text("MRA - " + " patient ID : "+seed +" - " + day() + "/" + month() + "/" + (""+year()).substring(2,4) + " - FRM " +(int)random(1,mx) + "/" + mx,width - 830,height - 60,800,40);
text("loc "+random(100,1000) + "; " +random(100,1000) + "; " + random(100,1000) + " (left temporal lobe)",width - 830,height - 30,800,800);