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 & HelpPrograms › pbs with screen size sketch
Page Index Toggle Pages: 1
pbs with screen size sketch (Read 512 times)
pbs with screen size sketch
Sep 11th, 2007, 1:48pm
 
Hi i'm actually playing around at work with some examples.

Actually i've end up with this code but i don't understand why it don't work as expected when i create the sketch with screen.width and screen.height size.

When i use a smaller size it seems to work but when i go on a bigger size the background is gray and the smooth() functions doesn't seems to work.

Here's the code.
Sorry it's messy but i'm @work.

Quote:


float r;
float theta;
float theta_vel;
float theta_acc;
int sized=2;
PFont font;
char[] val;

void setup(){
 size(screen.width,screen.height);
 //size(400,200);
 frameRate(60);
 background(0);
 strokeWeight(1);
 smooth();
 noCursor();
 font=loadFont("CourierNewPSMT-72.vlw");
 theta=0.0f;
 theta_vel = 0.0f;
 theta_acc = 0.001f;
 r = 100.0;
 //noLoop();
}


void draw(){
 //background(0);
 textFont(font,12);
 text("r :"+r, 10, 15);
 //fill(0,20);
 //rect(0, 0, 150, 20);
   
 
 //r = random(50,width);
 // Create an alpha blended background
 //fill(255, 40);
 //rect(0,0,width,height);


 // Get a noise value based on xoff and scale it according to the window's width
 noiseDetail(8, 0.75);
 //float n = r*cos(random(noise(xoff)*width));
 //float m = r*sin(random(noise(yoff)*height));
 translate(mouseX, mouseY);
 rotate(theta);
 float n = r * cos(theta);
 float m = r * sin(theta);
 // With each cycle, increment xoff
 //xoff += xincrement;
 //yoff += yincrement;
 //scale(mouseX/random(126,128));
 // Draw the ellipse at the value produced by perlin noise
 //fill(random(0,50), random(n), random(m),random(20,255));

//switching two colors according to odd and even seconds
 int sec = second();
  switch(sec%2) {
    case 0:
      stroke(180,20);
      fill(random(0,2000),random(30,100));
      break;
    case 1:
      stroke(#FFD024,20);
      fill(#FFD024,90);
      break;
  }
 
 float randomsize= random(sized, sized*5);
 ellipse(n/2,m/2,randomsize,randomsize);
 line(0,0,n/random(16,32),m/random(8,24));
 noStroke(); // no stroke for the ellipse
 
 
 theta_vel += theta_acc;
 theta += theta_vel;
 
 //keyboard user interaction
 if (key == 's' || key == 'S'){
   exit();
   }
 
}

void keyPressed(){
 if (key == '+'){
   r += 1.0;
 }
 else if(key == '-') {
   r -= 1.0;
 }
 else if((key >= '0') && (key  <= '9')){
   println(key);
 }
}

void mousePressed() {
 if (mouseButton == RIGHT){
   background(0);
 }
}

void mouseDragged() {
 if (mouseButton == LEFT){
   redraw();
 }
 }




Cheers.
Re: pbs with screen size sketch
Reply #1 - Oct 1st, 2007, 5:31pm
 
Hi. I tried your code on my computer (PC-WinXP) and it just works fine at the screen's dimensions... :-)
Re: pbs with screen size sketch
Reply #2 - Oct 2nd, 2007, 3:35pm
 
Hi nikoony,

Thx for the anwser and tested it !
I've identify the problem.

It's the lack of ram of my work computer, only 128 ram and 8mo video memory :]. That's ok because it's not for making graphic design, but allow me to enhance my knowledge while working Smiley

Thx btw.
Page Index Toggle Pages: 1