I have begun to research a library called SimCirJS. This is a javascript library built to simulate circuits, so if I can use parts of it for my own circuit editor, my job might be made easier. My experiences so far show that the largest benefit of using the library would be access to an to use front end for my project. SimCirJS has an ability to draw vector representations of circuit components, including the logic gates I need to work with. This would solve one of the problems I had encountered so far with my front end. I have been using some images for the gates, but with my grid idea, sizing them to fit the grid has resulted in warped images. My follow up idea was creating anchor points on the images that wires would snap to, though this is harder to do than I thought, plus it would still have the same grid alignment issue - but this would negate the usefulness of the grid to an extent. The other problem with my images is that I have not been working with a full set of the gates I need to use, requiring a different set of images.
The extent to which this library overlaps with my project might end with my needs for the user interface. The library has capability for snapping to a grid, and components link together with anchor points. Separate wire components would be eliminated as a result. Their example code also includes an easy method of adding a bar to drag components onto the workspace and remove them.
What the library does not include or make easy is really everything I need for the backend. Loading and saving will require work, though both are doable through JSON. The library also provides nothing to remedy the stepping through of circuits, highlighting components, or creating compact new elements. There are included animations on some elements to indicate state, though this would not directly help my efforts.
Since saving is one of the main concerns with the library, I have a few potential routes that could be pursued. Cookies could be used to store saved schematics for a given machine, though this has the obvious limitation of restricting a user’s data to a single device. Alternatively, a login system with some kind of storage could be implemented, either with a database or text files. A database would be far more secure. Playing to the strengths of the library, I could have a directory with files saved to it that would be browsable by all users.