Anyone in mood for some trigonometry? I am trying to perfectly replicate draw_self() using draw_sprite_general(), to supply it with part cutout, coloring, modifiable origin point and so on. I achieve it with the following code:
var _origin_transformed_x = (_part_x1 - lerp(_part_x1, (_part_x1 + _part_x2),
((_origin_x * _scale_x) /
_size_x)));
var _origin_transformed_y = (_part_y1 - lerp(_part_y1, (_part_y1 + _part_y2),
((_origin_y * _scale_y) /
_size_y)));
_location_x = (_location_x + (_origin_transformed_x * _angle_dcos) +
(_origin_transformed_y * _angle_dsin));
_location_y = (_location_y - (_origin_transformed_x * _angle_dsin) +
(_origin_transformed_y * _angle_dcos));
draw_sprite_general(_sprite, _frame, _part_x1, _part_y1, _part_x2, _part_y2,
_location_x, _location_y, _scale_x, _scale_y,
_angle_value, _color_x1y1, _color_x2y1, _color_x2y2,
_color_x1y2, _alpha);
This code works, but I have an edge case I cannot get to fix: It produces an unwanted offset, provided three conditions are met: First is that I have to scale the sprite with scale that is not even in both dimensions (for example: X: 2, Y: 1). Second is that "Automatically Crop" Texture Option must have cropped something from top and/or left of the sprite. Third is that the sprite is being rotated. It results in an offset like this: