Skip to content

Commit c476028

Browse files
author
Oblarg
committed
fix newton's method seeding
1 parent 489eb70 commit c476028

5 files changed

Lines changed: 215 additions & 76 deletions

File tree

source/_extensions/controls_js_sim/dynamic-shooting.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class DynamicShootingWidget {
5858
this.controlDrawDiv.style.position = "relative";
5959
this.controlDrawDiv.style.zIndex = "10";
6060

61-
// Row 1: Mode toggle only
61+
// Row 1: Mode toggle (Simulation, Fractal iterations, Fractal interaction)
6262
const row1 = document.createElement("div");
6363
row1.style.cssText = "display: flex; align-items: center; justify-content: center; gap: 6px;";
6464
const simBtn = document.createElement("button");
@@ -67,14 +67,29 @@ class DynamicShootingWidget {
6767
simBtn.style.cssText = "padding: 2px 10px; font-size: 12px; cursor: pointer;";
6868
simBtn.onclick = function() { this.setMode("simulation"); }.bind(this);
6969
row1.appendChild(simBtn);
70-
const fractBtn = document.createElement("button");
71-
fractBtn.innerHTML = "Fractal";
72-
fractBtn.setAttribute("id", divIdPrefix + "_mode_fractal");
73-
fractBtn.style.cssText = "padding: 2px 10px; font-size: 12px; cursor: pointer;";
74-
fractBtn.onclick = function() { this.setMode("fractal"); }.bind(this);
75-
row1.appendChild(fractBtn);
70+
const fractIterBtn = document.createElement("button");
71+
fractIterBtn.innerHTML = "Fractal (Iterations)";
72+
fractIterBtn.setAttribute("id", divIdPrefix + "_mode_fractal_iter");
73+
fractIterBtn.style.cssText = "padding: 2px 10px; font-size: 12px; cursor: pointer;";
74+
fractIterBtn.onclick = function() {
75+
this.visualization.setFractalVariant("convergence");
76+
this.setMode("fractal");
77+
this.refreshModeButtons();
78+
}.bind(this);
79+
row1.appendChild(fractIterBtn);
80+
const fractInterBtn = document.createElement("button");
81+
fractInterBtn.innerHTML = "Fractal (Interaction)";
82+
fractInterBtn.setAttribute("id", divIdPrefix + "_mode_fractal_inter");
83+
fractInterBtn.style.cssText = "padding: 2px 10px; font-size: 12px; cursor: pointer;";
84+
fractInterBtn.onclick = function() {
85+
this.visualization.setFractalVariant("interaction");
86+
this.setMode("fractal");
87+
this.refreshModeButtons();
88+
}.bind(this);
89+
row1.appendChild(fractInterBtn);
7690
this.modeSimBtn = simBtn;
77-
this.modeFractalBtn = fractBtn;
91+
this.modeFractalIterBtn = fractIterBtn;
92+
this.modeFractalInterBtn = fractInterBtn;
7893
this.controlDrawDiv.appendChild(row1);
7994

8095
// Row 2: Iterations, speed, tolerance (same controls in both modes)
@@ -134,11 +149,18 @@ class DynamicShootingWidget {
134149
}.bind(this);
135150
controlBar.appendChild(nextButton);
136151

152+
this.refreshModeButtons = function() {
153+
const mode = this.mode;
154+
const variant = this.visualization.fractalVariant || "convergence";
155+
this.modeSimBtn.style.fontWeight = mode === "simulation" ? "bold" : "normal";
156+
this.modeFractalIterBtn.style.fontWeight = (mode === "fractal" && variant === "convergence") ? "bold" : "normal";
157+
this.modeFractalInterBtn.style.fontWeight = (mode === "fractal" && variant === "interaction") ? "bold" : "normal";
158+
}.bind(this);
159+
137160
this.setMode = function(mode) {
138161
this.mode = mode;
139162
this.visualization.setMode(mode);
140-
this.modeSimBtn.style.fontWeight = mode === "simulation" ? "bold" : "normal";
141-
this.modeFractalBtn.style.fontWeight = mode === "fractal" ? "bold" : "normal";
163+
this.refreshModeButtons();
142164
this.update();
143165
}.bind(this);
144166

0 commit comments

Comments
 (0)