File size: 5,618 Bytes
3447886 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Algorithm Visualizer | PawnStars</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>
<body class="bg-gray-900 text-white min-h-screen flex flex-col">
<custom-navbar></custom-navbar>
<main class="flex-1 p-4 max-w-7xl mx-auto w-full">
<h1 class="text-3xl font-bold mb-6 flex items-center gap-2">
<i data-feather="cpu"></i> Algorithm Visualizer
</h1>
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
<!-- Controls Panel -->
<div class="lg:col-span-1 space-y-4">
<!-- Algorithm Selection -->
<div class="bg-gray-800 rounded-xl p-4">
<h3 class="text-lg font-bold mb-3 flex items-center gap-2">
<i data-feather="git-branch"></i> Algorithm Type
</h3>
<select id="algorithm-category" class="w-full bg-gray-700 p-2 rounded mb-3">
<option value="sorting">Sorting Algorithms</option>
<option value="searching">Searching Algorithms</option>
<option value="pathfinding">Pathfinding Algorithms</option>
<option value="recursion">Recursive Algorithms</option>
</select>
<select id="algorithm-select" class="w-full bg-gray-700 p-2 rounded">
<option value="bubble-sort">Bubble Sort</option>
<option value="quick-sort">Quick Sort</option>
<option value="merge-sort">Merge Sort</option>
<option value="binary-search">Binary Search</option>
<option value="dijkstra">Dijkstra's Algorithm</option>
<option value="a-star">A* Search</option>
</select>
</div>
<!-- Controls -->
<div class="bg-gray-800 rounded-xl p-4">
<h3 class="text-lg font-bold mb-3 flex items-center gap-2">
<i data-feather="sliders"></i> Controls
</h3>
<div class="space-y-3">
<div>
<label class="block text-sm mb-1">Array Size</label>
<input type="range" id="array-size" min="5" max="50" value="20" class="w-full">
<span id="array-size-value" class="text-sm">20</span>
</div>
<div>
<label class="block text-sm mb-1">Speed</label>
<input type="range" id="speed" min="1" max="10" value="5" class="w-full">
<span id="speed-value" class="text-sm">Medium</span>
</div>
<button id="generate-array" class="w-full bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg transition-colors">
Generate New Array
</button>
</div>
</div>
<!-- Algorithm Info -->
<div class="bg-gray-800 rounded-xl p-4">
<h3 class="text-lg font-bold mb-3 flex items-center gap-2">
<i data-feather="info"></i> Algorithm Information
</h3>
<div id="algorithm-info" class="text-sm space-y-2">
<p><strong>Time Complexity:</strong> <span id="time-complexity">-</span></p>
<p><strong>Space Complexity:</strong> <span id="space-complexity">-</span></p>
<p id="algorithm-description">Select an algorithm to see its description</p>
</div>
</div>
</div>
<!-- Visualization Area -->
<div class="lg:col-span-3 space-y-6">
<div class="bg-gray-800 rounded-xl p-4">
<div class="flex flex-wrap gap-2 mb-4">
<button id="play-btn" class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded-lg flex items-center gap-2 transition-colors">
<i data-feather="play"></i> Play
</button>
<button id="pause-btn" class="bg-yellow-600 hover:bg-yellow-700 px-4 py-2 rounded-lg flex items-center gap-2 transition-colors">
<i data-feather="pause"></i> Pause
</button>
<button id="step-btn" class="bg-purple-600 hover:bg-purple-700 px-4 py-2 rounded-lg flex items-center gap-2 transition-colors">
<i data-feather="skip-forward"></i> Step
</button>
<button id="reset-btn" class="bg-red-600 hover:bg-red-700 px-4 py-2 rounded-lg flex items-center gap-2 transition-colors">
<i data-feather="rotate-ccw"></i> Reset
</button>
</div>
<!-- Visualization Canvas -->
<div id="visualization-container" class="bg-gray-700 rounded-lg p-4 min-h-96 flex items-end justify-center gap-1">
<!-- Array bars will be generated here -->
</div>
<!-- Code Display -->
<div class="bg-gray-800 rounded-xl p-4">
<h3 class="text-lg font-bold mb-3 flex items-center gap-2">
<i data-feather="code"></i> Pseudocode
</h3>
<div id="pseudocode" class="bg-gray-900 p-4 rounded font-mono text-sm overflow-x-auto">
// Code will be displayed here
</div>
</div>
</div>
</main>
<custom-footer></custom-footer>
<script src="components/navbar.js"></script>
<script src="components/footer.js"></script>
<script src="script.js"></script>
<script src="algorithms.js"></script>
<script>feather.replace();</script>
</body>
</html> |