I am starting a project just for fun that deals with simple vector images (e.g. placing small colored or textured triangles in specific locations and orientations). I want to TDD the project if I can after I get out of prototyping, but I don't really know how to TDD a vector graphic, or any graphic output for that matter. Right now I'm playing with RMagick / RVG, but I'm not married to it.
A sample of features that I would like to test:
- a triangle has the correct background (this can come from a simple color, another vector graphic, or possibly (hopefully) raster image)
- has a triangle has been rotated correctly (0-360 degree)
- has a triangle been placed correctly (either in the context of the image or perhaps just in a correct "slot").
I started to look at ways of testing "equality" of a vector image. The first way that I came up with was to rasterize the vector and compare the vectors. While this seldom produces an absolute positive/negative match, it does create a good metric to compare the two images. See this gist for what I'm talking about.
Do you think this is a sane way of going about this? I was also thinking of decoupling my Triangle class from the imaging library, so that I could just unit test attributes within the domain of problem that translate into transformations. Has anyone else here TDDed with image generation that could share some wisdom?
Aucun commentaire:
Enregistrer un commentaire