def scaleToBoxParam(quad, shape):
<EOL>x0 = <NUM_LIT:0.5>*(quad[<NUM_LIT:0>][<NUM_LIT:0>]+quad[<NUM_LIT:1>][<NUM_LIT:0>])<EOL>x1 = <NUM_LIT:0.5>*(quad[<NUM_LIT:2>][<NUM_LIT:0>]+quad[<NUM_LIT:3>][<NUM_LIT:0>])<EOL>y0 = <NUM_LIT:0.5>*(quad[<NUM_LIT:0>][<NUM_LIT:1>]+quad[<NUM_LIT:3>][<NUM_LIT:1>])<EOL>y1 = <NUM_LIT:0.5>*(quad[<NUM_LIT:1>][<NUM_LIT:1>]+quad[<NUM_LIT:2>][<NUM_LIT:1>])<EOL>cx = (x0*shape[<NUM_LIT:0>]) / (x0-x1+shape[<NUM_LIT:0>])<EOL>cy = (y0*shape[<NUM_LIT:1>]) / (y0-y1+shape[<NUM_LIT:1>])<EOL>fx = abs(cx/(x0-cx))<EOL>fy = abs(cy/(y0-cy))<EOL>return (fx,fy), (cx,cy)<EOL>
so, you have a [quad] ((x0,y0),,,) inside a box [shape](width,height)

this function gives you center [x,y], and scale factor [x,y]
you would need to apply to [quad] in order to scale it to the same shape as the box


!quad corners needs to be sorted like in example