We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here is my code, i need to achieve redraw by mousePress. But i want to write the code that when y=300, it code will redraw automatically. By the way, i println my code in gcode writing way, when the code start, it will show in the black window. It is helpful to check each value of x and y
`int x,y,e; void setup(){ x=5; y=0; size(500,500); }
void draw(){ background(255,255,255); y=y+1;
if (y>300){ y=300; point(x,y); }
String[] gcode=new String[6];
gcode[0]="X"; gcode[1]=str(x); gcode[2]="Y"; gcode[3]=str(y); gcode[4]="E"; gcode[5]=str(e);
String joinedgcode = join(gcode,""); println(joinedgcode);
e+=1; }
void mousePressed() { x += 1; y=0; redraw(); }`
Answers
i don't know why, the code i posted doesn't show in the wright format here
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text#latest
The redraw() in mousePressed() is useless here, because draw() will just redraw the sketch area 60 times per second, anyway.