I am writing an application for manipulating forms, so that after creating simple shapes, the user can create more complex ones by trimming the shapes against each other (i.e., combining two circles together with figure 8 stored using one path, not a group or intersecting two circles to create a bite mark), and I'm trying to decide to use a graphics library.
SVG seems to handle 80% of the functionality that I need out of the box (form storage, movement, rotation, scaling). The problem is that the other 20% (using cropping to create a new set of complex polygons) is apparently impossible to achieve without recreating the SVG functionality in my own modules (I would need to save the form once for drawing inside the SVG and one times for clipping processing). I could be wrong in SVG, but reading about the Raphael library (based on SVG), it seems that it only handles cropping using a rectangle, and even this clipping is temporary (it only displays part of the shape, but retains the entire shape for retransmission, when the rectangle being moved moves). Perhaps I just got confused in the SVG standard, but even searching / analyzing paths to calculate a new path using a subset of the previous paths seems not obvious in SVG (there is a Subpath () function, but I don’t see anything in finding the intersection points of two polygon perimeters or merging several subfolders in one way).
As a result, Canvas seems to be a better alternative, as it does not introduce additional overhead by tracking the forms that I already have to track in order to do my own cropping work. Not only that, I have already implemented a polygon class that can be moved, rotated and scaled. However, Canvas has some other problems (I would have to implement my own redraw method, which I’m sure would not be as effective as SVG, which takes advantage of browsers in Chrome and Firefox, and I would have to accept IE incompatibility, processed free of charge with libraries like Raphael).
thanks
source share