Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

comments - Processing 'It looks like you're mixing "active" and "static" modes.'

Processing keeps giving me this error when I run it even though it is just a print command. When I delete the comment block it works fine. Here's the code:

/*
    float[] cortToPolar(int xcorr, int ycorr) {
    float returns[] = new float[2];
    returns[0]= degrees(tan(ycorr/xcorr));
    returns[1]= sqrt(pow(xcorr,2)+pow(ycorr,2));
    return returns;
}

float lawCos(int a, int b, int c) {
  return degrees(
     acos(
     (pow(a,2)+pow(b,2)-pow(c,2))/
       (2*a*b)
     )
  );
}
*/
print(0); 

Why doesn't it like my comment?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Processing runs in two separate modes: static or active

Static mode simply means it's a list of instructions/calls to existing functions (e.g. draw a bunch of lines then exit)

Active mode uses the setup() and draw() calls and runs continuously (gets updated every 'frame').

Even you though you are using comments, you are defining methods(cortToPolar,lawCos) inside those comments and Processing encounters those which is why you're getting the error.

Use the setup() call to do your print:

/*
    float[] cortToPolar(int xcorr, int ycorr) {
    float returns[] = new float[2];
    returns[0]= degrees(tan(ycorr/xcorr));
    returns[1]= sqrt(pow(xcorr,2)+pow(ycorr,2));
    return returns;
}

float lawCos(int a, int b, int c) {
  return degrees(
     acos(
     (pow(a,2)+pow(b,2)-pow(c,2))/
       (2*a*b)
     )
  );
}
*/
void setup(){
  print(0);
}

In active mode you can control frame updating using noLoop() and loop() in conjunction with draw()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...