I am currently trying to center the innermost shape (the red shape) along the X-axis to the middle of the outermost shape (the black shape), while ensuring that the red shape remains within its direct parent, which is the blue shape.
For instance, centering the red shape based on the original image (the dimensions are shown in the second picture):
The desired outcome should resemble this:
Furthermore, the blue shape may be positioned anywhere inside the black shape, and the red shape may be positioned anywhere inside the blue shape.
It's essentially basic math :) and I am struggling to devise a general mathematical formula to center the red shape within the black shape while keeping its position within the blue shape intact. Can someone guide me or explain how to achieve this?
PLEASE NOTE that the values (widths) are in pixels and are not precise.