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
noStroke(); (Read 1335 times)
noStroke();
Sep 8th, 2009, 8:58pm
 
Why doesn't processing allow you to set noStroke(); within an object?

How else can I achieve no stroke? strokeWeight(0); gives me one pixel.

Thanks,

Joe
Re: noStroke();
Reply #1 - Sep 9th, 2009, 1:59am
 
What do you call "an object"? Can you give a simple example?
Re: noStroke();
Reply #2 - Sep 9th, 2009, 7:36am
 
Code:

void setup() {

}
void draw() {

}

class Object {
   Object {
       noStroke(); //Throws an error
   }

}
Re: noStroke();
Reply #3 - Sep 9th, 2009, 7:44am
 
just move it before you start to draw.
Object1 o1 = new Object1();

void setup() {
 size(200, 200);
}

void draw() {
 background(204);
 o1.update();
}

class Object1 {

 Object1 () {  

 }

 void update() {
noStroke();
fill(#ff0000);
ellipse(100,100,40,40);
 }
}
Re: noStroke();
Reply #4 - Sep 9th, 2009, 9:45am
 
As Cedric said.
Your sample is problematic: you use Object as class name, but it already exists in Java (it is a fundamental class!). Beside, your constructor is lacking parentheses. The error doesn't come from the noStroke().
Re: noStroke();
Reply #5 - Sep 9th, 2009, 4:39pm
 
I was just trying to save time by writing that temporary document. Here is what I'm working on.

Code:
int i = 0;
int value = 0;

void setup() {
size(640, 480);
background(0);
smooth();
colorMode(RGB);
color blue = color(0, 0, 153, 60);
fill(blue);
}

void draw() {

}

void mouseClicked() {
float tempRandX = random(mouseX-5, mouseX+5);
float tempRandY = random(mouseY-5, mouseY+5);
int(tempRandX);
int(tempRandY);

Circle newCirc = new Circle(tempRandX, tempRandY);
}

class Circle {
float xpos;
float ypos;

noStroke();

Circle(float tempRandX, float tempRandY) {
xpos = tempRandX;
ypos = tempRandY;
float randSize = random(30, 100);
ellipse(xpos, ypos, randSize, randSize);
}
}



noStroke throws an 'unexpected token' error
Re: noStroke();
Reply #6 - Sep 9th, 2009, 4:41pm
 
Also, I'm aware that you can insert noStroke(); into the constructor function. But what if I want to generate another class called triangle, and one called square. Both with different stroke properties.
Re: noStroke();
Reply #7 - Sep 9th, 2009, 10:41pm
 
you should read this tutorial about OOP. cause i believe you didnt totally understand how to use them. You are missing the functions where you draw, update, move etc. your object . You also have to call them in your main draw function...

http://processing.org/learning/objects/

Re: noStroke();
Reply #8 - Sep 9th, 2009, 11:14pm
 
Quote:
class Circle {
 float xpos;
 float ypos;
 
 //noStroke();
 //it's not a variable, don't put it here!
 
 // here is your constructor method:
 Circle(float tempRandX, float tempRandY) {
   xpos = tempRandX;
   ypos = tempRandY;
   float randSize = random(30, 100);
   // ellipse(xpos, ypos, randSize, randSize);
   // don't draw here!
 }
 
 better add this method to draw your object:
 void draw() {
   noStroke();
   ellipse(xpos, ypos, randSize, randSize);
 }
 
}


Then, call newCirc.draw(); when you want to display the circle.
Page Index Toggle Pages: 1