Menu

#162 "Shapes" tool should be extensible

v0.9.23
open
nobody
Other (24)
5
2018-10-10
2011-11-28
No

A teacher just mentioned that they tried to place new images in Tux Paint's data/images/shapes/ folder, expecting new shapes to be available under the "Shapes" tool. I explained that those images are simply used as icons for the shape tool's buttons.

However, there's no reason Tux Paint's shapes need to be hard-coded. (Already, the color palette, brushes, stamps, starters, templates and even Magic tools can be extended.) We should provide a way to describe shapes, perhaps through a text file (like we use for color palettes). Additionally, the shape icons should be render at start-up, and not rely on PNG images for the button labels, since that's an extra step that we shouldn't force the user to go through when adding new shapes.

At the moment, the shapes are defined by arrays in "src/shapes.h". Each is currently defined twice, once for filled, and again for empty. That should be handled automatically. The arrays are:

  • sides (how many sides)
  • locked (aspect ratio locked? e.g., true for circle and square, false for oval and rectangle)
  • filled (should be handled programmatically)
  • init_angle (initial angle)
  • no_rotate (don't provide a rotate step; currently only true for circle)
  • names (button labels)
  • tips (descriptive text, shown next to Tux penguin)
  • img_fnames (for button label icons; should be rendered automatically, and not rely on bitmap images)

Discussion

  • William Kendrick

    • Group: v0.9.22 --> v0.9.23
    • Priority: 2 --> 5
     
  • Pere Pujal i Carabantes

    Since there is already support for SVGs wouldn't make more sense to just add two SVGs, one filled the other oulined? plus a .txt and .dat files with the characteristics, locked, rotation, description...
    That would simplify the adding of new shapes, and also allow complex ones, like spirals or fractals.
    That would mean the completely redo of the shapes tool though but the implementation of the rotation on a SVG could also benefit the stamps tool.

     
    • Pere Pujal i Carabantes

      Well, I did some tests, made a couple SVGs, square and rectangle, modified tuxpaint to scale and rotate them in live then apply to the draw with the same interface as the Shapes tool.

      Found that the idea of just add some SVGs and let the user scale and rotate them on the interface doesn't seems to be so good.

      Appart of hard use of the CPU to generate the xor outline dynamically, wich could eventually be improved, the main problem with SVG scaling is the scaling of the lines, they get thicker on big scales and thinner on small ones, if a rectangle gets one dimension scaled up and the other scaled down, the diference in line thickness is really big.

      Either there is a way to scale a SVG keeping the thickness of its lines or I just have to discard this idea.

       

Log in to post a comment.