[Tuxpaint-devel] Options for scaling starters & templates
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
From: Bill K. <nb...@so...> - 2023-02-10 10:40:55
|
When a starter image or template is not the exact same size as the canvas, it will of course be scaled up or down. We do not change the aspect ratio (change the shape, aka squash or stretch) of the picture, though. If the aspect ratio is not the same as the canvas (which it frequently is note), it will scale up as large as it can and then "smear" the edges that did not fill the canvas. This can look really weird & ugly, especially with the photographic ones (e.g., the rocky beach template). I just started work to allow option files (plaintext config files with the same name as the image file, but with ".dat" extension; same as we do with stamps and brushes) to allow this to be overridden for some starters & templates. I have done so already with the wool mill machinery, the rocky beach, and the reef (2-layer starter). They've all been set to use the same option, "autoscale=both". The "autoscale" option allows you to tell Tux Paint whether it's okay to scale the image up so much that the edges will be cropped away. For example, a wide starter on a narrow canvas can be scaled up so that it fits vertically, with the left/right sides getting discarded. And conversely, a narrow starter on a wide canvas can be scaled up so that it fits horizontally, with the top/bottom discarded. If it only makes sense to allow one dimension to be discarded (i.e., right & left is okay, but cutting off the top & bottom would be bad), you can specify either "autoscale=horizontal" or "autoscale=vertical". If no scaling is specified, it will scale up as much as it can without cropping anything, like it has been doing already. Now, though, you can also specify whether or not to "smear" (which will be the default), or to simply use a solid background color (which you specify with "background=..." in the file; it supports 6- and 3-digit hex (e.g., #FFFFFF & #000) and decimal, just like the color palette file does. This would be good for B&W coloring-book style starters (e.g., the skull SVG) which can sometimes end up with a very faint edge getting smeared all the way down the canvas. Note: If the "autoscale=both" option is set, the image will NEVER have any bare edges, no matter the shape of the canvas. So the background setting (smear, or use a background color) is moot. I posted a tweet on Twitter showing the rocky beach template, with before & after in both portrait & landscape canvases of rather extreme sizes (Tux Paint running at 1280x640 and 640x960). https://twitter.com/billkendrick/status/1623989004436901890 For the rocky beach template, for example, I don't think what's at the extreme edges "matters". And I'd prefer to have a drawing that looks like some nice rocks, regardless of my canvas' aspect ratio, rather than weird smeary edges. :) I need to test this a bunch more, document it (EXTENDING), and add sensible defaults for any starters & templates that would benefit from the different settings. I cannot guarantee that Tux Paint will behave very well with starters & templates [*] if you save a drawing, quit, change the canvas size (via setting a different window size), launch Tux Paint again, and open the image up again. However, I don't think it's done a great job with this _already_, so I'm not super concerned. What you'll see is that I only apply this "scale & crop?" and "background color or smear?" decision when loading the actual starter/template images, and don't do it to the saved drawing. It also gets a little tricky because as of late, we jam some of the starter & template stuff (including the entire background and foregrounds?!) into the PNG files, if I recall correctly. Basically, woe is me, I don't think I can make this "perfect"... but I think this improvement is probably beneficial. Holler if you have other ideas or concerns! -bill! [*] Starters would be more adversely affected since there is a top layer that applies itself to the image after every modification (paint, stamp, etc.) Warped & zoom-in/out effects could be seen. Templates are less of a concern, as they only come into play -- the same way as the starters' background layers -- when you use the Eraser tool. PS - This is https://sourceforge.net/p/tuxpaint/feature-requests/190/ |