How to use coordinates Translation in FireMonkey Applications


I am writing a drawing method in Delphi 10.1 to draw few shapes on a Canvas, however, the shapes are logically nested in a way that they should be relative to each other (child coordinates should be translated to parent coordinates). For example, drawing a square inside a square inside another square, for the (parent) top square, I need to have it’s coordinates translated to FMX object coordinates (bounding rectangle), for the second square, it’s coordinates will be translated to top square coordinates, and so continues till the last object is drawn. I can do this mathematically, but I was hoping to use a translation matrix in FMX drawing (Matrix) for performance, but I do not know how to use it:

FM1 := Canvas.SetMatrix(Matrix.CreateTranslation(cx, cy));// for 1st square
// Darwing goes here
FM2 := Canvas.SetMatrix(Matrix.CreateTranslation(cx, cy));// for 2nd square
Canvas.SetMatrix(????);// is it FM1 * FM2???


Comments are closed.