In my IDML file, I have a Spread, containing several rectangles, which then contain an image each. I'm able to correctly (it seems) reconcile my rectangles against the Spread coordinate space, however, I'm unable to reconcile the images into the same coordinate space.
In the image below, the pink boxes (images) should roughly overlap with the rectangles they are pointed to.
My pseudo-code is as follows:
transformed_rectangle = idml_rect.transform_by(idml_rect.transformation_matrix)
final_rectangle = transformed_rectangle.offset_by(spread_x, spread_y/2)
draw_outline(final_rectangle)
For the images, I -thought- it would just be chaining the transforms, but I feel like I'm missing a step.
# Create an idml_image using the <Image> tag and graphics bounds
transformed_image = idml_image.transform_by(idml_image.transformation_matrix)
# Should there be a translation here based on the Rectangle's bounding box?
transformed_image = transformed_image.transform_by(parent_idml_rect.transformation_matrix)
final_image = transformed_image.offset_by(spread_x, spread_y/2)
draw_and_fill_rectangle(final_image)
The image makes it look like there is a missing translation, which should be scaled - but I've tried using the Rectangle's origin - but to no avail.
Another question mark is whether scaling should be applied from the top-left, or centre-point. The centre has given me my best results, but I'm still missing something.