2023-03-02 07:59:14 +01:00
|
|
|
function draw_line_dashed(x0, y0, x1, y1, th = 1, dash_distance = 8, dash_shift = 0) {
|
2024-04-22 14:13:03 +02:00
|
|
|
var dis = point_distance(x0, y0, x1, y1);
|
|
|
|
var dir = point_direction(x0, y0, x1, y1);
|
2022-12-16 09:18:09 +01:00
|
|
|
var part = ceil(dis / dash_distance);
|
|
|
|
|
|
|
|
var dx = lengthdir_x(1, dir);
|
|
|
|
var dy = lengthdir_y(1, dir);
|
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
var ox, oy, nx, ny, od, nd;
|
|
|
|
var rat = dash_distance / dis;
|
2022-12-16 09:18:09 +01:00
|
|
|
|
|
|
|
for( var i = 0; i <= part; i++ ) {
|
2023-03-02 07:59:14 +01:00
|
|
|
nd = dis * frac(i * rat + dash_shift / dis);
|
|
|
|
nx = x0 + dx * nd;
|
|
|
|
ny = y0 + dy * nd;
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
if(i && i % 2 && nd > od)
|
2022-12-16 09:18:09 +01:00
|
|
|
draw_line_width(ox, oy, nx, ny, th);
|
|
|
|
|
|
|
|
ox = nx;
|
|
|
|
oy = ny;
|
2023-03-02 07:59:14 +01:00
|
|
|
od = nd;
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function draw_line_dashed_color(x0, y0, x1, y1, th, c0, c1, dash_distance = 8) {
|
2024-04-22 14:13:03 +02:00
|
|
|
var dis = point_distance(x0, y0, x1, y1);
|
|
|
|
var dir = point_direction(x0, y0, x1, y1);
|
2022-01-29 14:25:18 +01:00
|
|
|
var part = ceil(dis / dash_distance);
|
|
|
|
|
|
|
|
var dx = lengthdir_x(1, dir);
|
|
|
|
var dy = lengthdir_y(1, dir);
|
|
|
|
|
|
|
|
var ox, oy, nx, ny, oc, nc;
|
|
|
|
var dd = 0;
|
|
|
|
|
|
|
|
for( var i = 0; i <= part; i++ ) {
|
|
|
|
dd = min(dis, i * dash_distance);
|
|
|
|
nx = x0 + dx * dd;
|
|
|
|
ny = y0 + dy * dd;
|
|
|
|
nc = merge_color(c0, c1, i / part);
|
|
|
|
|
2023-07-23 20:21:35 +02:00
|
|
|
if(i % 2) draw_line_width_color(ox, oy, nx, ny, th, oc, nc);
|
2022-01-29 14:25:18 +01:00
|
|
|
|
|
|
|
oc = nc;
|
|
|
|
ox = nx;
|
|
|
|
oy = ny;
|
|
|
|
}
|
2024-04-22 09:56:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function draw_line_dotted(x0, y0, x1, y1, radius, shift, distanceMulp = 1) {
|
2024-04-22 14:13:03 +02:00
|
|
|
var dis = point_distance(x0, y0, x1, y1);
|
|
|
|
var dir = point_direction(x0, y0, x1, y1);
|
|
|
|
var dtd = radius * distanceMulp * 2;
|
2024-04-22 09:56:37 +02:00
|
|
|
var part = floor(dis / dtd);
|
2024-04-22 14:13:03 +02:00
|
|
|
dtd = dis / part;
|
2024-04-22 09:56:37 +02:00
|
|
|
|
|
|
|
var dx = lengthdir_x(1, dir);
|
|
|
|
var dy = lengthdir_y(1, dir);
|
|
|
|
|
|
|
|
var nd, nx, ny;
|
|
|
|
var rat = dtd / dis;
|
|
|
|
|
|
|
|
for( var i = 0; i < part; i++ ) {
|
|
|
|
nd = dis * frac(i * rat + shift / dis);
|
|
|
|
nx = x0 + dx * nd;
|
|
|
|
ny = y0 + dy * nd;
|
|
|
|
|
|
|
|
draw_circle(nx, ny, radius, false);
|
|
|
|
}
|
2022-01-29 14:25:18 +01:00
|
|
|
}
|