The ratio of the height of each triangle to the width/base of each triangle is the slope of the line. This is using the method "rise over run," where you count how many units you climb and divide by the number of units across between two coordinate points.
Since this appears to be a linear function, we also know that these two triangles are similar.