I am making a web application that will mostly take place client side and have the data processed and stored on the server side (PHP/MySQL). The app lets you add different pieces of furniture to a room. These pieces of furniture are going to represented mostly by simple shapes (rectangle, square, etc...) except for a couple unique ones like a "L" shape and a "U" shape (no curve, all straight edges). I need to be able to calculate the square footage of any of these pieces depending on what dimensions the user puts in. What is the best way to store the "formulas" with each piece?
The other part is I plan to have a drag and drop type interface where the user can place the furniture in a room. I've been looking into using the <canvas>
element but then I came across Raphael. This seems like the better way to go since it supports more browsers. The main things I will need from this interface is:
The syntax for Raphael looks fairly simple, what would be the best way to store the SVG for each shape I make so that when the user clicks "Add" the shape is already calculated and can be added?
So basically, is Raphael a good choice for this type of interface/needs? And, how would I store information such as the shapes that I make, as well as each layout (combination of shapes, dimensions, and position of each shape) in a database so I can load any saved layout?
I believe you are in the right direction, keep with SVG and Raphael or you can use one of this libraries:
About the formulas, I would store the last dimensions and points in JS object format, I believe the formulas could be stored created in objects and using the strategy pattern you pass the correct one to be applied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With