Greetings, fellow Stackers! Please pardon my formatting as this is my debut question on this platform.
I am currently working on a basic vector drawing tool. If you want to view the full CodePen code for reference, feel free to click here.
Here's the scenario: I've created a DRAW object with a 'temp' method that contains canvas drawing commands within a template structure. I aim to insert a variable code line from other methods of this object (such as add, sub...) in between.
temp(operation){
ctx.beginPath();
ctx.moveTo(o.x, o.y);
eval(operation);
ctx.strokeStyle="red";
ctx.stroke();
}
I'm seeking assistance in finding an alternative to using eval(), as it has been noted to be problematic and error-prone. Any other suggestions or recommendations would also be highly appreciated. Thank you kindly.