I have a seat function which takes a number of values, 3 of which are used to draw circles on the canvas.
each circle is a var named after a person and containing the values from the seat function.
I have the following function which I use to draw the individual circles:
ctx.fillPerson = function(p){
this.fillStyle = p.fillStyle;
this.arc(p.centerX, p.centerY, p.radius, 0, 2*Math.PI, false);
this.fill();
}
this works great when I do for example, ctx.fillPerson(johnSmith); however I am creating multiple groupings of people in array form and I need a function to draw the people in these arrays.
I have an array containing the variables mentioned above like this: var seatingOne = [johnSmith, joanSmith, bobJohnson, jillJohnson];
However, I can't seem to get the function right, I feel like I am on the right track, but my limited javascript knowledge is holding me back. So far I have this:
ctx.fillSeats = function(s){
for ( var i=0; i<s.length; ++i ){
ctx.beginPath();
ctx.fillPerson(indexOf(s));
}
}
My thinking is that I step through the array and perform a beginPath(); and ctx.fillPerson(); for each array item. I THINK(?) indexOf if the right tool to use but I am unsure if it is and exactly how to get the desired result.
Any help is much appreciated and please correct me if I said anything improperly (not hip to the all the lingo quite yet either ;) )
Thanks
s[i]instead ofindexOf(s)?ctx.fillSeats(myArray);