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.
IndexDiscussionExhibition › Processing remix
Pages: 1 2 
Processing remix (Read 6838 times)
Re: Processing remix
Reply #15 - Apr 13th, 2010, 9:16pm
 
Late night.... I'm just playing around with this off the top of my head...here we are:

[EDIT - just went in and modified as there was something that didn't make sense and made it run very inefficiently]

Code:
int angle = 0; 
int objectMode=1;
int currcol=214;
color backCol = color(200,200,255);


void setup()
{
size(300, 500, P2D);
colorMode(HSB, 360, 255, 255, 255);
background(backCol);
smooth();
noStroke();
fill(0, 102);
}

void draw()
{

// Draw only when mouse is pressed
if (mousePressed) {
angle += 10;
float val = cos(radians(angle)) * 20.5;
for (int a = 0; a < 360; a += 20) {
float xoff = random(0, 5)*cos(radians(a)) * val;
float yoff = random(0, 5)*sin(radians(a)) * val;
fill(currcol,random(255),random(255), random(100, 255));
drawShape(new PVector(mouseX+xoff,mouseY+yoff),objectMode,val);
}
currcol+=random(-20,20);
}
float ab=avgbright();
if(ab<165) filter(DILATE);
else if (ab>175) filter(ERODE);
}

void mouseReleased()
{
if (mouseButton==RIGHT) background(backCol);
}

void keyReleased()
{
switch(key)
{
case 'm':
objectMode++;
if (objectMode>3) objectMode-=3;
break;
}
}

void drawShape(PVector Pos, int mode, float param1)
{
switch (mode)
{
case 1:
rect(Pos.x,Pos.y,param1,param1);
break;
case 2:
ellipse(Pos.x,Pos.y,param1,param1);
break;
case 3:
float start=random(0,TWO_PI);
arc(Pos.x,Pos.y,param1,param1,start,random(start,TWO_PI));
break;
}
}

float avgbright()
{
float totalbright=0;
loadPixels();
for(int i=0; i<pixels.length; i++)
{
totalbright+=brightness(pixels[i]);
}
return totalbright/pixels.length;
}
Re: Processing remix
Reply #16 - Apr 19th, 2010, 1:07am
 
The code with the brightness seemed to "hang" every now and then. I've replaced that part with a periodic action.


Quote:
int angle = 0;
int objectMode=1;
int currcol=214;
color backCol = color(200,200,255);


void setup()

  size(300, 500, P2D);
  colorMode(HSB, 360, 255, 255, 255);
  background(backCol);
  smooth();
  noStroke();
  fill(0, 102);


void draw()


  // Draw only when mouse is pressed
  if (mousePressed) {
    angle += 10; 
    float val = cos(radians(angle)) * 20.5;
    for (int a = 0; a < 360; a += 20) {
     float xoff = random(0, 5)*cos(radians(a)) * val;
     float yoff = random(0, 5)*sin(radians(a)) * val;
     fill(currcol,random(255),random(255), random(100, 255));
       drawShape(new PVector(mouseX+xoff,mouseY+yoff),objectMode,val);
    } 
    currcol+=random(-20,20);
  } 
  float ab=avgbright();
  //if(ab<165) filter(DILATE);
  //if (ab>175) filter(ERODE);
  if (frameCount%200>100) filter(DILATE);
  else filter (ERODE);
}
void mouseReleased()
{
     if (mouseButton==RIGHT) background(backCol);
}

void keyReleased()
{
  switch(key)
  {
    case 'm':
     objectMode++;
     if (objectMode>3) objectMode-=3;
    break;
  }
}

void drawShape(PVector Pos, int mode, float param1)
  {
    switch (mode)
    {
    case 1:
     rect(Pos.x,Pos.y,param1,param1);
     break;
    case 2:
     ellipse(Pos.x,Pos.y,param1,param1);
     break;
    case 3:
     float start=random(0,TWO_PI);
     arc(Pos.x,Pos.y,param1,param1,start,random(start,TWO_PI));
     break;
    }
  }
  
float avgbright()
{
  float totalbright=0;
  loadPixels();
  for(int i=0; i<pixels.length; i++)
  {
    totalbright+=brightness(pixels[i]);
  }
  return totalbright/pixels.length;
}

Re: Processing remix
Reply #17 - Apr 19th, 2010, 9:28am
 
Quote:
The code with the brightness seemed to "hang" every now and then.


Did it? It was supposed to stop when the target brightness range was reached, and start up again when it went out of that range....seemed to work OK for me. But what you have done is interesting too....
Re: Processing remix
Reply #18 - Apr 28th, 2010, 4:39pm
 
My presentation is tomorrow, thank you all for your support. I plan to continue learning so this isn't the end of this project! Thank you again.
Re: Processing remix
Reply #19 - Apr 29th, 2010, 1:52pm
 
Good luck - let us know how it goes, and what interesting issues get discussed, where you are planning to take it next, and so on.
Re: Processing remix
Reply #20 - Apr 30th, 2010, 11:06am
 
Good luck form my side as well, although - coming to think of it - you should already have had your presentation. A pitty, not more people joint.
Re: Processing remix
Reply #21 - May 3rd, 2010, 11:17pm
 
And please feel free to keep going!  Smiley
Re: Processing remix
Reply #22 - May 11th, 2010, 2:22am
 
Yaah.. I noted this when I uses pd for my project.
Pages: 1 2