Herbert Spencer
YaBB Newbies
Offline
Posts: 8
Chile
Re: quicktime.std.StdQTException
Reply #8 - Oct 2nd , 2008, 11:00pm
I re-installed quicktime but the problems persists. This is my code: import processing.video.*; MovieMaker mm; Circulo[] c; boolean gen = false; boolean margen = true; boolean rec = true; void setup(){ size(720, 480); mm = new MovieMaker(this, width, height, "drawing.mov", 30, MovieMaker.ANIMATION, MovieMaker.HIGH); smooth(); colorMode(HSB, 100); c = new Circulo[0]; } void draw(){ background(0, 0, 100); for(int i = 0; i < c.length; i++){ c[i].draw(); } if(gen) calcNew(); if(rec) mm.addFrame(); } void calcNew(){ boolean good = true; float x = random(width); float y = random(height); for(int i = 0; i < c.length; i++){ float d = dist(x, y, c[i].x, c[i].y); if(d <= 1 + c[i].diam/2){ good = false; } } if(good){ c = (Circulo[])expand(c, c.length + 1); c[c.length - 1] = new Circulo(x, y, c.length-1); println("nuevo circulo a las "+millis()+" -- hay "+c.length+" círculos en total"); } } void mouseReleased(){ c = (Circulo[])expand(c, c.length + 1); c[c.length - 1] = new Circulo(mouseX, mouseY, c.length-1); } void keyPressed(){ if(key == ' '){ gen = !gen; } if(key == 's' || key == 'S'){ setup(); } if(key == 'b' || key == 'B'){ margen = !margen; } if(key == 'g' || key == 'G'){ todosCrecen(); } if(key == 'r' || key == 'R'){ rec = !rec; if (rec) println("grabando"); if(!rec) println("grabación pausada"); } if(key == 'q' || key == 'Q'){ mm.finish(); println("fin"); exit(); } } void todosCrecen(){ for(int i = 0; i < c.length; i++){ c[i].growing = true; } } class Circulo{ float x, y; float diam; boolean growing; int id; color col; Circulo(float x, float y, int id){ this.x = x; this.y = y; diam = 0; growing = true; this.id = id; col = color(0, 0, 40, 50); } void draw(){ if(margen)bordes(); fill(col); noStroke(); ellipse(x, y, diam, diam); check(); if(growing) { grow(); } } void check(){ int topes = 0; for (int i = 0; i < c.length; i++){ if(i != id){ float d = dist(x, y, c[i].x, c[i].y); if(d <= diam/2 + c[i].diam/2){ repel(c[i]); topes ++; col = color(hue(col)+(float)topes/32, saturation(col)+(float)topes/5, 40, alpha(col)+(float)topes/7); if (topes == 2){ growing = false; } } } } } void repel(Circulo otro){ float traslape = (diam/2 + otro.diam/2) - dist(x, y, otro.x, otro.y); pushMatrix(); translate(x,y); float angulo = atan2(otro.x, otro.y); popMatrix(); x += (cos(angulo) * traslape) * 0.5; y += (sin(angulo) * traslape) * 0.5; otro.x += (cos(angulo-PI) * traslape) * 0.5; otro.y += (sin(angulo-PI) * traslape) * 0.5; fill(0, 0, 100, 70); stroke(0, 0, 100, 70); ellipse(x, y, diam/5, diam/5); line(x,y, otro.x, otro.y); diam -= 0.01; } void bordes(){ x = constrain(x, diam/2, width - (diam/2)); y = constrain(y, diam/2, height - (diam/2)); } void grow(){ if(growing){ //float dif = maxDiam - diam; //diam += dif / 50; diam += 0.2; } } float[] distancias(Circulo[] todos){ float[] distancia = new float[todos.length]; for(int i = 0; i < todos.length; i++){ distancia[i] = dist(x,y, todos[i].x, todos[i].y); } return distancia; } float getMax(float[] nums){ float m = 0; for(int i = 0; i < nums.length; i++){ if(m < nums[i]) m = nums[i]; } return m; } float getMin(float[] nums){ float m = width * height; for(int i = 0; i < nums.length; i++){ if(m > nums[i]) m = nums[i]; } return m; } }