vscode commited on
Commit
d6f9734
·
verified ·
1 Parent(s): a2b4f4e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +561 -18
index.html CHANGED
@@ -1,19 +1,562 @@
1
  <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <title>Calculus Portfolio — Introduction to Calculus</title>
7
+
8
+ <!-- Google Font (single external resource) -->
9
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap" rel="stylesheet">
10
+
11
+ <style>
12
+ :root{
13
+ --bg:#0f1724;
14
+ --card:#0b1020;
15
+ --muted:#9aa7bf;
16
+ --accent:#7dd3fc;
17
+ --accent-2:#60a5fa;
18
+ --glass: rgba(255,255,255,0.04);
19
+ --success:#34d399;
20
+ --danger:#fb7185;
21
+ --radius:16px;
22
+ font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
23
+ }
24
+
25
+ *{box-sizing:border-box}
26
+ html,body{height:100%}
27
+ body{
28
+ margin:0;
29
+ background: linear-gradient(180deg, #071028 0%, #071a2e 65%);
30
+ color:#e6eef8;
31
+ -webkit-font-smoothing:antialiased;
32
+ -moz-osx-font-smoothing:grayscale;
33
+ padding:32px;
34
+ }
35
+
36
+ .wrap{
37
+ max-width:1100px;
38
+ margin:0 auto;
39
+ display:grid;
40
+ grid-template-columns: 380px 1fr;
41
+ gap:28px;
42
+ }
43
+
44
+ /* SIDEBAR */
45
+ aside{
46
+ background:linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
47
+ border-radius:var(--radius);
48
+ padding:22px;
49
+ box-shadow: 0 6px 30px rgba(2,6,23,0.6), inset 0 1px 0 rgba(255,255,255,0.02);
50
+ min-height:520px;
51
+ position:sticky;
52
+ top:32px;
53
+ overflow:hidden;
54
+ }
55
+
56
+ .logo{
57
+ display:flex;
58
+ gap:14px;
59
+ align-items:center;
60
+ margin-bottom:12px;
61
+ }
62
+ .logo .mark{
63
+ width:62px;
64
+ height:62px;
65
+ border-radius:12px;
66
+ background:linear-gradient(135deg,var(--accent),var(--accent-2));
67
+ display:flex;
68
+ align-items:center;
69
+ justify-content:center;
70
+ font-weight:800;
71
+ color:#04263b;
72
+ font-size:20px;
73
+ box-shadow: 0 8px 20px rgba(96,165,250,0.14);
74
+ }
75
+ .logo h1{
76
+ font-size:16px;
77
+ margin:0;
78
+ line-height:1;
79
+ letter-spacing:0.2px;
80
+ }
81
+ .logo p{margin:0;margin-top:4px;color:var(--muted);font-size:13px}
82
+
83
+ .meta{
84
+ display:flex;
85
+ gap:12px;
86
+ flex-wrap:wrap;
87
+ margin:18px 0 12px;
88
+ }
89
+ .chip{
90
+ background:var(--glass);
91
+ padding:8px 10px;
92
+ border-radius:10px;
93
+ font-size:13px;
94
+ color:var(--muted);
95
+ box-shadow: 0 3px 10px rgba(2,6,23,0.45);
96
+ }
97
+
98
+ .summary{
99
+ color:var(--muted);
100
+ font-size:14px;
101
+ line-height:1.55;
102
+ margin-bottom:14px;
103
+ }
104
+
105
+ .objectives{
106
+ margin-top:12px;
107
+ }
108
+ .objectives h3{font-size:13px;margin:0 0 8px;color:var(--accent)}
109
+ .objectives ul{margin:0;padding-left:18px;color:var(--muted);line-height:1.6;font-size:14px}
110
+
111
+ /* MAIN */
112
+ main{
113
+ background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
114
+ border-radius:var(--radius);
115
+ padding:26px;
116
+ min-height:520px;
117
+ box-shadow: 0 6px 40px rgba(2,6,23,0.6);
118
+ }
119
+
120
+ header.port{
121
+ display:flex;
122
+ align-items:center;
123
+ justify-content:space-between;
124
+ gap:12px;
125
+ margin-bottom:20px;
126
+ }
127
+ .title{
128
+ display:flex;
129
+ gap:16px;
130
+ align-items:center;
131
+ }
132
+ .title h2{
133
+ margin:0;font-size:20px;
134
+ }
135
+ .title p{margin:0;color:var(--muted);font-size:13px}
136
+
137
+ .badge{
138
+ background:linear-gradient(90deg,var(--accent-2),var(--accent));
139
+ color:#04263b;
140
+ padding:10px 14px;
141
+ border-radius:12px;
142
+ font-weight:700;
143
+ box-shadow: 0 8px 30px rgba(96,165,250,0.08);
144
+ }
145
+
146
+ /* Sections */
147
+ section.block{
148
+ margin-bottom:20px;
149
+ padding:16px;
150
+ background:linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.015));
151
+ border-radius:12px;
152
+ }
153
+ .block h3{margin:0 0 10px;font-size:16px}
154
+ .block p{margin:0;color:var(--muted);line-height:1.6}
155
+
156
+ .outline-grid{
157
+ display:grid;
158
+ grid-template-columns:repeat(2,1fr);
159
+ gap:12px;
160
+ margin-top:10px;
161
+ }
162
+ .outline-item{
163
+ background:rgba(255,255,255,0.02);
164
+ padding:12px;border-radius:10px;
165
+ border:1px solid rgba(255,255,255,0.02);
166
+ color:var(--muted);
167
+ font-size:14px;
168
+ }
169
+ .outline-item strong{display:block;color:#e6eef8;margin-bottom:6px}
170
+
171
+ /* Accordion */
172
+ .accordion{
173
+ margin-top:10px;
174
+ }
175
+ .acco-item{
176
+ border-radius:10px;
177
+ overflow:hidden;
178
+ margin-bottom:8px;
179
+ border:1px solid rgba(255,255,255,0.03);
180
+ }
181
+ .acco-head{
182
+ display:flex;justify-content:space-between;align-items:center;
183
+ padding:12px;background:transparent;cursor:pointer;
184
+ }
185
+ .acco-head h4{margin:0;font-size:15px}
186
+ .acco-body{
187
+ padding:12px 14px 16px;
188
+ color:var(--muted);
189
+ font-size:14px;
190
+ display:none;
191
+ line-height:1.6;
192
+ border-top:1px solid rgba(255,255,255,0.02);
193
+ }
194
+
195
+ /* Interactive demo */
196
+ .demo{
197
+ display:grid;
198
+ grid-template-columns: 1fr 260px;
199
+ gap:16px;
200
+ align-items:center;
201
+ margin-top:12px;
202
+ }
203
+ .graph{
204
+ background:linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.015));
205
+ border-radius:12px;padding:14px;
206
+ min-height:260px;
207
+ }
208
+
209
+ .controls{
210
+ padding:14px;border-radius:12px;background:rgba(255,255,255,0.02);
211
+ }
212
+ .controls label{display:block;font-size:13px;color:var(--muted);margin-bottom:8px}
213
+ .controls input[type="range"]{width:100%}
214
+ .controls .val{font-weight:700;color:#e6eef8;margin-top:8px}
215
+
216
+ footer.note{
217
+ display:flex;justify-content:space-between;align-items:center;
218
+ gap:10px;margin-top:16px;color:var(--muted);font-size:13px;
219
+ }
220
+
221
+ /* small screens */
222
+ @media (max-width:980px){
223
+ .wrap{grid-template-columns:1fr; padding:0 12px}
224
+ aside{position:relative;top:0}
225
+ .demo{grid-template-columns:1fr}
226
+ }
227
+
228
+ /* small decorative details */
229
+ .sparkle{
230
+ width:100%;height:6px;margin-bottom:12px;
231
+ background: linear-gradient(90deg, rgba(125,211,252,0.06), rgba(96,165,250,0.06));
232
+ border-radius:6px;
233
+ }
234
+
235
+ .cta{
236
+ display:inline-flex;gap:10px;align-items:center;padding:10px 14px;border-radius:12px;background:linear-gradient(90deg,var(--accent),var(--accent-2));color:#04263b;font-weight:700;border:none;cursor:pointer;
237
+ }
238
+
239
+ /* tiny legend dots */
240
+ .legend{display:flex;gap:8px;align-items:center;color:var(--muted);font-size:13px}
241
+ .dot{width:10px;height:10px;border-radius:50%}
242
+ .dot.sec{background:rgba(125,211,252,0.9)}
243
+ .dot.tan{background:rgba(96,165,250,0.9)}
244
+ </style>
245
+ </head>
246
+ <body>
247
+ <div class="wrap" role="main">
248
+ <!-- SIDEBAR -->
249
+ <aside aria-label="Course overview">
250
+ <div class="logo" role="banner">
251
+ <div class="mark">∫d</div>
252
+ <div>
253
+ <h1>Calculus Portfolio</h1>
254
+ <p>Introduction to Calculus — Differential & Integral</p>
255
+ </div>
256
+ </div>
257
+
258
+ <div class="sparkle" aria-hidden="true"></div>
259
+
260
+ <div class="meta" aria-hidden="true">
261
+ <div class="chip">Level: Introductory</div>
262
+ <div class="chip">Duration: 10–12 weeks</div>
263
+ <div class="chip">Format: Theory + Demo</div>
264
+ </div>
265
+
266
+ <p class="summary">
267
+ Calculus studies continuous change. This portfolio summarizes the course objectives, outline, key concepts (limits, derivatives, integrals), and includes a tiny interactive demo illustrating how a secant slope approaches a derivative (tangent slope).
268
+ </p>
269
+
270
+ <div class="objectives" aria-labelledby="obj">
271
+ <h3 id="obj">Course Objectives</h3>
272
+ <ul>
273
+ <li>Understand limits, derivatives & integrals</li>
274
+ <li>Apply techniques to physics, engineering & economics</li>
275
+ <li>Analyze & model real-world functions</li>
276
+ <li>Use derivatives to find maxima/minima</li>
277
+ </ul>
278
+ </div>
279
+
280
+ <div style="margin-top:14px">
281
+ <button class="cta" id="downloadBtn" title="Save as PDF (print)">
282
+ 📄 Save / Print
283
+ </button>
284
+ </div>
285
+
286
+ <div style="margin-top:18px">
287
+ <small style="color:var(--muted)">Author: Calculus Instructor • Prepared as a student portfolio</small>
288
+ </div>
289
+ </aside>
290
+
291
+ <!-- MAIN -->
292
+ <main>
293
+ <header class="port">
294
+ <div class="title">
295
+ <div>
296
+ <h2>Introduction to Calculus</h2>
297
+ <p>Understanding differential & integral calculus — core ideas, examples, and applications.</p>
298
+ </div>
299
+ </div>
300
+
301
+ <div class="badge">Essentials</div>
302
+ </header>
303
+
304
+ <!-- Course Outline -->
305
+ <section class="block" aria-labelledby="outlineTitle">
306
+ <h3 id="outlineTitle">Course Outline</h3>
307
+ <div class="outline-grid" role="list">
308
+ <div class="outline-item" role="listitem">
309
+ <strong>Differential Calculus</strong>
310
+ Limits • Derivatives • Applications (tangent lines, rates, optimization)
311
+ </div>
312
+ <div class="outline-item" role="listitem">
313
+ <strong>Integral Calculus</strong>
314
+ Indefinite/Definite Integrals • Techniques • Area & accumulation problems
315
+ </div>
316
+ <div class="outline-item" role="listitem">
317
+ <strong>Foundations</strong>
318
+ Limits, continuity, algebra of functions
319
+ </div>
320
+ <div class="outline-item" role="listitem">
321
+ <strong>Applications</strong>
322
+ Physics (velocity/acceleration), engineering, economics & area computations
323
+ </div>
324
+ </div>
325
+ </section>
326
+
327
+ <!-- Definitions and Concepts -->
328
+ <section class="block" aria-labelledby="defs">
329
+ <h3 id="defs">What is Calculus?</h3>
330
+ <p>
331
+ Calculus is the study of continuous change. Historically developed by Newton and Leibniz, it focuses on two complementary ideas:
332
+ </p>
333
+
334
+ <div class="accordion" id="accordion">
335
+ <div class="acco-item">
336
+ <button class="acco-head" data-target="a1"><h4>Differential Calculus</h4><span>▸</span></button>
337
+ <div class="acco-body" id="a1">
338
+ Differential calculus studies rates of change (derivatives). The derivative f'(x) = dy/dx measures how the function y = f(x) changes as x changes. It arises from the limit of a quotient: the slope of the secant line approaches the slope of the tangent line.
339
+ </div>
340
+ </div>
341
+
342
+ <div class="acco-item">
343
+ <button class="acco-head" data-target="a2"><h4>Integral Calculus</h4><span>▸</span></button>
344
+ <div class="acco-body" id="a2">
345
+ Integral calculus reverses differentiation: integration accumulates small pieces to get a whole. Indefinite integrals include an arbitrary constant (C); definite integrals compute accumulated values like area under a curve.
346
+ </div>
347
+ </div>
348
+
349
+ <div class="acco-item">
350
+ <button class="acco-head" data-target="a3"><h4>Limits & Continuity</h4><span>▸</span></button>
351
+ <div class="acco-body" id="a3">
352
+ Limits describe the behavior of a function as the input approaches a certain value. Continuity means the limit equals the function value. Limits are the foundation on which both derivatives and integrals are built.
353
+ </div>
354
+ </div>
355
+ </div>
356
+ </section>
357
+
358
+ <!-- Interactive mini-demo -->
359
+ <section class="block" aria-labelledby="demoTitle">
360
+ <h3 id="demoTitle">Interactive Demo — Secant → Tangent (Derivative)</h3>
361
+ <p style="margin-bottom:12px;color:var(--muted)">Use the slider to move the second point (h). The slope of the secant line approaches the tangent slope as h → 0 for f(x) = x² at x = 1.</p>
362
+
363
+ <div class="demo" role="application" aria-label="Derivative demo">
364
+ <div class="graph" id="svgWrap" aria-hidden="false">
365
+ <!-- SVG will be injected by JS -->
366
+ <svg id="calcSVG" width="100%" height="260" viewBox="0 0 600 260" preserveAspectRatio="xMinYMin meet" aria-label="Graph area" role="img"></svg>
367
+ </div>
368
+
369
+ <div class="controls" aria-hidden="false">
370
+ <label for="hRange">h (distance between points): <span id="hVal">0.8</span></label>
371
+ <input id="hRange" type="range" min="0.01" max="2" step="0.01" value="0.8" />
372
+ <div style="margin-top:12px">
373
+ <label for="xInput">Point x (evaluation point):</label>
374
+ <input id="xInput" type="number" value="1" step="0.1" style="width:100%;padding:8px;border-radius:8px;border:1px solid rgba(255,255,255,0.04);background:transparent;color:#e6eef8" />
375
+ </div>
376
+
377
+ <div class="val" style="margin-top:12px">
378
+ Secant slope: <strong id="secSlope">2.6</strong>
379
+ </div>
380
+ <div class="val" style="margin-top:6px">
381
+ Tangent (derivative) at x: <strong id="tanSlope">2</strong>
382
+ </div>
383
+
384
+ <div style="height:10px"></div>
385
+
386
+ <div class="legend" style="margin-top:10px">
387
+ <div class="dot sec" aria-hidden="true"></div><span>Secant</span>
388
+ <div style="width:8px"></div>
389
+ <div class="dot tan" aria-hidden="true"></div><span>Tangent</span>
390
+ </div>
391
+ </div>
392
+ </div>
393
+
394
+ <footer class="note">
395
+ <span>Formula shown uses f(x)=x². Derivative f'(x)=2x (so at x=1, tangent slope = 2).</span>
396
+ <span style="opacity:0.9">Try h → 0 to see secant slope approach 2.</span>
397
+ </footer>
398
+ </section>
399
+
400
+ <!-- More content -->
401
+ <section class="block" aria-labelledby="addTitle">
402
+ <h3 id="addTitle">Key Formulas & Notes</h3>
403
+ <p style="margin-bottom:8px;color:var(--muted)">
404
+ <strong>Derivative:</strong> f'(x) = limₕ→0 (f(x+h) - f(x))/h<br>
405
+ <strong>Indefinite Integral:</strong> ∫ f(x) dx = F(x) + C<br>
406
+ <strong>Definite Integral:</strong> ∫ₐᵇ f(x) dx = F(b) - F(a)
407
+ </p>
408
+
409
+ <div style="display:flex;gap:12px;flex-wrap:wrap;margin-top:8px">
410
+ <div class="chip">Applications: Motion, Area, Optimization</div>
411
+ <div class="chip">Tools: Analytical techniques, substitution, parts</div>
412
+ <div class="chip">Prereqs: Functions, algebra, exponents</div>
413
+ </div>
414
+ </section>
415
+
416
+ <!-- Closing -->
417
+ <section style="display:flex;justify-content:space-between;align-items:center;margin-top:8px">
418
+ <small style="color:var(--muted)">Prepared as a student portfolio • Clean, shareable, printable</small>
419
+ <div>
420
+ <button class="cta" id="toggleTheme">🌙 Toggle Theme</button>
421
+ </div>
422
+ </section>
423
+ </main>
424
+ </div>
425
+
426
+ <script>
427
+ /* ---------- Accordion ---------- */
428
+ document.querySelectorAll('.acco-head').forEach(btn=>{
429
+ btn.addEventListener('click', ()=>{
430
+ const target = btn.getAttribute('data-target');
431
+ const body = document.getElementById(target);
432
+ const open = body.style.display === 'block';
433
+ // close all
434
+ document.querySelectorAll('.acco-body').forEach(b=>b.style.display='none');
435
+ // rotate arrows
436
+ document.querySelectorAll('.acco-head span').forEach(s=>s.textContent='▸');
437
+ if(!open){
438
+ body.style.display='block';
439
+ btn.querySelector('span').textContent='▾';
440
+ }
441
+ });
442
+ });
443
+
444
+ // default open first
445
+ document.querySelector('.acco-head')?.click();
446
+
447
+ /* ---------- Print / Download ---------- */
448
+ document.getElementById('downloadBtn').addEventListener('click', ()=> {
449
+ window.print();
450
+ });
451
+
452
+ /* ---------- Theme Toggle (simple) ---------- */
453
+ const toggle = document.getElementById('toggleTheme');
454
+ let dark = true;
455
+ toggle.addEventListener('click', ()=>{
456
+ dark = !dark;
457
+ if(!dark){
458
+ document.body.style.background = 'linear-gradient(180deg,#f8fafc,#e6eef8)';
459
+ document.body.style.color = '#02263b';
460
+ document.querySelectorAll('aside, main').forEach(el=>{
461
+ el.style.background = 'linear-gradient(180deg, rgba(2,38,59,0.02), rgba(2,38,59,0.01))';
462
+ el.style.boxShadow = '0 6px 20px rgba(2,6,23,0.04)';
463
+ });
464
+ } else {
465
+ location.reload(); // quick reset to original styling
466
+ }
467
+ });
468
+
469
+ /* ---------- Interactive derivative demo (f(x)=x^2) ---------- */
470
+ (function(){
471
+ const svg = document.getElementById('calcSVG');
472
+ const w = 600, h = 260;
473
+ svg.setAttribute('viewBox','0 0 '+w+' '+h);
474
+
475
+ // coordinate mapping (x from -1 to 3, y from -1 to 9)
476
+ const xMin = -1, xMax = 3, yMin = -1, yMax = 9;
477
+ const mapX = x => ( (x - xMin) / (xMax - xMin) ) * (w-60) + 40;
478
+ const mapY = y => h - ( (y - yMin) / (yMax - yMin) ) * (h-40) - 20;
479
+
480
+ // draw axes + grid
481
+ function drawAxes(){
482
+ svg.innerHTML = '';
483
+ const ns = 'http://www.w3.org/2000/svg';
484
+
485
+ // grid lines
486
+ for(let gx = Math.ceil(xMin); gx<=Math.floor(xMax); gx++){
487
+ const xPos = mapX(gx);
488
+ const line = document.createElementNS(ns,'line');
489
+ line.setAttribute('x1',xPos); line.setAttribute('x2',xPos);
490
+ line.setAttribute('y1',20); line.setAttribute('y2',h-20);
491
+ line.setAttribute('stroke','rgba(255,255,255,0.02)');
492
+ line.setAttribute('stroke-width','1');
493
+ svg.appendChild(line);
494
+
495
+ const txt = document.createElementNS(ns,'text');
496
+ txt.setAttribute('x', xPos);
497
+ txt.setAttribute('y', h-6);
498
+ txt.setAttribute('fill','rgba(230,238,248,0.45)');
499
+ txt.setAttribute('font-size','10');
500
+ txt.setAttribute('text-anchor','middle');
501
+ txt.textContent = gx;
502
+ svg.appendChild(txt);
503
+ }
504
+
505
+ for(let gy = 0; gy<=8; gy+=1){
506
+ const yPos = mapY(gy);
507
+ const line = document.createElementNS(ns,'line');
508
+ line.setAttribute('y1',yPos); line.setAttribute('y2',yPos);
509
+ line.setAttribute('x1',40); line.setAttribute('x2',w-20);
510
+ line.setAttribute('stroke','rgba(255,255,255,0.02)');
511
+ line.setAttribute('stroke-width','1');
512
+ svg.appendChild(line);
513
+ }
514
+
515
+ // axes
516
+ const axisX = document.createElementNS(ns,'line');
517
+ axisX.setAttribute('x1',mapX(xMin)); axisX.setAttribute('x2',mapX(xMax));
518
+ axisX.setAttribute('y1', mapY(0)); axisX.setAttribute('y2', mapY(0));
519
+ axisX.setAttribute('stroke','rgba(230,238,248,0.12)');
520
+ axisX.setAttribute('stroke-width','1.5');
521
+ svg.appendChild(axisX);
522
+
523
+ const axisY = document.createElementNS(ns,'line');
524
+ axisY.setAttribute('x1',mapX(0)); axisY.setAttribute('x2',mapX(0));
525
+ axisY.setAttribute('y1', mapY(yMin)); axisY.setAttribute('y2', mapY(yMax));
526
+ axisY.setAttribute('stroke','rgba(230,238,248,0.12)');
527
+ axisY.setAttribute('stroke-width','1.5');
528
+ svg.appendChild(axisY);
529
+ }
530
+
531
+ function plotFunction(){
532
+ const ns = 'http://www.w3.org/2000/svg';
533
+ const path = document.createElementNS(ns,'path');
534
+ let d = '';
535
+ const steps = 200;
536
+ for(let i=0;i<=steps;i++){
537
+ const t = i/steps;
538
+ const x = xMin + t*(xMax - xMin);
539
+ const y = x*x; // f(x)=x^2
540
+ const px = mapX(x), py = mapY(y);
541
+ d += (i===0? 'M':'L') + px + ' ' + py + ' ';
542
+ }
543
+ path.setAttribute('d', d);
544
+ path.setAttribute('stroke','rgba(125,211,252,0.95)');
545
+ path.setAttribute('stroke-width','2.2');
546
+ path.setAttribute('fill','none');
547
+ svg.appendChild(path);
548
+ }
549
+
550
+ function drawPoints(x, h){
551
+ const ns = 'http://www.w3.org/2000/svg';
552
+ const x1 = x;
553
+ const x2 = x + h;
554
+ const y1 = x1*x1;
555
+ const y2 = x2*x2;
556
+
557
+ const p1x = mapX(x1), p1y = mapY(y1);
558
+ const p2x = mapX(x2), p2y = mapY(y2);
559
+
560
+ // points
561
+ const c1 = document.createElementNS(ns,'circle');
562
+ c1.setAttribute('cx',p1x); c1.setAttribute('cy',p1y); c1.setAttribute.