I recently got a request for a way to help visualize the blanket that’s generated. It’s hard to work from a list of “r/h/p”-type entries. Not very user-friendly.
So I added in a color picker today, and the generator now shows the colors of the squares. As a warning, if you have a lot of very similar colors, the generated image may be difficult to work from. Then again, if your blanket’s in 15 shades of purple (yes, please!), you may not need this utility.
Now that the resulting blanket is far less printable (except to PDF), I think I may go ahead and add in a “permalink” functionality like what I use on the my World of Darkness ghost character sheet. It’ll allow folks to retrieve their blankets, but not require any personal information or account creation.
My first color picker of choice (for simplicity of implementation) was jPicker. It’s got issues: it’s not very accessible, it’s not very pretty, and it’s not very fast. That’s been noted and fixes seem to be in progress. That said, the picker worked well in a scenario of multiple instances of the subform and updating a hidden form element, making for about a 5 minute implementation.
But dang, it’s big. I don’t really want all that stuff on there.
Enter Farbtastic (with its fantastic name), or, better yet, a github version. I had to put in the bit of work to get it to appear and disappear, as well as having it retain its values and such, but truly, this entire thing was a drop-in affair.
My life was made easier by the UI-agnostic setup on the backend. There are actually two “apps” there, in the Django sense: the granny_squares app that handles the form processing and blanket display, and the color_combinator that actually does the crunching to produce a blanket.
The color field doesn’t care if it’s a manually-entered word or a hex except for display, which is all within granny_squares. All the color_combinator needs is to know is whether two colors (or their individual fields) are equal; I just reassessed the __hash__ and __eq__ methods on the Color object to account for not having “initials” anymore.