Skip to content

feat(path): add missing path functions#351

Open
emiyl wants to merge 6 commits into
ButterscotchRunner:mainfrom
emiyl:missing-path-functions
Open

feat(path): add missing path functions#351
emiyl wants to merge 6 commits into
ButterscotchRunner:mainfrom
emiyl:missing-path-functions

Conversation

@emiyl

@emiyl emiyl commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Butterscotch was missing the following functions, which have now been implemented:

  • path_get_name
  • path_change_point
  • path_insert_point
  • path_delete_point
  • path_append
  • path_assign
  • path_duplicate
  • path_flip
  • path_mirror
  • path_reverse
  • path_rotate
  • path_rescale
  • path_shift

I've tested the functionality with the following script:

function assert_equal(name, actual, expected)
{
    if (actual == expected)
        show_debug_message("PASS: " + name);
    else
        show_debug_message(
            "FAIL: " + name +
            " expected=" + string(expected) +
            " got=" + string(actual)
        );
}


show_debug_message("===== PATH TEST START =====");


// path_add + path_exists
var p1 = path_add();

assert_equal(
    "path_exists after add",
    path_exists(p1),
    true
);


// path_add_point
path_add_point(p1, 10, 20, 30);
path_add_point(p1, 40, 50, 60);

assert_equal(
    "path_add_point count",
    path_get_number(p1),
    2
);

assert_equal(
    "first point x",
    path_get_point_x(p1, 0),
    10
);

assert_equal(
    "first point y",
    path_get_point_y(p1, 0),
    20
);

assert_equal(
    "first point speed",
    path_get_point_speed(p1, 0),
    30
);


// path_change_point
path_change_point(p1, 0, 100, 200, 300);

assert_equal(
    "path_change_point x",
    path_get_point_x(p1, 0),
    100
);

assert_equal(
    "path_change_point y",
    path_get_point_y(p1, 0),
    200
);

assert_equal(
    "path_change_point speed",
    path_get_point_speed(p1, 0),
    300
);


// path_insert_point
path_insert_point(p1, 1, 50, 60, 70);

assert_equal(
    "path_insert_point count",
    path_get_number(p1),
    3
);

assert_equal(
    "inserted point x",
    path_get_point_x(p1, 1),
    50
);


// path_delete_point
path_delete_point(p1, 1);

assert_equal(
    "path_delete_point count",
    path_get_number(p1),
    2
);


// path_clear_points
var clear_test = path_duplicate(p1);

path_clear_points(clear_test);

assert_equal(
    "path_clear_points",
    path_get_number(clear_test),
    0
);


// path_duplicate
var dup = path_duplicate(p1);

assert_equal(
    "path_duplicate count",
    path_get_number(dup),
    path_get_number(p1)
);

assert_equal(
    "path_duplicate point",
    path_get_point_x(dup, 0),
    path_get_point_x(p1, 0)
);


// path_append
var append = path_add();

path_add_point(append, 500, 600, 700);

var before = path_get_number(p1);

path_append(p1, append);

assert_equal(
    "path_append count",
    path_get_number(p1),
    before + 1
);

assert_equal(
    "path_append point",
    path_get_point_x(p1, before),
    500
);


// path_assign
var assigned = path_add();

path_assign(assigned, p1);

assert_equal(
    "path_assign count",
    path_get_number(assigned),
    path_get_number(p1)
);


// flip test
var flip = path_add();
path_add_point(flip, 10, 10, 0);
path_add_point(flip, 10, 30, 0);

path_flip(flip);

assert_equal(
    "path_flip point0 y",
    path_get_point_y(flip, 0),
    30
);

assert_equal(
    "path_flip point1 y",
    path_get_point_y(flip, 1),
    10
);


// mirror test
var mirror = path_add();
path_add_point(mirror, 10, 10, 0);
path_add_point(mirror, 30, 10, 0);

path_mirror(mirror);

assert_equal(
    "path_mirror point0 x",
    path_get_point_x(mirror, 0),
    30
);

assert_equal(
    "path_mirror point1 x",
    path_get_point_x(mirror, 1),
    10
);


// rotate test
var rotate = path_add();
path_add_point(rotate, 0, 0, 0);
path_add_point(rotate, 10, 0, 0);

path_rotate(rotate, 90);

assert_equal(
    "path_rotate point0 x",
    round(path_get_point_x(rotate, 0)),
    5
);

assert_equal(
    "path_rotate point0 y",
    round(path_get_point_y(rotate, 0)),
    5
);


// rescale test
var scale = path_add();
path_add_point(scale, 0, 0, 0);
path_add_point(scale, 10, 20, 0);

path_rescale(scale, 2, 3);

assert_equal(
    "path_rescale point1 x",
    path_get_point_x(scale, 1),
    15
);

assert_equal(
    "path_rescale point1 y",
    path_get_point_y(scale, 1),
    40
);


// path_shift
var shift = path_add();
path_add_point(shift, 10, 20, 0);

path_shift(shift, 100, 200);

assert_equal(
    "path_shift x",
    path_get_point_x(shift, 0),
    110
);

assert_equal(
    "path_shift y",
    path_get_point_y(shift, 0),
    220
);


// path_set_closed
path_set_closed(p1, true);

assert_equal(
    "path_set_closed",
    path_get_closed(p1),
    true
);


// path_set_kind
path_set_kind(p1, 1);

assert_equal(
    "path_set_kind",
    path_get_kind(p1),
    1
);


// path_set_precision
path_set_precision(p1, 8);

assert_equal(
    "path_set_precision",
    path_get_precision(p1),
    8
);


// path_delete
var deleted = path_add();

assert_equal(
    "path exists before delete",
    path_exists(deleted),
    true
);

path_delete(deleted);

assert_equal(
    "path exists after delete",
    path_exists(deleted),
    false
);


show_debug_message("===== PATH TEST END =====");

In both GameMaker Runtime 2026.0.0.23 and this PR, all functions added in this PR pass the tests. path_get_name is not in this test, but I've confirmed that it also works as expected.

@emiyl emiyl changed the title Add missing path functions feat(path): add missing path functions Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant