Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Equation to convert MouseX, MouseY value to 0,0

I have a various objects on the stage which have handles placed around the bounds of each object. I want to resize the object by pressing and dragging on a handle like you would when resizing in Photoshop. I envision this by pressing on a handle, reset the mouseX, mouseY coordinates to 0,0 and when dragging the handle the Mouse x,y value increases or decreases. I was wanting to use that value and add it to the objects width or height. For example: Mouse moves 2px and the value output is 2px and so on.

Object.height += //mouseY equation starting from 0 when pressed

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you can store the MouseX and MouseY in variables when the mouse button is down and the cursor is on the handler then subtract them from the new corresponding MouseX and MouseY when the mouse button is up.

Now you can add these values to your height and width of your objects.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading