Created
February 20, 2020 11:38
-
-
Save kaleem-elahi/8dff1e87f6071e6a76f00d1bef0a00a0 to your computer and use it in GitHub Desktop.
creating seating table with top, left, bottom, left.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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