I always forget this fact, so hopefully typing this out will help.
Let be a triangle with vertices , then there exists unique linear functions The derivation is simple. The direction of the gradient is towards the highest growth, and as the barycentric coordinates are linear functions, it’s clear that is the correct direction. The scaling is to simply note the area as ls says: