InteractiveStarryNight icon indicating copy to clipboard operation
InteractiveStarryNight copied to clipboard

How to calculate the field of an image?

Open LiuzcEECS opened this issue 9 years ago • 3 comments

Hello, I'm trying to write a javascript implementation and I'm wondering how to calculate the flow_field? Would you please share your method?

LiuzcEECS avatar Dec 25 '16 16:12 LiuzcEECS

Sorry, I didn't notice this issue😂 Here is the codes

void drawField(float x, float y, PVector v) {
  int column = int(constrain(x/resolution, 0, cols-1));
  int row = int(constrain(y/resolution, 0, rows-1));
  for (int i=-affectRadius; i<=affectRadius; i++) { // Your brush's radius
    for (int j=-affectRadius; j<=affectRadius; j++) {
      if (i*i+j*j<affectRadius*affectRadius) {
          // Change the vector of every unit in radius
          tempField[column+i][row+j].add(v).mult(0.9); 
      }
    }
  }
}

void onMouseDrag() { // Caculate the direction of mouse and apply drawField
    PVector direc = new PVector(mouseX-pmouseX, mouseY-pmouseY).normalize();
    drawField(pmouseX, pmouseY, direc.mult(force));
  }

DomonJi avatar Feb 12 '17 02:02 DomonJi

man how did you make the field.txt can you please elaborate?

dackdel avatar Mar 22 '19 11:03 dackdel

DomonJi , would you please provide a little details on how to generate the field.txt?

AndrewGe avatar Jun 06 '20 17:06 AndrewGe