The red and green areas are the same. The area between the MC- curve and
the price measures the producer surplus. The same applies to the rectangle
between the four red points.
The entire rectangle with price and quantity as corner points represents the revenue (price x quantity). If you subtract the costs, i.e. the lower green/light green square (average costs x quantity), the profit remains (upper red square). At the same time, the total costs can be determined as the area under the marginal cost curve1 so that the profit represents the area between price and marginal costs. Thus, the area of the upper red square is equal to the area between price and marginal cost curve.
The following relations apply:
For technical reasons, the quantity control can only be moved up to point 5.3.
1The marginal costs are the derivation of the cost curve. Thus, the cost curve can be written as integral of the marginal cost curve and the costs can be represented as area under the marginal cost curve.