Focal point in percentage

Is there any way to crop image based on a focalpoint in percentage like we can do on imagix:

While we are working on implementing this in a single step transformation, it can be done in a two-step chained transformation as of now.

https://ik.imagekit.io/demo/img/default-image.jpg?tr=w-2000,ar-3200-1350,c-at_least:w-2000,ar-3200-1350,cm-extract,xc-cw_mul_0.5,yc-ch_mul_0.4

Here, the first step is w-2000,ar-3200-1350,c-at_least, which means resize the image to be atleast larger than or equal to - width 2000, aspect ratio 3200:1500. So we end up with an image 2000x2000

In next step w-2000,ar-3200-1350,cm-extract,xc-cw_mul_0.5,yc-ch_mul_0.4 we are now extracting the area equal to width 2000, aspect ratio 3200:1500 (so our width in this step is same as the previous step, and focal point will effectively change only along the y axis. So, we use the yc parameter to say that focal point should be at 40% (0.4) of the previous step’s image height (ch). xc parameter is at the center of the previous steps width (by multiplying cw with 0.5)

We are making use of Arithmetic Expressions in Transformations , Chained Transformations, and different resize and crop modes.

Ok, so just to be sure I understand correctly:
Imagine I want a function to generate this transformation, it could look something like this.

function generateTransformation(width: number, height: number, x: string, y:string){
  const widthNormalize = 'w-2000';
  const aspectRatio = `ar-${width}-${height}`;
  return `?tr=${widthNormalize},${aspectRatio},c-at_least:${widthNormalize},${aspectRatio},cm-extract,xc-cw_mul_${x},yc-ch_mul_${y}:w-${width},h-${height}`
}

Is this logic correct ?

(and increase width normalize if target size is bigger than 2000)

Yes. The code looks right, as long as x and y are in decimals between 0 and 1.
Did you try it out for a few images?