add more imgui functions
This commit is contained in:
parent
fce8ff6081
commit
bc313d6f8c
|
@ -68,4 +68,14 @@ shape.circle.points = function(radius, 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};
|
||||
|
|
|
@ -677,12 +677,16 @@ function flush_poly()
|
|||
}
|
||||
|
||||
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 dist = vector.distance(points[0],points[1]);
|
||||
poly.transform.move(vector.midpoint(points[0],points[1]));
|
||||
poly.transform.rotate([0,0,-1], vector.angle([points[1].x-points[0].x, points[1].y-points[0].y]));
|
||||
var dist = vector.distance(a,b);
|
||||
poly.transform.move(vector.midpoint(a,b));
|
||||
poly.transform.rotate([0,0,-1], vector.angle([b.x-a.x, b.y-a.y]));
|
||||
poly.transform.scale = [dist, thickness, 1];
|
||||
poly.color = color;
|
||||
}
|
||||
check_flush(flush_poly);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,14 @@ JSC_CCALL(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[] = {
|
||||
MIST_FUNC_DEF(imgui, window, 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,lineplot,2),
|
||||
MIST_FUNC_DEF(imgui, sokol_gfx, 0),
|
||||
MIST_FUNC_DEF(imgui, columns, 2),
|
||||
MIST_FUNC_DEF(imgui, nextcolumn, 0),
|
||||
};
|
||||
|
||||
static int started = 0;
|
||||
|
|
Loading…
Reference in a new issue