Pixel-Composer/scripts/draw_line_width2/draw_line_width2.gml

52 lines
2.1 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
function draw_line_width2(x0, y0, x1, y1, w0, w1, cap = false) {
var aa = point_direction(x0, y0, x1, y1) + 90;
var _x0 = x0 + lengthdir_x(w0 / 2, aa);
var _y0 = y0 + lengthdir_y(w0 / 2, aa);
var _x1 = x0 + lengthdir_x(w0 / 2, aa + 180);
var _y1 = y0 + lengthdir_y(w0 / 2, aa + 180);
var _x2 = x1 + lengthdir_x(w1 / 2, aa);
var _y2 = y1 + lengthdir_y(w1 / 2, aa);
var _x3 = x1 + lengthdir_x(w1 / 2, aa + 180);
var _y3 = y1 + lengthdir_y(w1 / 2, aa + 180);
draw_primitive_begin(pr_trianglestrip);
2023-01-09 03:14:20 +01:00
draw_vertex(_x0, _y0);
draw_vertex(_x1, _y1);
draw_vertex(_x2, _y2);
draw_vertex(_x3, _y3);
2022-01-13 05:24:03 +01:00
draw_primitive_end();
if(cap && w0 / 2 - 1 > 0) {
//draw_set_color(c_red);
2023-01-09 03:14:20 +01:00
draw_circle(x0 - 1, y0 - 1, w0 / 2 - 1, 0);
draw_circle(x1 - 1, y1 - 1, w1 / 2 - 1, 0);
2022-01-13 05:24:03 +01:00
}
}
2023-02-20 10:16:31 +01:00
function draw_line_width2_angle(x0, y0, x1, y1, w0, w1, a0 = 0, a1 = 0, _oc = c_white, _nc = c_white, widColor = false) {
2022-01-13 05:24:03 +01:00
var _x0 = x0 + lengthdir_x(w0 / 2, a0);
var _y0 = y0 + lengthdir_y(w0 / 2, a0);
var _x1 = x1 + lengthdir_x(w1 / 2, a1);
var _y1 = y1 + lengthdir_y(w1 / 2, a1);
2023-02-19 13:49:20 +01:00
//draw_set_color(c_red);
2022-01-13 05:24:03 +01:00
draw_primitive_begin(pr_trianglestrip);
2023-02-20 10:16:31 +01:00
draw_vertex_color( x0, y0, widColor? merge_color(_oc, c_black, 0.5) : _oc, 1);
draw_vertex_color( x1, y1, widColor? merge_color(_nc, c_black, 0.5) : _nc, 1);
draw_vertex_color(_x0, _y0, widColor? merge_color(_oc, c_black, 0.0) : _oc, 1);
draw_vertex_color(_x1, _y1, widColor? merge_color(_nc, c_black, 0.0) : _nc, 1);
2022-01-13 05:24:03 +01:00
draw_primitive_end();
var _x0 = x0 + lengthdir_x(w0 / 2, a0 + 180);
var _y0 = y0 + lengthdir_y(w0 / 2, a0 + 180);
var _x1 = x1 + lengthdir_x(w1 / 2, a1 + 180);
var _y1 = y1 + lengthdir_y(w1 / 2, a1 + 180);
2023-02-19 13:49:20 +01:00
//draw_set_color(c_blue);
2022-01-13 05:24:03 +01:00
draw_primitive_begin(pr_trianglestrip);
2023-02-20 10:16:31 +01:00
draw_vertex_color( x0, y0, widColor? merge_color(_oc, c_black, 0.5) : _oc, 1);
draw_vertex_color( x1, y1, widColor? merge_color(_nc, c_black, 0.5) : _nc, 1);
draw_vertex_color(_x0, _y0, widColor? merge_color(_oc, c_black, 1.0) : _oc, 1);
draw_vertex_color(_x1, _y1, widColor? merge_color(_nc, c_black, 1.0) : _nc, 1);
2022-01-13 05:24:03 +01:00
draw_primitive_end();
}