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.
Page Index Toggle Pages: 1
no drawing (Read 751 times)
no drawing
Feb 28th, 2006, 2:59am
 
This may be somewhere between syntax and program forums:

I am having a problem getting my code to draw to screen. I am importing old code from alpha version, but I have reworked it to what I mostly feel are current syntax protocols. I am using mac OSX, regular P103 download; do I need to install something else? No exceptions or errors are thrown at run. Any way, here is the code:

void setup() {
 
 size(600,600);
 smooth();
 background(255);
 
}
/*
void loop(int bang,int buck,int blast){
 bang=abs(mouseY-pmouseY);
 buck=abs(mouseX-pmouseX);
 
 if(bang>buck){
   blast=bang;
 }else{
   blast=buck;
 }
 
 switch(key){
   
   case 'a':
   
   translate(mouseX,mouseY);
   fill(220,60*random(1,4),0,100-(blast));
   ellipse(0,0,0,blast);
   
   break;
 }
}
*/
void loop(){
 fill(0,0,0,50);
 ellipse(mouseX,mouseY,0,20);
}
 

The commented out sections don't draw, the loop not so commented out doesn't draw, and the only thing that does seem to draw is something like this program example with no other classes:

ellipse(50,50,0,50);
Re: no drawing
Reply #1 - Feb 28th, 2006, 3:13am
 
very first item in the FAQ for "changes between releases"
http://processing.org/faq/changes.html
Re: no drawing
Reply #2 - Feb 28th, 2006, 5:46am
 
Yes, thank you. However, the program when run as the following still doesn't draw.

void setup() {
 
 size(600,600);
 background(255);
 
}

void draw(int bang,int buck,int blast){
 bang=abs(mouseY-pmouseY);
 buck=abs(mouseX-pmouseX);
 
 if(bang>buck){
   blast=bang;
 }else{
   blast=buck;
 }
 
 switch(key){
   
   case 'a':
   
   translate(mouseX,mouseY);
   fill(220,60,0,100);
   ellipse(0,0,5,blast);
   
   break;
 }
}

 
Re: no drawing
Reply #3 - Feb 28th, 2006, 7:36am
 
You made need to include the switch statement inside of a keyPressed or keyReleased call.
Re: no drawing
Reply #4 - Feb 28th, 2006, 7:59am
 
Oops let me expand... and actually looking actually reading the code... here are the problems I see.

void draw(int bang,int buck,int blast)
there are no parameters for draw... that i know of unless theyre on documented but since I havent seen it anywhere else in the discourse Im going to assume thats there arent.

You should read a few of the examples to become familar with the language structure. Anyhow I rewrote the code and here it is.

int bang, buck,blast;
boolean drawEllipse;

void setup() {
 size(600,600);
 background(255);

 drawEllipse = false;  
}

void draw(){
 bang=abs(mouseY-pmouseY);
 buck=abs(mouseX-pmouseX);

 if(bang>buck){
   blast=bang;
 }
 else{
   blast=buck;
 }

 if(drawEllipse) {
   translate(mouseX,mouseY);
   fill(220,60,0,100);
   ellipse(0,0,5,blast);
 }
}

void keyPressed() {
 switch(key){

 case 'a':    
   drawEllipse = true;
   break;
 }
}

ps: written in 0105 beta for OSX and it saves changes!
Re: no drawing
Reply #5 - Feb 28th, 2006, 5:45pm
 
YES! We are finally drawing.
But a quick optimiztion question if anybody is still listening. Is the point of the switch statement to not need to check an if statement? Is it the same thing? OR how is while(drawEllipse==true) diferent from the above?
Re: no drawing
Reply #6 - Feb 28th, 2006, 5:48pm
 
Oh yeah, almost forgot. . . the >break;< part doesn't work, it won't stop drawing.
Page Index Toggle Pages: 1