File size: 21,474 Bytes
ef7a581 |
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Drawing Board</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/@excalidraw/excalidraw@0/dist/excalidraw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<style>
.drawing-container {
height: calc(100vh - 180px);
}
.ai-suggestion {
transition: all 0.3s ease;
}
.ai-suggestion:hover {
transform: translateY(-5px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.animate-pulse {
animation: pulse 2s infinite;
}
</style>
</head>
<body class="bg-gray-100">
<div class="container mx-auto px-4 py-6">
<!-- Header -->
<header class="flex flex-col md:flex-row justify-between items-center mb-6">
<div class="flex items-center mb-4 md:mb-0">
<h1 class="text-3xl font-bold text-indigo-700">AI Drawing Board</h1>
<span class="ml-2 px-2 py-1 bg-indigo-100 text-indigo-800 text-xs font-semibold rounded-full">Beta</span>
</div>
<div class="flex space-x-2">
<button id="save-btn" class="px-4 py-2 bg-white border border-gray-300 rounded-lg shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500">
Save Drawing
</button>
<button id="clear-btn" class="px-4 py-2 bg-white border border-gray-300 rounded-lg shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500">
Clear Board
</button>
<button id="export-btn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg shadow-sm text-sm font-medium hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500">
Export as PNG
</button>
</div>
</header>
<!-- Main Content -->
<div class="flex flex-col lg:flex-row gap-6">
<!-- Drawing Canvas -->
<div class="flex-1 bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-4 border-b border-gray-200 bg-gray-50">
<h2 class="text-lg font-medium text-gray-900">Drawing Canvas</h2>
<p class="text-sm text-gray-500">Draw freely or use AI suggestions</p>
</div>
<div id="drawing-container" class="drawing-container"></div>
</div>
<!-- AI Panel -->
<div class="w-full lg:w-80 bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-4 border-b border-gray-200 bg-gray-50">
<h2 class="text-lg font-medium text-gray-900">AI Assistant</h2>
<p class="text-sm text-gray-500">Get creative suggestions</p>
</div>
<div class="p-4 space-y-4">
<!-- AI Prompt Input -->
<div>
<label for="ai-prompt" class="block text-sm font-medium text-gray-700 mb-1">Describe what you want to draw</label>
<div class="flex">
<input type="text" id="ai-prompt" class="flex-1 px-3 py-2 border border-gray-300 rounded-l-lg focus:ring-indigo-500 focus:border-indigo-500" placeholder="e.g. a sunset over mountains">
<button id="generate-btn" class="px-4 py-2 bg-indigo-600 text-white rounded-r-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500">
Generate
</button>
</div>
</div>
<!-- AI Suggestions -->
<div>
<h3 class="text-sm font-medium text-gray-700 mb-2">Quick Suggestions</h3>
<div class="grid grid-cols-2 gap-2">
<button class="ai-suggestion px-3 py-2 bg-indigo-50 text-indigo-700 text-xs font-medium rounded-lg hover:bg-indigo-100">
Simple House
</button>
<button class="ai-suggestion px-3 py-2 bg-indigo-50 text-indigo-700 text-xs font-medium rounded-lg hover:bg-indigo-100">
Tree Landscape
</button>
<button class="ai-suggestion px-3 py-2 bg-indigo-50 text-indigo-700 text-xs font-medium rounded-lg hover:bg-indigo-100">
Abstract Art
</button>
<button class="ai-suggestion px-3 py-2 bg-indigo-50 text-indigo-700 text-xs font-medium rounded-lg hover:bg-indigo-100">
Flow Chart
</button>
</div>
</div>
<!-- AI Processing -->
<div id="ai-processing" class="hidden p-4 bg-blue-50 rounded-lg">
<div class="flex items-center space-x-2 text-blue-700">
<svg class="animate-spin h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span>AI is generating your drawing...</span>
</div>
</div>
<!-- AI Results -->
<div id="ai-results" class="space-y-3 hidden">
<h3 class="text-sm font-medium text-gray-700">AI Suggestions</h3>
<div class="grid grid-cols-2 gap-2">
<div class="ai-suggestion p-2 bg-white border border-gray-200 rounded-lg cursor-pointer hover:border-indigo-300">
<div class="h-20 bg-gray-100 rounded mb-1"></div>
<p class="text-xs text-gray-600 truncate">Option 1</p>
</div>
<div class="ai-suggestion p-2 bg-white border border-gray-200 rounded-lg cursor-pointer hover:border-indigo-300">
<div class="h-20 bg-gray-100 rounded mb-1"></div>
<p class="text-xs text-gray-600 truncate">Option 2</p>
</div>
<div class="ai-suggestion p-2 bg-white border border-gray-200 rounded-lg cursor-pointer hover:border-indigo-300">
<div class="h-20 bg-gray-100 rounded mb-1"></div>
<p class="text-xs text-gray-600 truncate">Option 3</p>
</div>
<div class="ai-suggestion p-2 bg-white border border-gray-200 rounded-lg cursor-pointer hover:border-indigo-300">
<div class="h-20 bg-gray-100 rounded mb-1"></div>
<p class="text-xs text-gray-600 truncate">Option 4</p>
</div>
</div>
</div>
<!-- AI Tools -->
<div class="pt-4 border-t border-gray-200">
<h3 class="text-sm font-medium text-gray-700 mb-2">AI Enhancement Tools</h3>
<div class="space-y-2">
<button class="w-full flex items-center justify-between px-3 py-2 bg-white border border-gray-200 rounded-lg hover:bg-gray-50">
<span class="text-sm text-gray-700">Improve Drawing</span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</button>
<button class="w-full flex items-center justify-between px-3 py-2 bg-white border border-gray-200 rounded-lg hover:bg-gray-50">
<span class="text-sm text-gray-700">Add Color Palette</span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</button>
<button class="w-full flex items-center justify-between px-3 py-2 bg-white border border-gray-200 rounded-lg hover:bg-gray-50">
<span class="text-sm text-gray-700">Convert to Diagram</span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Recent Drawings -->
<div class="mt-8 bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-4 border-b border-gray-200 bg-gray-50">
<h2 class="text-lg font-medium text-gray-900">Recent Drawings</h2>
<p class="text-sm text-gray-500">Your saved creations</p>
</div>
<div class="p-4">
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
<div class="relative group">
<div class="h-32 bg-gray-100 rounded-lg"></div>
<div class="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-20 rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-200">
<button class="p-2 bg-white rounded-full shadow-md text-indigo-600 hover:bg-indigo-50">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
</svg>
</button>
</div>
</div>
<div class="relative group">
<div class="h-32 bg-gray-100 rounded-lg"></div>
<div class="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-20 rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-200">
<button class="p-2 bg-white rounded-full shadow-md text-indigo-600 hover:bg-indigo-50">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
</svg>
</button>
</div>
</div>
<div class="relative group">
<div class="h-32 bg-gray-100 rounded-lg"></div>
<div class="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-20 rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-200">
<button class="p-2 bg-white rounded-full shadow-md text-indigo-600 hover:bg-indigo-50">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
</svg>
</button>
</div>
</div>
<div class="relative group">
<div class="h-32 bg-gray-100 rounded-lg"></div>
<div class="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-20 rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-200">
<button class="p-2 bg-white rounded-full shadow-md text-indigo-600 hover:bg-indigo-50">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
</svg>
</button>
</div>
</div>
<div class="relative group">
<div class="h-32 bg-gray-100 rounded-lg"></div>
<div class="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-20 rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-200">
<button class="p-2 bg-white rounded-full shadow-md text-indigo-600 hover:bg-indigo-50">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
</svg>
</button>
</div>
</div>
<div class="relative flex items-center justify-center h-32 bg-gray-50 border-2 border-dashed border-gray-300 rounded-lg hover:border-gray-400 cursor-pointer">
<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-8 w-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg>
<span class="text-sm text-gray-600">New Drawing</span>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Initialize Excalidraw
const excalidrawWrapper = document.getElementById("drawing-container");
const { Excalidraw, exportToCanvas } = EXCALIDRAW;
let excalidrawAPI = null;
const initExcalidraw = async () => {
excalidrawAPI = new Excalidraw({
width: excalidrawWrapper.offsetWidth,
height: excalidrawWrapper.offsetHeight,
});
excalidrawWrapper.appendChild(excalidrawAPI);
// Set theme based on system preference
const isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
excalidrawAPI.updateScene({
appState: { theme: isDark ? "dark" : "light" }
});
// Load any saved data
const savedData = localStorage.getItem('excalidraw-data');
if (savedData) {
excalidrawAPI.updateScene(JSON.parse(savedData));
}
};
// Event Listeners
document.getElementById('save-btn').addEventListener('click', () => {
const sceneData = excalidrawAPI.getSceneData();
localStorage.setItem('excalidraw-data', JSON.stringify(sceneData));
// Show success message
const saveBtn = document.getElementById('save-btn');
const originalText = saveBtn.textContent;
saveBtn.textContent = 'Saved!';
saveBtn.classList.remove('bg-white');
saveBtn.classList.add('bg-green-100', 'text-green-800');
setTimeout(() => {
saveBtn.textContent = originalText;
saveBtn.classList.remove('bg-green-100', 'text-green-800');
saveBtn.classList.add('bg-white');
}, 2000);
});
document.getElementById('clear-btn').addEventListener('click', () => {
if (confirm('Are you sure you want to clear the drawing board?')) {
excalidrawAPI.resetScene();
}
});
document.getElementById('export-btn').addEventListener('click', async () => {
const canvas = await exportToCanvas({
elements: excalidrawAPI.getSceneElements(),
appState: excalidrawAPI.getAppState(),
files: excalidrawAPI.getFiles(),
});
const link = document.createElement('a');
link.download = 'drawing.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
document.getElementById('generate-btn').addEventListener('click', () => {
const prompt = document.getElementById('ai-prompt').value.trim();
if (!prompt) {
alert('Please enter a description for the AI');
return;
}
// Show processing
document.getElementById('ai-processing').classList.remove('hidden');
document.getElementById('ai-results').classList.add('hidden');
// Simulate AI processing (in a real app, this would call an API)
setTimeout(() => {
document.getElementById('ai-processing').classList.add('hidden');
document.getElementById('ai-results').classList.remove('hidden');
// Update the suggestion boxes with the prompt
const suggestionBoxes = document.querySelectorAll('#ai-results .ai-suggestion p');
suggestionBoxes.forEach((box, index) => {
box.textContent = `${prompt} - Variation ${index + 1}`;
});
}, 2000);
});
// Quick suggestion buttons
document.querySelectorAll('.ai-suggestion').forEach(button => {
button.addEventListener('click', function() {
const suggestion = this.textContent.trim();
document.getElementById('ai-prompt').value = suggestion;
});
});
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
initExcalidraw();
// Watch for window resize
window.addEventListener('resize', () => {
if (excalidrawAPI) {
excalidrawAPI.updateScene({
appState: {
...excalidrawAPI.getAppState(),
width: excalidrawWrapper.offsetWidth,
height: excalidrawWrapper.offsetHeight
}
});
}
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=chaojie/aiboard" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |