Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// draw_rectangle_rotated(x1, y1, x2, y2, xp, yp, angle, outline)
- //
- // Draws a rectangle rotated about a point by a given number of degress.
- //
- // x1 x-coordinate of top-left corner
- // y1 y-coordinate of top-left corner
- // x2 x-coordinate of bottom-right corner
- // y2 y-coordinate of bottom-right corner
- // xp x-coordinate to rotate about
- // xp y-coordinate to rotate about
- // angle angle to rotate by in degrees
- // outline draw filled (false), or outlined (true)
- //
- /// GMLscripts.com/license
- {
- var x1 = argument0,
- y1 = argument1,
- x2 = argument2,
- y2 = argument3,
- xp = argument4,
- yp = argument5,
- angle = argument6,
- outline = argument7;
- var w, m;
- // Get Current World Transformation
- w = matrix_get(matrix_world);
- // Move Rotation Point to Origin
- m = matrix_multiply(w, matrix_build(-xp, -yp, 0, 0, 0, 0, 1, 1, 1));
- // Rotate and Move Back
- m = matrix_multiply(m, matrix_build(xp, yp, 0, 0, 0, angle, 1, 1, 1));
- // Set New World Transformation
- matrix_set(matrix_world, m);
- // Draw Rectangle
- draw_rectangle(x1, y1, x2, y2, outline);
- // Restore Old World Transformation
- matrix_set(matrix_world, w);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement