MeBoingus
Member
Howdy guys and gals,
I'm in the process of making a small editing tool that allows users to create 'objects' and rotate, scale and move these objects around.
I'm trying to implement the ability for the user to scale the object by clicking on a side/corner of the 'box' and dragging to size it (similar to how an image editing tool handles this same problem).
I got some help from another user in regards to drawing the 'box' around the object. This is the code I'm using for that:
This works as intended, along side some other code I'm using to allow the user to click a point to the bottom left of the sprite the sprite and begin rotating it.
The issue I'm having is that I cannot work out a simple way to detect if the cursor is 'inside of' or 'along' one of those lines. I.E. If the cursor is on the right-hand-side line of the box, regardless of it's current angle.
Does anyone know of a way to achieve this effect? A 'point_in_line' type script that would work within a few pixels of the 'edge' of each line?
Thanks in advance .
I'm in the process of making a small editing tool that allows users to create 'objects' and rotate, scale and move these objects around.
I'm trying to implement the ability for the user to scale the object by clicking on a side/corner of the 'box' and dragging to size it (similar to how an image editing tool handles this same problem).
I got some help from another user in regards to drawing the 'box' around the object. This is the code I'm using for that:
Code:
var _x0 = x + _left * _c + _top * _s;
var _y0 = y + _left * -_s + _top * _c;
var _x1 = x + _right * _c + _top * _s;
var _y1 = y + _right * -_s + _top * _c;
var _x2 = x + _right * _c + _bottom * _s;
var _y2 = y + _right * -_s + _bottom * _c;
var _x3 = x + _left * _c + _bottom * _s;
var _y3 = y + _left * -_s + _bottom * _c;
draw_set_color(c_gui_decor);
draw_line_width(_x0, _y0, _x1, _y1, 2);
draw_line_width(_x1, _y1, _x2, _y2, 2);
draw_line_width(_x2, _y2, _x3, _y3, 2);
draw_line_width(_x3, _y3, _x0, _y0, 2);
The issue I'm having is that I cannot work out a simple way to detect if the cursor is 'inside of' or 'along' one of those lines. I.E. If the cursor is on the right-hand-side line of the box, regardless of it's current angle.
Does anyone know of a way to achieve this effect? A 'point_in_line' type script that would work within a few pixels of the 'edge' of each line?
Thanks in advance .