| 1 | // Aseprite | 
|---|---|
| 2 | // Copyright (C) 2001-2015 David Capello | 
| 3 | // | 
| 4 | // This program is distributed under the terms of | 
| 5 | // the End-User License Agreement for Aseprite. | 
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H | 
| 8 | #include "config.h" | 
| 9 | #endif | 
| 10 | |
| 11 | #include "app/shade.h" | 
| 12 | |
| 13 | #include "base/split_string.h" | 
| 14 | |
| 15 | namespace app { | 
| 16 | |
| 17 | Shade shade_from_string(const std::string& str) | 
| 18 | { | 
| 19 | Shade shade; | 
| 20 | std::vector<std::string> parts; | 
| 21 | base::split_string(str, parts, " "); | 
| 22 | for (const auto& part : parts) { | 
| 23 | auto color = app::Color::fromString(part); | 
| 24 | if (color.getType() == app::Color::IndexType) | 
| 25 | shade.push_back(color); | 
| 26 | } | 
| 27 | return shade; | 
| 28 | } | 
| 29 | |
| 30 | std::string shade_to_string(const Shade& shade) | 
| 31 | { | 
| 32 | std::string res; | 
| 33 | for (const auto& s : shade) { | 
| 34 | res += s.toString(); | 
| 35 | res += " "; | 
| 36 | } | 
| 37 | return res; | 
| 38 | } | 
| 39 | |
| 40 | } // namespace app | 
| 41 | 
