Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. gr::Clip::Clip(Button& button, const sf::Texture& texture, Orientation orientation,
  2. std::initializer_list<CLICKSTATUS> states):
  3. Clip(
  4. button,
  5. texture,
  6. [&states, &orientation, ts = texture.getSize()] {
  7. FrameArray<int> frames;
  8. std::function<sf::IntRect(size_t)> makeFrame;
  9. if(orientation == Orientation::Horizontal) {
  10. makeFrame = [&ts, frdim = ts.x / states.size()] (size_t indx) {
  11. return sf::IntRect(frdim * indx, 0, frdim, ts.y);
  12. };
  13. }
  14. else {
  15. makeFrame = [&ts, frdim = ts.x / states.size()] (size_t indx) {
  16. return sf::IntRect(0, frdim * indx, ts.x, frdim);
  17. };
  18. }
  19. size_t j = 0;
  20. for(const auto& ele : states) {
  21. frames[int(ele)] = makeFrame(j++);
  22. }
  23. return frames;
  24. }()
  25. )
  26. {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement