Fadlhasn commited on
Commit
c04d49d
·
verified ·
1 Parent(s): 8115105

انشئ موقع تعليمي للرياضيات حيث يعتمد على تحويل المفاهيم النظرية الى تصور ويمكن عرض الريياضيات بطريقة حيوية والتلاعب بها لفهمها اكثر

Browse files
Files changed (8) hide show
  1. README.md +8 -5
  2. components/footer.js +83 -0
  3. components/navbar.js +50 -0
  4. index.html +100 -19
  5. math-visualizer.html +86 -0
  6. math-visualizer.js +217 -0
  7. script.js +26 -0
  8. style.css +39 -18
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Mathmagic Visualizer
3
- emoji: 💻
4
- colorFrom: red
5
- colorTo: pink
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: MathMagic Visualizer 🧮✨
3
+ colorFrom: yellow
4
+ colorTo: purple
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
components/footer.js ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomFooter extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ .footer-link {
7
+ transition: all 0.2s ease;
8
+ }
9
+ .footer-link:hover {
10
+ color: #0ea5e9;
11
+ transform: translateX(4px);
12
+ }
13
+ .social-icon {
14
+ transition: all 0.2s ease;
15
+ }
16
+ .social-icon:hover {
17
+ transform: translateY(-4px);
18
+ }
19
+ </style>
20
+ <footer class="bg-gray-800 text-white py-12">
21
+ <div class="container mx-auto px-6">
22
+ <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
23
+ <div class="md:col-span-2">
24
+ <div class="flex items-center space-x-2 mb-4">
25
+ <div class="w-8 h-8 rounded-full bg-gradient-to-r from-primary-500 to-secondary-500"></div>
26
+ <span class="text-xl font-bold">Chromatic Canvas</span>
27
+ </div>
28
+ <p class="text-gray-400 mb-4">Exploring the beauty of undefined design possibilities.</p>
29
+ <div class="flex space-x-4">
30
+ <a href="#" class="social-icon text-gray-400 hover:text-white">
31
+ <i data-feather="twitter"></i>
32
+ </a>
33
+ <a href="#" class="social-icon text-gray-400 hover:text-white">
34
+ <i data-feather="instagram"></i>
35
+ </a>
36
+ <a href="#" class="social-icon text-gray-400 hover:text-white">
37
+ <i data-feather="github"></i>
38
+ </a>
39
+ <a href="#" class="social-icon text-gray-400 hover:text-white">
40
+ <i data-feather="linkedin"></i>
41
+ </a>
42
+ </div>
43
+ </div>
44
+
45
+ <div>
46
+ <h3 class="text-lg font-semibold mb-4">Quick Links</h3>
47
+ <ul class="space-y-2">
48
+ <li><a href="#" class="footer-link text-gray-400">Home</a></li>
49
+ <li><a href="#" class="footer-link text-gray-400">Features</a></li>
50
+ <li><a href="#" class="footer-link text-gray-400">Gallery</a></li>
51
+ <li><a href="#" class="footer-link text-gray-400">About</a></li>
52
+ </ul>
53
+ </div>
54
+
55
+ <div>
56
+ <h3 class="text-lg font-semibold mb-4">Contact</h3>
57
+ <ul class="space-y-2">
58
+ <li class="flex items-center space-x-2 text-gray-400">
59
+ <i data-feather="mail"></i>
60
+ <span>hello@chromatic.com</span>
61
+ </li>
62
+ <li class="flex items-center space-x-2 text-gray-400">
63
+ <i data-feather="phone"></i>
64
+ <span>+1 (555) 123-4567</span>
65
+ </li>
66
+ <li class="flex items-center space-x-2 text-gray-400">
67
+ <i data-feather="map-pin"></i>
68
+ <span>123 Design St, Creative City</span>
69
+ </li>
70
+ </ul>
71
+ </div>
72
+ </div>
73
+
74
+ <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400">
75
+ <p>© ${new Date().getFullYear()} Chromatic Canvas. All rights reserved.</p>
76
+ </div>
77
+ </div>
78
+ </footer>
79
+ `;
80
+ }
81
+ }
82
+
83
+ customElements.define('custom-footer', CustomFooter);
components/navbar.js ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomNavbar extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ .navbar {
7
+ transition: all 0.3s ease;
8
+ }
9
+ .nav-link {
10
+ position: relative;
11
+ }
12
+ .nav-link:after {
13
+ content: '';
14
+ position: absolute;
15
+ width: 0;
16
+ height: 2px;
17
+ bottom: 0;
18
+ left: 0;
19
+ background-color: currentColor;
20
+ transition: width 0.3s ease;
21
+ }
22
+ .nav-link:hover:after {
23
+ width: 100%;
24
+ }
25
+ </style>
26
+ <nav class="navbar bg-white shadow-sm py-4 px-6">
27
+ <div class="container mx-auto flex justify-between items-center">
28
+ <a href="/" class="flex items-center space-x-2">
29
+ <div class="w-8 h-8 rounded-full bg-gradient-to-r from-primary-500 to-secondary-500"></div>
30
+ <span class="text-xl font-bold text-gray-800">Chromatic</span>
31
+ </a>
32
+
33
+ <div class="hidden md:flex space-x-8">
34
+ <a href="/" class="nav-link text-gray-600 hover:text-primary-600">Home</a>
35
+ <a href="math-visualizer.html" class="nav-link text-gray-600 hover:text-primary-600">Math Visualizer</a>
36
+ <a href="#" class="nav-link text-gray-600 hover:text-primary-600">Algebra</a>
37
+ <a href="#" class="nav-link text-gray-600 hover:text-primary-600">Geometry</a>
38
+ <a href="#" class="nav-link text-gray-600 hover:text-primary-600">Calculus</a>
39
+ </div>
40
+
41
+ <button class="md:hidden focus:outline-none">
42
+ <i data-feather="menu"></i>
43
+ </button>
44
+ </div>
45
+ </nav>
46
+ `;
47
+ }
48
+ }
49
+
50
+ customElements.define('custom-navbar', CustomNavbar);
index.html CHANGED
@@ -1,19 +1,100 @@
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.0">
6
+ <title>Chromatic Canvas</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script>
12
+ tailwind.config = {
13
+ theme: {
14
+ extend: {
15
+ colors: {
16
+ primary: {
17
+ 50: '#f0f9ff',
18
+ 100: '#e0f2fe',
19
+ 200: '#bae6fd',
20
+ 300: '#7dd3fc',
21
+ 400: '#38bdf8',
22
+ 500: '#0ea5e9',
23
+ 600: '#0284c7',
24
+ 700: '#0369a1',
25
+ 800: '#075985',
26
+ 900: '#0c4a6e',
27
+ },
28
+ secondary: {
29
+ 50: '#f5f3ff',
30
+ 100: '#ede9fe',
31
+ 200: '#ddd6fe',
32
+ 300: '#c4b5fd',
33
+ 400: '#a78bfa',
34
+ 500: '#8b5cf6',
35
+ 600: '#7c3aed',
36
+ 700: '#6d28d9',
37
+ 800: '#5b21b6',
38
+ 900: '#4c1d95',
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ </script>
45
+ </head>
46
+ <body class="bg-gray-50 min-h-screen">
47
+ <custom-navbar></custom-navbar>
48
+
49
+ <main class="container mx-auto px-4 py-12">
50
+ <section class="text-center mb-16">
51
+ <h1 class="text-5xl font-bold text-primary-700 mb-4">Chromatic Canvas</h1>
52
+ <p class="text-xl text-gray-600 max-w-2xl mx-auto">A vibrant playground of colors and design. Explore the beauty of undefined possibilities.</p>
53
+ </section>
54
+
55
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
56
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden transition-all hover:shadow-xl hover:-translate-y-1">
57
+ <div class="h-48 bg-gradient-to-r from-primary-400 to-secondary-500"></div>
58
+ <div class="p-6">
59
+ <h3 class="text-xl font-semibold text-gray-800 mb-2">Color Exploration</h3>
60
+ <p class="text-gray-600">Discover the endless combinations of our undefined color palette.</p>
61
+ </div>
62
+ </div>
63
+
64
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden transition-all hover:shadow-xl hover:-translate-y-1">
65
+ <div class="h-48 bg-gradient-to-r from-secondary-400 to-primary-500"></div>
66
+ <div class="p-6">
67
+ <h3 class="text-xl font-semibold text-gray-800 mb-2">Design Freedom</h3>
68
+ <p class="text-gray-600">Create without constraints in our undefined theme environment.</p>
69
+ </div>
70
+ </div>
71
+
72
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden transition-all hover:shadow-xl hover:-translate-y-1">
73
+ <div class="h-48 bg-gradient-to-r from-primary-300 to-secondary-600"></div>
74
+ <div class="p-6">
75
+ <h3 class="text-xl font-semibold text-gray-800 mb-2">Visual Harmony</h3>
76
+ <p class="text-gray-600">Experience the perfect balance of undefined elements.</p>
77
+ </div>
78
+ </div>
79
+ </div>
80
+
81
+ <section class="mt-20 bg-gradient-to-r from-primary-100 to-secondary-100 rounded-2xl p-8 md:p-12">
82
+ <div class="max-w-4xl mx-auto text-center">
83
+ <h2 class="text-3xl font-bold text-gray-800 mb-6">Ready to Explore?</h2>
84
+ <p class="text-lg text-gray-700 mb-8">Dive into our undefined world of design possibilities and create something truly unique.</p>
85
+ <button class="bg-primary-600 hover:bg-primary-700 text-white font-medium py-3 px-8 rounded-full transition-all shadow-md hover:shadow-lg">
86
+ Get Started
87
+ </button>
88
+ </div>
89
+ </section>
90
+ </main>
91
+
92
+ <custom-footer></custom-footer>
93
+
94
+ <script src="components/navbar.js"></script>
95
+ <script src="components/footer.js"></script>
96
+ <script src="script.js"></script>
97
+ <script>feather.replace();</script>
98
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
99
+ </body>
100
+ </html>
math-visualizer.html ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0">
6
+ <title>MathMagic Visualizer | Interactive Math Learning</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.6.0/math.min.js"></script>
11
+ <script src="https://unpkg.com/feather-icons"></script>
12
+ </head>
13
+ <body class="bg-gray-50 min-h-screen">
14
+ <custom-navbar></custom-navbar>
15
+
16
+ <main class="container mx-auto px-4 py-12">
17
+ <section class="text-center mb-16">
18
+ <h1 class="text-5xl font-bold text-primary-700 mb-4">MathMagic Visualizer</h1>
19
+ <p class="text-xl text-gray-600 max-w-2xl mx-auto">Transform abstract math concepts into interactive visual experiences.</p>
20
+ </section>
21
+
22
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-16">
23
+ <div class="bg-white p-6 rounded-xl shadow-lg">
24
+ <h2 class="text-2xl font-bold text-gray-800 mb-4">Function Explorer</h2>
25
+ <div class="mb-4">
26
+ <label class="block text-gray-700 mb-2">Enter function (e.g., sin(x), x^2):</label>
27
+ <input type="text" id="functionInput" class="w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" value="sin(x)">
28
+ </div>
29
+ <div class="h-64">
30
+ <canvas id="functionGraph"></canvas>
31
+ </div>
32
+ </div>
33
+
34
+ <div class="bg-white p-6 rounded-xl shadow-lg">
35
+ <h2 class="text-2xl font-bold text-gray-800 mb-4">Geometry Playground</h2>
36
+ <div class="mb-4 grid grid-cols-2 gap-4">
37
+ <button id="drawLine" class="bg-primary-100 hover:bg-primary-200 text-primary-700 py-2 px-4 rounded-lg transition">Line</button>
38
+ <button id="drawCircle" class="bg-primary-100 hover:bg-primary-200 text-primary-700 py-2 px-4 rounded-lg transition">Circle</button>
39
+ <button id="drawRectangle" class="bg-primary-100 hover:bg-primary-200 text-primary-700 py-2 px-4 rounded-lg transition">Rectangle</button>
40
+ <button id="drawTriangle" class="bg-primary-100 hover:bg-primary-200 text-primary-700 py-2 px-4 rounded-lg transition">Triangle</button>
41
+ </div>
42
+ <div class="h-64 border-2 border-dashed border-gray-300 rounded-lg relative" id="geometryCanvas">
43
+ <div class="absolute inset-0 flex items-center justify-center text-gray-400">Draw shapes here</div>
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <section class="bg-white rounded-xl shadow-lg overflow-hidden">
49
+ <div class="grid grid-cols-1 md:grid-cols-2">
50
+ <div class="p-8">
51
+ <h2 class="text-3xl font-bold text-gray-800 mb-4">Interactive Algebra</h2>
52
+ <p class="text-gray-600 mb-6">Manipulate equations in real-time to see how changes affect the graph.</p>
53
+ <div class="space-y-4">
54
+ <div>
55
+ <label class="block text-gray-700 mb-1">Equation: y = mx + b</label>
56
+ <div class="flex items-center space-x-4">
57
+ <div class="flex-1">
58
+ <label class="block text-sm text-gray-600 mb-1">Slope (m)</label>
59
+ <input type="range" id="sliderM" min="-5" max="5" step="0.1" value="1" class="w-full">
60
+ </div>
61
+ <div class="flex-1">
62
+ <label class="block text-sm text-gray-600 mb-1">Intercept (b)</label>
63
+ <input type="range" id="sliderB" min="-10" max="10" step="0.5" value="0" class="w-full">
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ <div class="bg-gray-50 p-8 flex items-center">
70
+ <div class="h-64 w-full">
71
+ <canvas id="algebraGraph"></canvas>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ </section>
76
+ </main>
77
+
78
+ <custom-footer></custom-footer>
79
+
80
+ <script src="components/navbar.js"></script>
81
+ <script src="components/footer.js"></script>
82
+ <script src="script.js"></script>
83
+ <script src="math-visualizer.js"></script>
84
+ <script>feather.replace();</script>
85
+ </body>
86
+ </html>
math-visualizer.js ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ // Function Graph Visualization
3
+ const functionCtx = document.getElementById('functionGraph').getContext('2d');
4
+ const algebraCtx = document.getElementById('algebraGraph').getContext('2d');
5
+
6
+ // Initialize function graph
7
+ const functionGraph = new Chart(functionCtx, {
8
+ type: 'line',
9
+ data: {
10
+ datasets: [{
11
+ label: 'Function',
12
+ borderColor: '#7c3aed',
13
+ backgroundColor: 'rgba(124, 58, 237, 0.1)',
14
+ borderWidth: 2,
15
+ pointRadius: 0,
16
+ fill: true
17
+ }]
18
+ },
19
+ options: {
20
+ responsive: true,
21
+ scales: {
22
+ x: {
23
+ type: 'linear',
24
+ position: 'center',
25
+ min: -10,
26
+ max: 10
27
+ },
28
+ y: {
29
+ type: 'linear',
30
+ position: 'center',
31
+ min: -5,
32
+ max: 5
33
+ }
34
+ }
35
+ }
36
+ });
37
+
38
+ // Initialize algebra graph
39
+ const algebraGraph = new Chart(algebraCtx, {
40
+ type: 'line',
41
+ data: {
42
+ datasets: [{
43
+ label: 'Linear Equation',
44
+ borderColor: '#0ea5e9',
45
+ backgroundColor: 'rgba(14, 165, 233, 0.1)',
46
+ borderWidth: 2,
47
+ pointRadius: 0
48
+ }]
49
+ },
50
+ options: {
51
+ responsive: true,
52
+ scales: {
53
+ x: {
54
+ type: 'linear',
55
+ position: 'center',
56
+ min: -10,
57
+ max: 10
58
+ },
59
+ y: {
60
+ type: 'linear',
61
+ position: 'center',
62
+ min: -10,
63
+ max: 10
64
+ }
65
+ }
66
+ }
67
+ });
68
+
69
+ // Update function graph when input changes
70
+ document.getElementById('functionInput').addEventListener('input', function() {
71
+ updateFunctionGraph();
72
+ });
73
+
74
+ function updateFunctionGraph() {
75
+ const func = document.getElementById('functionInput').value;
76
+ const data = [];
77
+
78
+ for (let x = -10; x <= 10; x += 0.1) {
79
+ try {
80
+ const y = math.evaluate(func, {x: x});
81
+ data.push({x: x, y: y});
82
+ } catch (e) {
83
+ console.error("Error evaluating function:", e);
84
+ }
85
+ }
86
+
87
+ functionGraph.data.datasets[0].data = data;
88
+ functionGraph.update();
89
+ }
90
+
91
+ // Update algebra graph with sliders
92
+ document.getElementById('sliderM').addEventListener('input', updateAlgebraGraph);
93
+ document.getElementById('sliderB').addEventListener('input', updateAlgebraGraph);
94
+
95
+ function updateAlgebraGraph() {
96
+ const m = parseFloat(document.getElementById('sliderM').value);
97
+ const b = parseFloat(document.getElementById('sliderB').value);
98
+
99
+ const data = [
100
+ {x: -10, y: m*-10 + b},
101
+ {x: 10, y: m*10 + b}
102
+ ];
103
+
104
+ algebraGraph.data.datasets[0].data = data;
105
+ algebraGraph.update();
106
+ }
107
+
108
+ // Initialize graphs
109
+ updateFunctionGraph();
110
+ updateAlgebraGraph();
111
+
112
+ // Geometry Canvas Interaction
113
+ const geometryCanvas = document.getElementById('geometryCanvas');
114
+ let isDrawing = false;
115
+ let currentShape = null;
116
+ let startX, startY;
117
+
118
+ document.getElementById('drawLine').addEventListener('click', () => setShapeMode('line'));
119
+ document.getElementById('drawCircle').addEventListener('click', () => setShapeMode('circle'));
120
+ document.getElementById('drawRectangle').addEventListener('click', () => setShapeMode('rectangle'));
121
+ document.getElementById('drawTriangle').addEventListener('click', () => setShapeMode('triangle'));
122
+
123
+ function setShapeMode(shape) {
124
+ currentShape = shape;
125
+ clearGeometryCanvas();
126
+ }
127
+
128
+ function clearGeometryCanvas() {
129
+ geometryCanvas.innerHTML = '<div class="absolute inset-0 flex items-center justify-center text-gray-400">Draw shapes here</div>';
130
+ }
131
+
132
+ geometryCanvas.addEventListener('mousedown', (e) => {
133
+ if (!currentShape) return;
134
+
135
+ isDrawing = true;
136
+ const rect = geometryCanvas.getBoundingClientRect();
137
+ startX = e.clientX - rect.left;
138
+ startY = e.clientY - rect.top;
139
+
140
+ // Clear instructions if present
141
+ if (geometryCanvas.querySelector('div')) {
142
+ geometryCanvas.innerHTML = '';
143
+ }
144
+ });
145
+
146
+ geometryCanvas.addEventListener('mousemove', (e) => {
147
+ if (!isDrawing || !currentShape) return;
148
+
149
+ const rect = geometryCanvas.getBoundingClientRect();
150
+ const endX = e.clientX - rect.left;
151
+ const endY = e.clientY - rect.top;
152
+
153
+ // Clear previous shape
154
+ geometryCanvas.innerHTML = '';
155
+
156
+ // Draw new shape
157
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
158
+ svg.setAttribute('width', '100%');
159
+ svg.setAttribute('height', '100%');
160
+ svg.style.position = 'absolute';
161
+
162
+ let shape;
163
+ switch (currentShape) {
164
+ case 'line':
165
+ shape = document.createElementNS("http://www.w3.org/2000/svg", "line");
166
+ shape.setAttribute('x1', startX);
167
+ shape.setAttribute('y1', startY);
168
+ shape.setAttribute('x2', endX);
169
+ shape.setAttribute('y2', endY);
170
+ shape.setAttribute('stroke', '#7c3aed');
171
+ shape.setAttribute('stroke-width', '2');
172
+ break;
173
+
174
+ case 'circle':
175
+ const radius = Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));
176
+ shape = document.createElementNS("http://www.w3.org/2000/svg", "circle");
177
+ shape.setAttribute('cx', startX);
178
+ shape.setAttribute('cy', startY);
179
+ shape.setAttribute('r', radius);
180
+ shape.setAttribute('fill', 'rgba(124, 58, 237, 0.2)');
181
+ shape.setAttribute('stroke', '#7c3aed');
182
+ shape.setAttribute('stroke-width', '2');
183
+ break;
184
+
185
+ case 'rectangle':
186
+ shape = document.createElementNS("http://www.w3.org/2000/svg", "rect");
187
+ shape.setAttribute('x', Math.min(startX, endX));
188
+ shape.setAttribute('y', Math.min(startY, endY));
189
+ shape.setAttribute('width', Math.abs(endX - startX));
190
+ shape.setAttribute('height', Math.abs(endY - startY));
191
+ shape.setAttribute('fill', 'rgba(124, 58, 237, 0.2)');
192
+ shape.setAttribute('stroke', '#7c3aed');
193
+ shape.setAttribute('stroke-width', '2');
194
+ break;
195
+
196
+ case 'triangle':
197
+ shape = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
198
+ const points = `${startX},${startY} ${endX},${endY} ${startX},${endY}`;
199
+ shape.setAttribute('points', points);
200
+ shape.setAttribute('fill', 'rgba(124, 58, 237, 0.2)');
201
+ shape.setAttribute('stroke', '#7c3aed');
202
+ shape.setAttribute('stroke-width', '2');
203
+ break;
204
+ }
205
+
206
+ svg.appendChild(shape);
207
+ geometryCanvas.appendChild(svg);
208
+ });
209
+
210
+ geometryCanvas.addEventListener('mouseup', () => {
211
+ isDrawing = false;
212
+ });
213
+
214
+ geometryCanvas.addEventListener('mouseleave', () => {
215
+ isDrawing = false;
216
+ });
217
+ });
script.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ document.addEventListener('DOMContentLoaded', () => {
3
+ // Add any global JavaScript functionality here
4
+ console.log('MathMagic Visualizer loaded!');
5
+
6
+ // Animate elements on scroll
7
+ const animateOnScroll = () => {
8
+ const elements = document.querySelectorAll('.fade-in, .slide-up');
9
+
10
+ elements.forEach(element => {
11
+ const elementPosition = element.getBoundingClientRect().top;
12
+ const screenPosition = window.innerHeight / 1.3;
13
+
14
+ if (elementPosition < screenPosition) {
15
+ element.style.opacity = '1';
16
+ element.style.transform = 'translateY(0)';
17
+ }
18
+ });
19
+ };
20
+
21
+ // Initial check
22
+ animateOnScroll();
23
+
24
+ // Check on scroll
25
+ window.addEventListener('scroll', animateOnScroll);
26
+ });
style.css CHANGED
@@ -1,28 +1,49 @@
 
 
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
2
+
3
  body {
4
+ font-family: 'Inter', sans-serif;
5
+ }
6
+
7
+ /* Custom scrollbar */
8
+ ::-webkit-scrollbar {
9
+ width: 8px;
10
+ height: 8px;
11
+ }
12
+
13
+ ::-webkit-scrollbar-track {
14
+ background: #f1f1f1;
15
+ }
16
+
17
+ ::-webkit-scrollbar-thumb {
18
+ background: #888;
19
+ border-radius: 4px;
20
  }
21
 
22
+ ::-webkit-scrollbar-thumb:hover {
23
+ background: #555;
 
24
  }
25
 
26
+ /* Animation classes */
27
+ .fade-in {
28
+ animation: fadeIn 0.5s ease-in-out;
 
 
29
  }
30
 
31
+ @keyframes fadeIn {
32
+ from { opacity: 0; }
33
+ to { opacity: 1; }
 
 
 
34
  }
35
 
36
+ .slide-up {
37
+ animation: slideUp 0.5s ease-out;
38
  }
39
+
40
+ @keyframes slideUp {
41
+ from {
42
+ opacity: 0;
43
+ transform: translateY(20px);
44
+ }
45
+ to {
46
+ opacity: 1;
47
+ transform: translateY(0);
48
+ }
49
+ }