sonar-reasoning-pro-high LMArena Search Arena 24K
code a single p5.js script that simulates water
- User
code a single p5.js script that simulates water
- Assistant
P5.js Water Simulation
Here's a complete P5.js script that simulates water with a realistic ripple effect. This simulation uses a physical model where disturbances in the water propagate outward as waves:
// Water ripple simulation let cols, rows; let current; // Current water state let previous; // Previous water state let damping = 0.97; // Energy loss (lower = more loss) function setup() { createCanvas(windowWidth, windowHeight); pixelDensity(1); // For consistent behavior across displays cols = width; rows = height; // Create 2D arrays for water height current = new Array(cols).fill(0).map(() => new Array(rows).fill(0)); previous = new Array(cols).fill(0).map(() => new Array(rows).fill(0)); } function mouseDragged() { // Create splash where mouse is dragged if (mouseX > 1 && mouseX < cols - 2 && mouseY > 1 && mouseY < rows - 2) { previous[mouseX][mouseY] = 500; // Add energy at mouse position } } function mousePressed() { // Create splash where mouse is clicked if (mouseX > 1 && mouseX < cols -
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.