Thread: [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/ |
From: Pere P. i C. <per...@gm...> - 2023-02-10 23:31:45
|
El dv. 10 de 02 de 2023 a les 02:40 -0800, en/na Bill Kendrick va escriure: > 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". Maybe also "autoscale=bottom" since in some starters is better to retain the upper part. > > 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. Yes, IIRC this is drawing surface, old dat file contents, starter bakground and foreground surfaces, label surface (if any) and contents of labels. As I see it, starter back and fore surfaces MUST be tied to the saved drawing and suffer the same changes as the saved drawing if the canvas change. Currently, on Open, it regenerates the starter surfaces from the stored data without taking account of the changes in the drawing, so if the drawing has scaled because canvas changes, then the starter and drawing will not match anymore. Also, some magic tools woul benefit of starter sync with drawing, like move, zoom, perspective... my 2 cents Pere > > 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/ > > > _______________________________________________ > Tuxpaint-devel mailing list > Tux...@li... > https://lists.sourceforge.net/lists/listinfo/tuxpaint-devel |
From: Albert C. <aca...@gm...> - 2023-02-11 07:57:31
|
You might want a gravity direction.This would cause the filling (smear or solid) or cropping to avoid one or two of the sides. 0. center 1. left 2. right 3. top 4. bottom 5. bottom-left 6. bottom-right 7. top-left 8. top-right Another option is to tile. This probably ought to scale the way stamps do, proportional to the fourth root of the canvas area. (that being a compromise for how to make use of larger screen size) Maybe the tiled ones should appear as 2x2 in the selection UI. Simple tiling is enough I think; there is no need for weird symmetries. |
From: Bill K. <nb...@so...> - 2023-02-12 18:54:11
|
On Sat, Feb 11, 2023 at 02:57:20AM -0500, Albert Cahalan wrote: > You might want a gravity direction.This would cause the filling (smear > or solid) or cropping to avoid one or two of the sides. > > 0. center > 1. left > 2. right > 3. top > 4. bottom > 5. bottom-left > 6. bottom-right > 7. top-left > 8. top-right Excellent idea, I've implemented this (as a separate option), and somehow it wasn't too difficult. I'm working to document it now; that might be the hard part. ;) Thanks to both you and Pere for putting though into this. > Another option is to tile. This probably ought to scale the way stamps > do, proportional to the fourth root of the canvas area. (that being a > compromise for how to make use of larger screen size) Maybe the tiled > ones should appear as 2x2 in the selection UI. Simple tiling is enough > I think; there is no need for weird symmetries. I'm gonna hold off on this idea, but I'll let it percolate in my brain. Thanks :) -bill! |