add more imgui functions

This commit is contained in:
John Alanbrook 2024-08-28 16:38:31 -05:00
parent fce8ff6081
commit bc313d6f8c
3 changed files with 30 additions and 6 deletions

View file

@ -68,4 +68,14 @@ shape.circle.points = function(radius, n) {
return shape.arc(radius, 360, n); return shape.arc(radius, 360, n);
}; };
shape.corners2points = function(ll, ur)
{
return [
ll,
ll.add([ur.x,0]),
ur,
ll.add([0,ur.y]),
];
}
return {shape}; return {shape};

View file

@ -677,12 +677,16 @@ function flush_poly()
} }
render.line = function render_line(points, color = Color.white, thickness = 1) { render.line = function render_line(points, color = Color.white, thickness = 1) {
for (var i = 0; i < points.length-1; i++) {
var a = points[i];
var b = points[i+1];
var poly = poly_e(); var poly = poly_e();
var dist = vector.distance(points[0],points[1]); var dist = vector.distance(a,b);
poly.transform.move(vector.midpoint(points[0],points[1])); poly.transform.move(vector.midpoint(a,b));
poly.transform.rotate([0,0,-1], vector.angle([points[1].x-points[0].x, points[1].y-points[0].y])); poly.transform.rotate([0,0,-1], vector.angle([b.x-a.x, b.y-a.y]));
poly.transform.scale = [dist, thickness, 1]; poly.transform.scale = [dist, thickness, 1];
poly.color = color; poly.color = color;
}
check_flush(flush_poly); check_flush(flush_poly);
} }

View file

@ -137,6 +137,14 @@ JSC_CCALL(imgui_sameline,
ImGui::SameLine(); ImGui::SameLine();
) )
JSC_SCALL(imgui_columns,
ImGui::Columns(js2number(argv[1]), str);
)
JSC_CCALL(imgui_nextcolumn,
ImGui::NextColumn();
)
static const JSCFunctionListEntry js_imgui_funcs[] = { static const JSCFunctionListEntry js_imgui_funcs[] = {
MIST_FUNC_DEF(imgui, window, 2), MIST_FUNC_DEF(imgui, window, 2),
MIST_FUNC_DEF(imgui, menu, 2), MIST_FUNC_DEF(imgui, menu, 2),
@ -155,6 +163,8 @@ static const JSCFunctionListEntry js_imgui_funcs[] = {
MIST_FUNC_DEF(imgui, plot,1), MIST_FUNC_DEF(imgui, plot,1),
MIST_FUNC_DEF(imgui,lineplot,2), MIST_FUNC_DEF(imgui,lineplot,2),
MIST_FUNC_DEF(imgui, sokol_gfx, 0), MIST_FUNC_DEF(imgui, sokol_gfx, 0),
MIST_FUNC_DEF(imgui, columns, 2),
MIST_FUNC_DEF(imgui, nextcolumn, 0),
}; };
static int started = 0; static int started = 0;