Skip to content

Commit

Permalink
Add slight padding to sprites for zoomy users.
Browse files Browse the repository at this point in the history
Zoomed in users sometimes get weird junk at the edges
of sprites 'cus everything's so close together.
  • Loading branch information
spladug committed Nov 16, 2011
1 parent 4a02f99 commit ba3cead
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions r2/r2/lib/nymph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from r2.lib.static import generate_static_name

SPRITE_PADDING = 1
sprite_line = re.compile(r"background-image: *url\((.*)\) *.*/\* *SPRITE *(stretch-x)? *\*/")


Expand Down Expand Up @@ -74,7 +75,7 @@ def has_space_for(self, image):

def add_image(self, image):
image.sprite_location = (self.offset, self.bounding_box[1])
self.offset += image.width
self.offset += image.width + SPRITE_PADDING


def _load_spritable_images(css_filename):
Expand Down Expand Up @@ -107,7 +108,7 @@ def _generate_sprite(images, sprite_path):
if image.stretch:
image.stretch_to_width(sprite_width)
image.sprite_location = (0, sprite_height)
sprite_height += image.height
sprite_height += image.height + SPRITE_PADDING
else:
small_images.append(image)

Expand All @@ -123,7 +124,7 @@ def _generate_sprite(images, sprite_path):
else:
# or give up and create a new bin
bin = SpriteBin((0, sprite_height, sprite_width, sprite_height + image.height))
sprite_height += image.height
sprite_height += image.height + SPRITE_PADDING
bins.append(bin)

bin.add_image(image)
Expand Down

0 comments on commit ba3cead

Please sign in to comment.