Skip to content

Instantly share code, notes, and snippets.

@kaleem-elahi
Created February 20, 2020 11:38
Show Gist options
  • Save kaleem-elahi/8dff1e87f6071e6a76f00d1bef0a00a0 to your computer and use it in GitHub Desktop.
Save kaleem-elahi/8dff1e87f6071e6a76f00d1bef0a00a0 to your computer and use it in GitHub Desktop.
creating seating table with top, left, bottom, left.
const paper = Raphael(0, 0, 3200, 3200);
const topSeatSet = paper.set();
Raphael.fn.seatingTable = {
generateHorizontally: function (x, y, count, space) {
const circleSet = paper.set();
let s = space;
for (var i = 0; i < count; ++i) {
const el = paper.circle( x + s, y - space, 20, 20);
circleSet.push(el);
s = s + space;
}
return circleSet;
},
generateVertically: function (x, y, count, space) {
const circleSet = paper.set();
let s = space;
for (var i = 0; i < count; ++i) {
const el = paper.circle( x - space, y + s, 20, 20);
circleSet.push(el);
s = s + space;
}
return circleSet;
},
generateRectangleSeating: function (top, right, bottom, left) {
const circleSet = paper.set();
const seatSize = (25 *2);
const seatSpacing = (20 *2);
const RecHeight = right > left ? right : left;
const RecWidth = top > bottom ? top : bottom;
console.log((RecWidth * seatSize), (RecHeight * seatSize))
const rectangle = paper.rect(150, 150, (RecWidth * seatSize), (RecHeight * seatSize));
const recSize = rectangle.getBBox();
console.log("----", recSize, RecHeight, RecWidth)
// Top
this.generateHorizontally(recSize.x, recSize.y, top, seatSpacing);
// Right
this.generateVertically(recSize.x2 + (seatSize*2), recSize.y, right, seatSpacing);
// Down
this.generateHorizontally(recSize.x, recSize.y2 +(seatSize*2), bottom, seatSpacing);
// Left
this.generateVertically(recSize.x, recSize.y, left, seatSpacing);
},
}
paper.seatingTable.generateRectangleSeating(3, 5, 3, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment