diff --git a/tests/g2chromatic2.cpp b/tests/g2chromatic2.cpp index 04c0e4f..d5ca285 100644 --- a/tests/g2chromatic2.cpp +++ b/tests/g2chromatic2.cpp @@ -9,6 +9,7 @@ #include "../util/output/aviwriter.hpp" #include "../util/output/bmpwriter.hpp" #include "../util/timing_decorator.cpp" +#include struct AnimationConfig { int width = 1024; @@ -173,7 +174,7 @@ bool exportavi(std::vector frames, AnimationConfig config) { return success; } -int main() { +void mainLogic(){ AnimationConfig config; // std::cout << "g2c2175" << std::endl; @@ -200,8 +201,40 @@ int main() { } } - + exportavi(frames,config); +} + +int main() { + static bool window = true; + ImGui::SetNextWindowSize(ImVec2(1110,667)); + + if (ImGui::Begin("window_name", &window)) + { + + ImGui::SetCursorPos(ImVec2(435.5,200)); + ImGui::PushItemWidth(200); + static int i1 = 123; + ImGui::InputInt("Width", &i1); + ImGui::PopItemWidth(); + + ImGui::SetCursorPos(ImVec2(432,166)); + ImGui::PushItemWidth(200); + static int i2 = 123; + ImGui::InputInt("Height", &i2); + ImGui::PopItemWidth(); + + ImGui::SetCursorPos(ImVec2(533.5,271)); + ImGui::Button("Start", ImVec2(43,19)); //remove size argument (ImVec2) to auto-resize + + ImGui::SetCursorPos(ImVec2(400.5,366)); + ImGui::PushItemWidth(200); + static int i6 = 123; + ImGui::InputInt("number of Seeds", &i6); + ImGui::PopItemWidth(); + + } + ImGui::End(); FunctionTimer::printStats(FunctionTimer::Mode::ENHANCED); return 0; } \ No newline at end of file diff --git a/util/grid/grid2.hpp b/util/grid/grid2.hpp index f020d18..6d49a83 100644 --- a/util/grid/grid2.hpp +++ b/util/grid/grid2.hpp @@ -172,7 +172,7 @@ public: }; class Grid2 { -private: +protected: //all positions reverselookupassistantclasscausecppisdumb Positions; //all colors diff --git a/util/grid/sprite2.hpp b/util/grid/sprite2.hpp index a738ae3..d6560a1 100644 --- a/util/grid/sprite2.hpp +++ b/util/grid/sprite2.hpp @@ -46,24 +46,27 @@ public: Orientations[id] = orientation; } - void getGridRegionAsBGR(const Vec2& minCorner, const Vec2& maxCorner, int& width, int& height, std::vector& bgrData) const { + void getGridRegionAsBGR(const Vec2& minCorner, const Vec2& maxCorner, int& width, int& height, std::vector& rgbData) const { TIME_FUNCTION; + // std::cout << "excessdebug g2.483" << std::endl; // Calculate dimensions width = static_cast(maxCorner.x - minCorner.x); height = static_cast(maxCorner.y - minCorner.y); if (width <= 0 || height <= 0) { width = height = 0; - bgrData.clear(); - bgrData.shrink_to_fit(); + rgbData.clear(); + rgbData.shrink_to_fit(); return; } + // std::cout << "excessdebug g2.494" << std::endl; // Initialize RGB data (3 bytes per pixel: R, G, B) std::vector rgbaBuffer(width * height, Vec4(0.0f, 0.0f, 0.0f, 0.0f)); // For each position in the grid, find the corresponding pixel for (const auto& [id, pos] : Positions) { + // std::cout << "excessdebug g2.501." << id << std::endl; size_t size = Sizes.at(id); // Calculate pixel coordinates @@ -76,34 +79,42 @@ public: pixelXM = std::min(width - 1, pixelXM); pixelYm = std::max(0, pixelYm); pixelYM = std::min(height - 1, pixelYM); + // std::cout << "excessdebug g2.514." << id << std::endl; // Ensure within bounds if (pixelXM >= minCorner.x && pixelXm < width && pixelYM >= minCorner.y && pixelYm < height) { + // std::cout << "excessdebug g2.518." << id << " - (" << pixelXm << "," << pixelYM << ")" << std::endl; const Vec4& color = Colors.at(id); float srcAlpha = color.a; float invSrcAlpha = 1.0f - srcAlpha; for (int py = pixelYm; py <= pixelYM; ++py){ for (int px = pixelXm; px <= pixelXM; ++px){ - int index = (py * width + px) * 3; - Vec4& dest = rgbaBuffer[index]; + // std::cout << "excessdebug g2.524." << id << " - (" << py << "," << px << ")" << std::endl; + int index = (py * width + px); + Vec4 dest = rgbaBuffer[index]; - dest.r = color.r * srcAlpha + dest.r * invSrcAlpha; - dest.g = color.g * srcAlpha + dest.g * invSrcAlpha; - dest.b = color.b * srcAlpha + dest.b * invSrcAlpha; - dest.a = srcAlpha + dest.a * invSrcAlpha; + dest.r = color.r * srcAlpha + dest.r; // * invSrcAlpha; + dest.g = color.g * srcAlpha + dest.g; // * invSrcAlpha; + dest.b = color.b * srcAlpha + dest.b; // * invSrcAlpha; + dest.a = srcAlpha + dest.a; // * invSrcAlpha; + rgbaBuffer[index] = dest; } } } } - bgrData.resize(dest.size() * 4); - for (int i = 0; i < width * height; ++i) { + rgbData.resize(rgbaBuffer.size() * 3); + for (int i = 0; i < rgbaBuffer.size(); ++i) { const Vec4& color = rgbaBuffer[i]; int bgrIndex = i * 3; - // Convert from [0,1] to [0,255] and store as BGR - bgrData[bgrIndex + 0] = static_cast(color.b * 255); // Blue - bgrData[bgrIndex + 1] = static_cast(color.g * 255); // Green - bgrData[bgrIndex + 2] = static_cast(color.r * 255); // Red + // Convert from [0,1] to [0,255] and store as RGB + // rgbData.push_back(color.r); + // rgbData.push_back(color.g); + // rgbData.push_back(color.b); + rgbData[bgrIndex + 2] = static_cast(color.r * 255); + rgbData[bgrIndex + 1] = static_cast(color.g * 255); + rgbData[bgrIndex + 0] = static_cast(color.b * 255); + } }