Quick question, I'm pretty new to JavaScript, and I will undoubtedly learn a lot from this project. So I propose a question (which could well be a silly one), my question is:
I am planning to build a web application that dynamically generates shapes from either Raphael or Joint.js both of which are very similar, by dynamic I mean that there will be an undefined amount of objects to draw until the user enters, for example the amount of objects they wish to draw - so here's some code to reinforce my question:
var erd = Joint.dia.erd;
Joint.paper("world", 800, 250);
var e1 = erd.Entity.create({
rect: {
x: 220,
y: 70,
width: 100,
height: 60
},
label: "Entity"
});
So, I've created a object of type rectangle, but here is what I want to know - can I do this:
var erd = Joint.dia.erd;
Joint.paper("world", 800, 250);
int x, y;
for (int i = 0; i < numOfUserDefObjects; i++) {
var e1 = erd.Entity.create({
rect: {
x: x,
y: y,
width: 100,
height: 60
},
label: "Entity"
x + 20;
y - 40;
});
}
All is what puzzles me is, the var e1
. If there are 2 objects to be created, will the first object created in the loop be erased/deleted/overwritten from my SVG/Canvas whenever the loop iterates through the loop for a second time/to create the second object?
A little insight to this would be greatly appreciated! Again, lack JavaScript experience but that'll change.
Thanks, again.