@@ -113,21 +113,15 @@ ExitStatus App::Application::run() {
113113 const ImVec2 base_size = viewport->Size ;
114114
115115 static char function[1024 ] = " tanh(x)" ;
116+ static float zoom = 100 .0f ;
116117
117118 // Left Pane (expression)
118119 {
119120 ImGui::SetNextWindowPos (base_pos);
120121 ImGui::SetNextWindowSize (ImVec2 (base_size.x * 0 .25f , base_size.y ));
121- ImGui::Begin (" Left Pane" ,
122- nullptr ,
123- ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse |
124- ImGuiWindowFlags_NoTitleBar);
125-
126- ImGui::InputTextMultiline (" ##search" ,
127- function,
128- sizeof (function),
129- ImVec2 (-FLT_MIN, ImGui::GetTextLineHeight () * 4 ));
130-
122+ ImGui::Begin (" Left Pane" , nullptr , ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
123+ ImGui::InputTextMultiline (" ##search" , function, sizeof (function), ImVec2 (-FLT_MIN, ImGui::GetTextLineHeight () * 4 ));
124+ ImGui::SliderFloat (" Graph Scale" , &zoom, 10 .0f , 500 .0f , " %.1f" );
131125 ImGui::End ();
132126 }
133127
@@ -136,35 +130,15 @@ ExitStatus App::Application::run() {
136130 ImGui::PushStyleColor (ImGuiCol_WindowBg, ImVec4 (1 .0f , 1 .0f , 1 .0f , 1 .0f ));
137131 ImGui::SetNextWindowPos (ImVec2 (base_pos.x + base_size.x * 0 .25f , base_pos.y ));
138132 ImGui::SetNextWindowSize (ImVec2 (base_size.x * 0 .75f , base_size.y ));
139- ImGui::Begin (" Right Pane" ,
140- nullptr ,
141- ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse |
142- ImGuiWindowFlags_NoTitleBar);
143-
133+ ImGui::Begin (" Right Pane" , nullptr , ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
144134 ImDrawList* draw_list = ImGui::GetWindowDrawList ();
145-
146- // Define the graphing area within the window
147- const ImVec2 canvas_p0 = ImGui::GetCursorScreenPos (); // Top-left corner of the window
148- const ImVec2 canvas_sz = ImGui::GetContentRegionAvail (); // Size of the window
149- const auto canvas_p1 =
150- ImVec2 (canvas_p0.x + canvas_sz.x , canvas_p0.y + canvas_sz.y ); // Bottom-right
151-
152- // Define your coordinate system origin (e.g., center of the canvas)
135+ const ImVec2 canvas_p0 = ImGui::GetCursorScreenPos ();
136+ const ImVec2 canvas_sz = ImGui::GetContentRegionAvail ();
137+ const auto canvas_p1 = ImVec2 (canvas_p0.x + canvas_sz.x , canvas_p0.y + canvas_sz.y );
153138 const ImVec2 origin (canvas_p0.x + canvas_sz.x * 0 .5f , canvas_p0.y + canvas_sz.y * 0 .5f );
154-
155139 float lineThickness = 6 .0f ;
156-
157- // 1. Draw Axes
158- draw_list->AddLine (ImVec2 (canvas_p0.x , origin.y ),
159- ImVec2 (canvas_p1.x , origin.y ),
160- IM_COL32 (0 , 0 , 0 , 255 ),
161- lineThickness); // X-axis
162- draw_list->AddLine (ImVec2 (origin.x , canvas_p0.y ),
163- ImVec2 (origin.x , canvas_p1.y ),
164- IM_COL32 (0 , 0 , 0 , 255 ),
165- lineThickness); // Y-axis
166-
167- const float zoom = 100 .0f ; // Pixels per unit
140+ draw_list->AddLine (ImVec2 (canvas_p0.x , origin.y ), ImVec2 (canvas_p1.x , origin.y ), IM_COL32 (0 , 0 , 0 , 255 ), lineThickness);
141+ draw_list->AddLine (ImVec2 (origin.x , canvas_p0.y ), ImVec2 (origin.x , canvas_p1.y ), IM_COL32 (0 , 0 , 0 , 255 ), lineThickness);
168142 std::vector<ImVec2> points;
169143
170144 // (f(t), g(t))
0 commit comments