InteractiveStarryNight
InteractiveStarryNight copied to clipboard
How to calculate the field of an image?
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?
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));
}
man how did you make the field.txt can you please elaborate?
DomonJi , would you please provide a little details on how to generate the field.txt?