hunk.code_window: {
   	"$schema": "node_modules/lerna/schemas/lerna-schema.json",
   	"packages": ["packages/*"],
   	"version": "2.0.0-beta.0"
   }
hunk.labels: keep keep replace replace keep
hunk.after_edit: 	"packages": [
   		"packages/*"
   	],
   	"version": "2.0.0-alpha.17"
  
hunk.file_path: lerna.json
hunk.type: replace
file: import { TLShape, Vec2dModel } from '@tldraw/tlschema'
  import { Box2d } from '../../../primitives/Box2d'
  import { Vec2d } from '../../../primitives/Vec2d'
  
  export function resizeScaled(
  	shape: Extract<TLShape, { props: { scale: number } }>,
  	{
  		initialBounds,
  		scaleX,
  		scaleY,
  		newPoint,
  	}: {
  		newPoint: Vec2dModel
  		initialBounds: Box2d
  		scaleX: number
  		scaleY: number
  	}
  ) {
  	// Compute the new scale (to apply to the scale prop)
  	const scaleDelta = Math.max(0.01, Math.min(Math.abs(scaleX), Math.abs(scaleY)))
  
  	// Compute the offset (if flipped X or flipped Y)
  	const offset = new Vec2d(0, 0)
  
  	if (scaleX < 0) {
  		offset.x = -(initialBounds.width * scaleDelta)
  	}
  	if (scaleY < 0) {
  		offset.y = -(initialBounds.height * scaleDelta)
  	}
  
  	// Apply the offset to the new point
  	const { x, y } = Vec2d.Add(newPoint, offset.rot(shape.rotation))
  
  	return {
  		x,
  		y,
  		props: {
  			scale: scaleDelta * shape.props.scale,
  		},
  	}
  }
  