I've written a JavaScript function that creates a triangle (MyFirstTriangle). The triangle displays perfectly as one would expect. However, when I try to apply an animation to the triangle I get the "ReferenceError: MyFirstTriangle is not defined".
function CreateTriangle(Name) {
var Name = draw.polygon("50 15, 100 100, 0 100").fill("#fff").stroke({ width: 0 })
}
CreateTriangle("MyFirstTriangle");
MyFirstTriangle.animate(4000, '<>', 500 * i).rotate(30 * i);
When I create the same triangle directly (as in, not through a function), then the animation works perfectly. Are there some inherent limitations regarding the use of functions with SVG.JS?