143 else if (intensity < 0.0)
147 intensity = intensity * (
mColors.size() - 1);
150 int i = (int) floor(intensity);
151 int j = (int) ceil(intensity);
163 double rest = 1 - intensity;
174 color[0] = (rest * r1 + intensity * r2);
175 color[1] = (rest * g1 + intensity * g2);
176 color[2] = (rest * b1 + intensity * b2);
182 dyePalette =
nullptr;
184 if (description.empty())
187 std::string::size_type next_pos = 0, length = description.length();
190 std::string::size_type pos = next_pos;
191 next_pos = description.find(
';', pos);
193 if (next_pos == std::string::npos)
196 if (next_pos <= pos + 3 || description[pos + 1] !=
':')
198 Log::info(
"Error, invalid dye: %s", description.c_str());
204 switch (description[pos])
206 case 'R': i = 0;
break;
207 case 'G': i = 1;
break;
208 case 'Y': i = 2;
break;
209 case 'B': i = 3;
break;
210 case 'M': i = 4;
break;
211 case 'C': i = 5;
break;
212 case 'W': i = 6;
break;
214 Log::info(
"Error, invalid dye: %s", description.c_str());
218 next_pos - pos - 2));
221 while (next_pos < length);
232 int cmax = std::max(color[0], std::max(color[1], color[2]));
236 int cmin = std::min(color[0], std::min(color[1], color[2]));
237 int intensity = color[0] + color[1] + color[2];
240 (cmin != 0 || (intensity != cmax && intensity != 2 * cmax)))
246 int i = (color[0] != 0) | ((color[1] != 0) << 1) | ((color[2] != 0) << 2);
254 std::string::size_type next_pos = target.find(
'|');
256 if (next_pos == std::string::npos || palettes.empty())
261 std::ostringstream s;
262 s << target.substr(0, next_pos);
263 std::string::size_type last_pos = target.length(), pal_pos = 0;
266 std::string::size_type pos = next_pos;
267 next_pos = target.find(
';', pos);
269 if (next_pos == std::string::npos)
272 if (next_pos == pos + 1 && pal_pos != std::string::npos)
274 std::string::size_type pal_next_pos = palettes.find(
';', pal_pos);
275 s << target[pos] <<
':';
276 if (pal_next_pos == std::string::npos)
278 s << palettes.substr(pal_pos);
279 s << target.substr(next_pos);
280 pal_pos = std::string::npos;
283 s << palettes.substr(pal_pos, pal_next_pos - pal_pos);
284 pal_pos = pal_next_pos + 1;
286 else if (next_pos > pos + 2)
288 s << target.substr(pos, next_pos - pos);
292 Log::info(
"Error, invalid dye placeholder: %s", target.c_str());
295 s << target[next_pos];
298 while (next_pos < last_pos);