Shavv
Member
Heey guys!
I found a neat little script here to draw a rotated rectangle, wich is really fun but I can't seem to solve the issue im having with it.
its drawing the rectangle in the exact middle of the object, and i want it to draw from the object forward to the direction i want it to.
Screenshots:
Whats happening now:
What I initially want:
Code:
I can't seem to wrap my head around how i could change the initial position without centering it in the middle of the object.
Thanks for your kind help!
I found a neat little script here to draw a rotated rectangle, wich is really fun but I can't seem to solve the issue im having with it.
its drawing the rectangle in the exact middle of the object, and i want it to draw from the object forward to the direction i want it to.
Screenshots:
Whats happening now:
What I initially want:
Code:
Code:
/// @description draw_rectangle_rotated(x,y,width,height,rotation,outline)
/// @param x
/// @param y
/// @param width
/// @param height
/// @param rotation
/// @param outline
var cx,cy,w,h,rot,sxx,sxy,syx,syy,x1,x2,x3,x4,y1,y2,y3,y4;
cx=argument0;
cy=argument1;
w=argument2/2;
h=argument3/2;
rot=argument4;
sxx = cos(degtorad(rot));
sxy = -sin(degtorad(rot));
syx = -sin(degtorad(rot));
syy = -cos(degtorad(rot));
x1=cx-sxx*w-syx*h;
x2=cx+sxx*w-syx*h;
x3=cx+sxx*w+syx*h;
x4=cx-sxx*w+syx*h;
y1=cy-sxy*w-syy*h;
y2=cy+sxy*w-syy*h;
y3=cy+sxy*w+syy*h;
y4=cy-sxy*w+syy*h;
if argument5=true
{
draw_line(x1,y1,x4,y4);
draw_line(x2,y2,x1,y1);
draw_line(x3,y3,x2,y2);
draw_line(x4,y4,x3,y3);
}
else
{
draw_triangle(x1,y1,x2,y2,x3,y3,false);
draw_triangle(x1,y1,x3,y3,x4,y4,false);
}
I can't seem to wrap my head around how i could change the initial position without centering it in the middle of the object.
Thanks for your kind help!