I'm having some trouble coming up with a way that would accomplish the following:
I have n slices whose ratios total 100%
I can adjust any border between two adjacent slices
I want to snap either one or both of the slices that are being adjusted with 1% accuracy
The procedure seems easy enough:
1) convert the slice border from pixel position to the respective percentage value for both slices
2) snap both slices to 1%
3) choose the one that has a smaller snap difference as the primary and ignore the other
4) convert the snapped position back to pixel coordinates
5) profit
Problem is: there can be any number of slices in the set whose total ratios always amount to 100%; as such I think I need to compensate for the change in the two slices to make the snap work. I'm not sure how to do this. Since I'm pretty sure the code is correct, I'm stuck looking at a logic failure. Unfortunately, I can't figure it out on my own... So any ideas or pointers would be awesome!
rounding slice distribution by percentage
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement