Title / Description
Code sf::Image img; img.create(181 * 2, 181 * 2); const auto img_s = img.getSize(); const auto center = img_s / 2u; for(auto abs_y = 0u; abs_y < img_s.y; ++abs_y) for(auto abs_x = 0u; abs_x < img_s.x; ++abs_x) { const auto y = static_cast<signed int>(abs_y) - static_cast<signed int>(center.y); const auto x = static_cast<signed int>(abs_x) - static_cast<signed int>(center.x); const auto r = std::sqrt(x * x + y * y); const auto g = (std::abs(std::atan2(y, x)) / (2 * std::acos(0))) * 255; const auto luma = static_cast<std::uint8_t>(std::sqrt(r * r + g * g)); img.setPixel(abs_x, abs_y, {luma, luma, luma}); } img.saveToFile("output.png");
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code