[glass] Add canvas element for arbitrary drawing #4585
Labels
component: glass
Glass app and backend
type: feature
Brand new functionality, features, pages, workflows, endpoints, etc.
Also allow canvas overlays on Field2D (and on camera views, once added). This will generically solve a number of issues, such as camera crosshairs / target highlighting. Should also support images (specified as image name, with dashboard side configuration of a directory to load images from).
Key elements to support: lines, rectangles, circles, images, text. Consider supporting everything in https://github.com/ocornut/imgui/blob/master/imgui.h#L2540-L2565
The overall canvas has width and height dimensions (like Mechanism2d). X, Y coordinates in other fields are within the width and height and are scaled based on width/height for display. This works well with Field2D and camera streams, which also auto-scale to fit the window; as long as the canvas overlay matches the aspect ratio of the other object, it will be a 1:1 overlay.
NT storage concept: subtable for each element with the following topics:
#FFFFFF
for white)(Poly)Line/Rect would have:
Circle and ngon would have:
Text would have:
Image would have:
API wise each of these object types should be standalone classes (e.g. CanvasLine) derived from a common CanvasPrimitive base class, and Canvas should have an add(CanvasPrimitive). Doing it this way is better than factory functions, as it makes it easy for teams to extend/create their own classes. Other dashboard classes (e.g. Field2d, Mechanism2d) could have a getCanvas() to get a Canvas object for overlay.
TBD: Should there be any capability to interact with these objects from the dashboard side? If so, there should be a setting for mutability. Since mutability would significantly increase complexity, the first version of this should probably be publish-only.
The text was updated successfully, but these errors were encountered: