We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › how to fade in or grow in object
Poll Poll
Question: how to fade in or grow in object?



« Created by: holger on: Jun 2nd, 2009, 1:56am »

Pages: 1 2 
how to fade in or grow in object? (Read 2206 times)
Re: how to fade in or grow in object?
Reply #15 - Jun 3rd, 2009, 11:46pm
 
hi!
..well, i don't see the difference right away...?
anyway, thanks for keeping interest!...
here is what i made of it till now, mixing different portrait photos with a timer, looks quite interesting.
i tried to make the point a bit alpha but, shure, these are many point over each other...

Code:
PImage img,a;
int radius;
int speed = 5;
int maxRadius;
int MIN_RADIUS = 1;
int MAX_RADIUS = 97;
int CIRCLE_NB = 8;  
PVector[] toGrow = new PVector[CIRCLE_NB];
boolean bRandom = true; // Set to true for a variant!

float swb=0;
int ws;
float rand;
float h,cx1,cy1,cx2,cy2;
float num;
int startingTime;
String pictures[] = {
   "a.jpg","b.jpg","c.jpg","d.jpg","e.jpg","f.jpg"}; //
void setup()
{
 
 size(800, 600);
 startingTime = millis();
 img = loadImage( pictures[int(random(pictures.length))] );
 //img = loadImage("01.jpg");
 noStroke();
 smooth();
 background(0);
 frameRate(100);
 for (int i = 0; i < CIRCLE_NB; i++)
 {
   toGrow[i] = new PVector();
 }
 if (!bRandom)
 {
   maxRadius = MAX_RADIUS * 2;
 }
}

void draw()
{
 int seconds = (millis() - startingTime)/100;
 swb = random (0,1);
 if (swb<0.5){
   ws=(#ffffff);
 }
 if (swb>0.5){
   //ws=(#ffb4bd); // light pink
  ws=(#000000); // light purple
 }
 
 if (seconds == 20) { ////////////////////////// TIMER
 img = loadImage( pictures[int(random(pictures.length))] );
 startingTime = millis();
 }
//  image(img, 0, 0);
  radius += speed;
 for (int i = 0; i < CIRCLE_NB; i++)
 {
   PVector v = toGrow[i];
   color pix = img.get(int(v.x), int(v.y));
   //stroke (ws,random(255));
   //strokeWeight(random(1,2));
   fill(pix,111); ///////////////////////////////////////////////////////////////// , random(15)
   //ellipse(v.x, v.y, radius, radius);
   ellipse(v.x, v.y, radius / 2, radius / 2);
   //ellipse(v.x, v.y, radius / 3, radius / 3);
   //ellipse(v.x, v.y, radius / 4, radius / 4);
 

 }
 if (radius >= maxRadius)
 {
   GetPoints();
   radius = 0;
 }
}


/////////////////////////////
void GetPoints()
{
 if (bRandom)
 {
   maxRadius = int(random(MIN_RADIUS, MAX_RADIUS - MIN_RADIUS));
 }
 else
 {
   if (maxRadius > MIN_RADIUS / 2)
   {
maxRadius--;
   }
 }
 for (int i = 0; i < CIRCLE_NB; i++)
 {
   PVector v = toGrow[i];
   v.x = random(maxRadius / 4, img.width - maxRadius / 2);
   v.y = random(maxRadius / 4, img.height - maxRadius / 2);
 }
}


Re: how to fade in or grow in object?
Reply #16 - Jun 4th, 2009, 1:01am
 
There is no difference, code is just simpler to understand by using Processing's facilities... Smiley

And your changes looks good. Just an advice: when checking time, you should test with > instead of ==, in case something goes wrong. Even if with 1s granularity, chance of missing the target is slim.

And transparency cannot work because the circles grow in place, the overlay quickly becomes opaque.
Re: how to fade in or grow in object?
Reply #17 - Jun 4th, 2009, 1:37am
 
ah! i was already wondering why it chooses the same image so often when working with very much images, so it was just running over it! thanks!Smiley
Pages: 1 2