import React, { useState } from 'react'; const SlopeInterceptWidget: React.FC = () => { const [m, setM] = useState(2); const [b, setB] = useState(1); // Visualization config const range = 10; const scale = 25; // px per unit const center = 150; const toPx = (val: number, isY = false) => isY ? center - val * scale : center + val * scale; // Points for triangle const p1 = { x: 0, y: b }; const p2 = { x: 1, y: m * 1 + b }; // Triangle vertex (1, b) const p3 = { x: 1, y: b }; return (
Equation
y = {m}x + {b}
setM(parseFloat(e.target.value))} className="w-full h-2 bg-blue-100 rounded-lg appearance-none cursor-pointer accent-blue-600 mt-2" />

Rate of Change (Rise / Run)

setB(parseFloat(e.target.value))} className="w-full h-2 bg-rose-100 rounded-lg appearance-none cursor-pointer accent-rose-600 mt-2" />

Starting Value (when x=0)

{/* Axes */} {/* The Line */} {/* Slope Triangle (between x=0 and x=1) */} {/* Intercept Point */} b={b} {/* Rise/Run Labels */} 0 ? 15 : -10)} textAnchor="middle" className="text-[10px] font-bold fill-blue-400">Run: 1 Rise: {m}
); }; export default SlopeInterceptWidget;