[Creating Library] Using specific methods (rect, background, stroke...) in a new class

DoxDox
edited April 2017 in Questions about Code

Hello everybody,

Note : Processing Version : 2.0.2 IDE : Eclipse

I have a problem concerning the way to use methods ( rect(), stroke(), fill(), background() ... ) from PGraphics library in a new class. To make it clear, below is an example :

package processing.MyNewClass;
import processing.core.*;
// Class MyNewClass inherited from PGraphics
public class MyNewClass extends PGraphics {
private String type; // Example of field;

// Constructor
public MyNewClass(String _type )
{ type=_type;
   PApplet.println(type); // Just to check -> Ok
// I want to draw a rectangle
   fill(255);
   rect(10,10,10,10); // Damn! It does not work !
}

}

So I have created this Library in Eclipse with built path for the core.jar (without error) and imported it into Processing. There is no execution error excepting that no rectangle is displayed (whereas println() works). Note that the issue is the same for methods stroke(), background() ... Compilation Errors occurs by making an extended PApplet class instead of a PGraphics Class.

If someone has an idea of what could be the problem, that would be fine.

Best Regards,

Dox

Tagged:

Answers

Sign In or Register to comment.