Uploaded image for project: 'SmartSprites'
  1. SmartSprites

Add support for setting width and height of an individual sprite image


    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 0.3.0
    • Labels:



      As pointed out on the discussion group by Kevin, the least common multiple (LCM) algorithm for repeated sprite images can cause the sprites to grow beyond control if there are large numbers of repeated images with "LCM-incompatible" widths. In many cases, the container of the repeated image is limited in size and it would be enough for the sprite image to be painted only on a specified width or height.


      For each sprite reference there should be a possibility of defining sprite-width and sprite-height properties, both specified in pixels, e.g. 22px. When specified, the individual sprite image should occupy the provided sprite-width and/or sprite-height. Width and height limits should exclude borders, i.e. a sprite declared with sprite-width: 20px; sprite-margin-left: 10px; sprite-margin-right: 5px will occupy 35px of width.

      If the source image is wider or higher than the allowed sprite image dimensions, it will be clipped. Clipping will also occur for repeated sprites. Similarly, if the source image is smaller along some direction than the specified maximum, the image should be padded with transparent pixels to meet the desired size constraints. Padding and clipping should be applied at different sides of the individual image, depending on the image's position within the sprite:

      • for left- and top-aligned sprite images: below / to the right of the image
      • for right-aligned sprite images: below / to the left of the image
      • for bottom-aligned sprite images: above / to the right of the image
      • for middle-aligned images (SMARTSPRITES-36) in a vertical sprite layout: below and proportionally from left and right of the image
      • for middle-aligned images (SMARTSPRITES-36) in a horizontal sprite layout: proportionally from top and bottom and to the right of the image

      SmartSprites should issue errors when:

      • the specified sprite-width or sprite-height does not follow the xpx format or is <= 0

      SmartSprites should issue warnings when:

      • the source image was clipped
      • the repeated image does not span across the whole width / height of the sprite
      • the repeated image occupies the full width / height of the sprite, but its repeated dimension is not a multiple of the corresponding source image dimension (and hence will not repeat seamlessly)


      In case of non-repeated sprite images, it would make more sense to define sprite-max-width and sprite-max-height so that there is no confusion around paddings and borders. However, this would be useless for repeated images, unless we also introduced sprite-min-width and sprite-min-height. Then for repeated sprite images, one would have to provide both minimum and maximum constraints, and these would usually be equal, coming down to plain width and height. Should a need arise, minimum and maximum constraints can be added later.




            • Assignee:
              stachoo Stanisław Osiński
              stachoo Stanisław Osiński
            • Votes:
              2 Vote for this issue
              0 Start watching this issue


              • Created:

                Time Tracking

                Original Estimate - 6h
                Remaining Estimate - 6h
                Time Spent - Not Specified
                Not Specified