Butt generation
C++
code posted
by
nabijaczleweli
created at 25 Feb 14:36
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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"); |
667 Bytes in 4 ms with coderay