Pixel-Composer/scripts/draw_connect_line/draw_connect_line.gml

38 lines
1.2 KiB
Text
Raw Normal View History

2024-11-08 04:36:54 +01:00
function draw_line_connect(x0, y0, x1, y1, _s = 1, thick = 1, c1 = c_white, c2 = c_white, params = {}) {
var extend = params.extend;
2024-12-14 03:39:34 +01:00
var corner = min(extend, params.corner, min(abs(x0 - x1), abs(y0 - y1)) / 2);
2024-11-08 04:36:54 +01:00
var type = params.type;
var sample = clamp(corner / 4, 1, 8);
var xx0 = x0 + extend * _s;
var xx1 = x1 - extend * _s;
var dir = point_direction(xx0, y0, xx1, y1);
var cx0 = xx0 + lengthdir_x(corner, dir);
var cy0 = y0 + lengthdir_y(corner, dir);
var cx1 = xx1 - lengthdir_x(corner, dir);
var cy1 = y1 - lengthdir_y(corner, dir);
draw_line_width_color( x0, y0, xx0 - corner, y0, thick, c1, c1);
draw_line_width_color(xx1 + corner, y1, x1, y1, thick, c2, c2);
draw_line_width_color(cx0, cy0, cx1, cy1, thick, c1, c2);
draw_corner(xx0 - corner, y0,
xx0, y0,
cx0, cy0,
thick, c1, sample);
draw_corner(cx1, cy1,
xx1, y1,
xx1 + corner, y1,
thick, c2, sample);
}
2024-11-24 06:07:17 +01:00
function distance_to_linear_connection(mx, my, x0, y0, x1, y1, _s, extend) {
2024-11-08 04:36:54 +01:00
var xx0 = x0 + extend * _s;
var xx1 = x1 - extend * _s;
return distance_to_line(mx, my, xx0, y0, xx1, y1);
}