add the possibility to add a `Canvas` to see visually the movements
Laaouatni opened this issue · 1 comments
- you can create a new Class that is needed to simulate the movements of all G0/G1 called before
- the array of G0/G1 classes, is inside the
GcodeAPI.array
(the array is created in this issue #9)
- the simulation needs to be inside
<canvas>
- and need to use the canvas web APIs (context 2D)
but in the future, I think we will use normal CSS (since is more powerful, but maybe slow).
the functionalities to add (at least that can be called inside the same class):
-
create()
method (internally):- this creates a new canvas element
- append the canvas to the parent element
- you need to make the user choose
- whatquerySelector();
is the parent element
- but if isn't defined by the user, use<body>
as a default.
- you need to make the user choose
- the user needs to choose also dimensions
- if there isn't any dimension
- get the other dimension (for example, "width
isundefined
" then get theheight
)
- if none of that parameters is defined then use 500px.
- if there isn't any dimension
-
drawLine() method:
- it needs to create a line from the previous position (or 0 if there aren't any of them)
- and go to the chosen position in G0/G1
- and show the line using the.stroke()
canvas API method -
generate()
method:- it needs to use the
create()
method - and loop the drawLine() method of all GcodeAPI arrays with
.forEach
- it needs to use the
only
generate()
need to be used by the user,
but the other method only internally.
so in the docs add onlygenerate();
⚠️ also solve the issues inMoveTo();
that don't get the previus position if you callMoveTo()
2+ times. (if you call only 1 time work fine, but 2 or more not, try solve that)