The issues jorgebastida#27 and jorgebastida#37 are still around for
files called myfile_1.png and myfile_2.png :/
But instead of fixing that, I'd rather just tell glue not to generate
css. Turns out it will validate the css classes nonetheless. Bad, bad
This PR should fix that behavior.
Don't bother validating class names if --no-css option is passed
Thanks for the PR @barraponto,
I've check if the naming issue is still around and I can't reproduce it!
Let's say you have file_1.png, file_2.png, file_3.png and file_4.png inside a folder named sprites and you call glue sprites/ out/, glue will refuse to create the sprite:
glue sprites/ out/
$ glue sprites/ out
Error: Some images will have the same class name:
sprites/file_1.png => .sprite-sprites-file
sprites/file_2.png => .sprite-sprites-file
sprites/file_3.png => .sprite-sprites-file
sprites/file_4.png => .sprite-sprites-file
That's because glue by default use the filename to determine if you want to add some padding around the image, so having a file named file_4.png means that you want to add 4 pixels around it. http://glue.readthedocs.org/en/latest/paddings.html
If you want to avoid this behaviour, you can use --ignore-filename-paddings.
I think class name validation is an interesting feature and I'm not really sure if I want to remove it from glue as it's glue responsibility generate class names, one of the first things you can expect is that he doesn't generate dups.
Does --ignore-filename-paddings fix your issue?
In the other hand, I'm thinking about moving the _ separator to __ so issues like yours would be harder to reproduce. Probably glue 0.3 is a good version number to do this backward Incompatible change.
Yeah, --ignore-filename-paddings was indeed the issue. But glue's logic first checks for padding, then validates the class name. I believe the latter should be skipped if --no-css is provided.
And 🍺 ++ for __padding in a filename. _number is a common pattern when working with tiles and sprites for games (which was actually what I used glue for). It'll be a BC issue though. Nevertheless (and I'll open another PR for this) I believe glue should either -opt-in to this behavior (using --use-filename-paddings) or log it explicitly Using paddings from filenames, --ignore-filename-paddings to disable.
Using paddings from filenames, --ignore-filename-paddings to disable
I think there is a biggest "issue" on the table. You are not the first one using glue to sprite game sprites for html5 games or even iOS. I think I should give a try to "reporters" #64 and make glue a "general purpose" sprite generator.
Some example formats:
I need to think about because it'll require a mayor rewrite, but I think it's a good idea :)
Yeah, JSON output would be awesome, although crafty has its own pattern so make sure it's pluggable.
Meanwhile, can we just disable CSS classes validation when --no-css is passed?
Make --no-css actually make something useful. #78
Several notes about this issue and glue 0.9:
As glue 0.9 codebase has changed dramatically, I can't merge this Pull Request, but I'm going to add you @barraponto to the AUTHORS file as you deserve the credit of this fix. Closing this.
Add Capi Etheriel to the AUTHORS file. #78
I've contributed to several projects before, but this is the first project I make it to the AUTHORS file. 🍸