-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose layers to public API #3
base: master
Are you sure you want to change the base?
Conversation
Hi, thanks for the PR. It's a good start but I have some comments / suggestions.
What we want to have is the ability to produce either a single flattened image atlas or a slice of unflattened image atlases. I think we can approach it as follows:
What do you think? |
Dear friend, I read your recommendation with great attention for about 45 minutes and studied the code more. I submitted two more commits. The first to make build methods private as you requested. The second to drop My reasoning is in line with my initial suggestion to split the construction of Aseprite into two: first get raw File, then Aseprite out of it, so that layers could be manipulated in some way before the image is flattened. I don't think that adding []Layers field would be better for two reasons:
With my current approach, if layers need to be manipulated (in my case, only filtered) the usage becomes: // normal way, no layer filtering
spr, _ := Read(r)
// new way, with layer filtering
f, _ := NewFile(r)
f.FilterLayers(filterFunc)
spr := New(f) Other types of manipulations could be added in the future. I think your suggestion can certainly work, but it will take more lines to implement and potentially produce a less flexible API surface for later modification. What do you think? |
I also suggest changing *File.FilterLayers signature to return a new *File instead of modifying the current one, so something like this can be composed more naturally: f, _ := NewFile(r)
spr := New(f.FilterLayers(filterFunc))
differentLayers := New(f.FilterLayers(differentFilterFunc)) I will submit the change after I hear some feedback from you. |
I tried to make the least amount of changes to get to the functionality I wanted. The API can be massaged more later. I also noticed that tests are little bit disorganized - I can submit another PR later to help with that.