Skip to content

Commit

Permalink
set color by HSV
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkesy committed Jan 22, 2024
1 parent 90c7984 commit 43fe15f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/mandelbrot/mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ ImVec4 Mandelbrot::MandelbrotColor(const std::complex<double> &c) const {

while (std::abs(z) <= 2 && iterations < max_iterations) {
z = z * z + c;
iterations++;
++iterations;
}

float hue = static_cast<float>(iterations) / max_iterations;
return ImVec4(hue, base_color[0], base_color[1], base_color[2]);
const auto hue = (static_cast<float>(iterations) / max_iterations);
ui::RGBColor rgb{};
ImGui::ColorConvertHSVtoRGB(hue, 1, iterations < max_iterations ? 0 : 1,
rgb[0], rgb[1], rgb[2]);

(void)base_color;
// FIXME: enable base color again
// const auto add_base_color = [](float color, float hue) {
// // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// return std::clamp(0.0F, (color / 255), 1.0F);
// // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// };
return {rgb[0], rgb[1], rgb[2], 1.0F};
}

} // namespace mandelbrot_visualizer

0 comments on commit 43fe15f

Please sign in to comment.