A 30 g chameleon on a sun-and-shade branch must keep its body near 28 to 33 °C, stay hidden from a hawk and still catch flies. Dark skin warms it but shows it up; the elastic tongue works even when the muscles are cold.
The science
Heat budget. One lumped body (30 g, c = 3500 J/kg/K, surface area A = 10·mg0.688 cm² = 104 cm²): C dT/dt = Qsun + QLW + hA(Ta − T) + Qmet − Qevap. Solar gain α [Sdir fp A + Sdif A/2] with absorptance α = 0.50 (pale) to 0.80 (dark) and a projected-area fraction fp of 0.12 (edge-on) to 0.30 (broadside to the sun). Long-wave exchange is εσA[½(Tsky4 − T4) + ½(Ta4 − T4)] (ε = 0.95, clear sky 20 K colder than air). Convection h = 9 + 7√v W/m²/K. Metabolism 0.010 W · 2.2(T−25)/10; panting cooling 0.012 W/K above 33 °C.
Time constant. Linearised, τ = C / (hA + 4εσAT³ − dQm/dT), about 9 min here; the page checks the simulated relaxation against it, and the steady state against a bisection root of the budget.
Sun and canopy. Latitude −19°, equinox: sin h = cos φ cos H. Direct beam 1000·e−0.25/sin h·(1 − 0.85 cloud) W/m², diffuse (110 + 260 cloud) sin0.6h. Shade is found by tracing jittered rays from the animal to the sun through the visible leaves (each leaf a disc of 7 cm radius). The drawn shadows come from the same leaves.
Colour and detection. Skin colour state c (0 pale green, 1 dark) relaxes with τ = 25 s. Visible reflectance ρ = 0.42 − 0.30c is compared with the background by Weber contrast C = |ρ − ρb| / ρb. A raptor's detection range is r = rmin + (r0 − rmin) C/(C + 0.5) with rmin = 3 m, r0 = 40 m, and expected detections follow a search strip: ρhawk v 2r t. This is a contrast index, not a prediction for any real predator; no animal is harmed in the model.
Ballistic tongue. Energy stored in elastic collagen gives ½ m v² = e m with e = 90 J/kg, v = 13.4 m/s, independent of body temperature. Uniform acceleration over xl = 7 cm then coasting gives the flight time t = (d + xl)/v (35 ms at d = 0.4 m). A muscle-only tongue (power-limited, Q10 = 2.2) would scale as v ∝ √(Q10(T−30)/10). Capture needs the prey's lognormal escape latency (median 45 ms) to exceed the arrival time and a Rayleigh aiming error to be under the 1.2 cm hit radius.
Simplifications: one lumped body temperature (no gradients), constant ground and air temperature, achromatic contrast only (real chameleons also change hue), fixed prey size, no social display, territory or reproduction. Values are typical orders of magnitude for a 30 g chameleon, not a species fit. Flies and strikes are shown as real-time events whose rates follow simulated time. Models (animal, branch, leaves, fly, hawk) built with Blender and rendered with Three.js; nothing here is a forecast of any real animal's behaviour.