ParthSadaria commited on
Commit
a829ba4
·
verified ·
1 Parent(s): 5f424f1

Update image-playground.html

Browse files
Files changed (1) hide show
  1. image-playground.html +41 -140
image-playground.html CHANGED
@@ -6,42 +6,39 @@
6
  <title>LOKI.AI IMAGE PLAYGROUND</title>
7
  <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
8
  <script src="https://cdn.tailwindcss.com"></script>
9
- <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
10
  <style>
11
  * {
12
  font-family: 'DM Sans', sans-serif;
13
- transition: all 0.3s ease;
14
  }
15
 
16
  body {
17
- background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
18
  min-height: 100vh;
19
  }
20
 
21
  .card {
22
- backdrop-filter: blur(10px);
23
- border: 1px solid rgba(255, 255, 255, 0.3);
24
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
25
- border-radius: 16px;
26
  }
27
 
28
  .pulse {
29
- animation: pulse 1.5s infinite;
30
  }
31
 
32
  @keyframes pulse {
33
- 0% { transform: scale(0.95); }
34
- 50% { transform: scale(1); }
35
- 100% { transform: scale(0.95); }
36
  }
37
 
38
  .loading {
39
- width: 48px;
40
- height: 48px;
41
- border: 5px solid #f5f5f5;
42
  border-bottom-color: #000;
43
  border-radius: 50%;
44
- animation: rotation 1s linear infinite;
45
  }
46
 
47
  @keyframes rotation {
@@ -50,58 +47,25 @@
50
  }
51
 
52
  .image-container {
 
53
  overflow: hidden;
54
- border-radius: 12px;
55
- }
56
-
57
- .image-container img {
58
- transition: transform 0.5s ease;
59
- }
60
-
61
- .image-container:hover img {
62
- transform: scale(1.05);
63
- }
64
-
65
- button {
66
- position: relative;
67
- overflow: hidden;
68
- }
69
-
70
- button:after {
71
- content: '';
72
- position: absolute;
73
- top: 50%;
74
- left: 50%;
75
- width: 100%;
76
- height: 100%;
77
- background: rgba(255, 255, 255, 0.3);
78
- border-radius: 50%;
79
- transform: scale(0);
80
- transition: transform 0.5s;
81
- pointer-events: none;
82
- }
83
-
84
- button:active:after {
85
- transform: scale(3);
86
- opacity: 0;
87
- transition: transform 0.5s, opacity 0.3s;
88
  }
89
  </style>
90
  </head>
91
- <body class="p-4 md:p-8">
92
  <div class="max-w-4xl mx-auto">
93
- <div class="card p-6 md:p-8 bg-white/80">
94
- <div class="flex flex-col md:flex-row items-center justify-between mb-8">
95
- <h1 class="text-3xl md:text-4xl font-bold bg-gradient-to-r from-black to-gray-700 bg-clip-text text-transparent mb-4 md:mb-0">LOKI.AI IMAGE PLAYGROUND</h1>
96
- <div class="pulse bg-black text-white px-4 py-1 rounded-full text-sm">Powered by LOKI.AI</div>
97
  </div>
98
 
99
- <div class="space-y-6">
100
- <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
101
  <div>
102
- <label for="model" class="block text-sm font-medium text-gray-700 mb-2">Select Model</label>
103
  <div class="relative">
104
- <select id="model" class="block w-full px-4 py-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-black appearance-none">
105
  <option value="Flux Realism">Flux Realism</option>
106
  <option value="Flux Pro Ultra">Flux Pro Ultra</option>
107
  <option value="grok-2-aurora">grok-2-aurora</option>
@@ -114,37 +78,36 @@
114
  <option value="dall-e-3">dall-e-3</option>
115
  </select>
116
  <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
117
- <svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
118
  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
119
  </svg>
120
  </div>
121
  </div>
122
  </div>
123
  <div>
124
- <label for="prompt" class="block text-sm font-medium text-gray-700 mb-2">Enter Prompt</label>
125
- <input type="text" id="prompt" placeholder="Describe what you want to see..." class="block w-full px-4 py-3 bg-gray-50 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-black" value="sky">
126
  </div>
127
  </div>
128
 
129
- <div class="flex flex-col items-center justify-center space-y-4">
130
- <button id="generate" class="w-full md:w-auto bg-black text-white px-8 py-3 rounded-lg font-medium hover:bg-gray-800 transform hover:scale-105 transition-all">
131
  Generate Image
132
  </button>
133
- <div id="status" class="text-sm text-gray-500 hidden">Processing your request...</div>
134
  </div>
135
 
136
- <div id="result" class="mt-6 hidden">
137
- <div class="text-center mb-6">
138
- <h2 class="text-xl font-medium">Your Creation</h2>
139
  <p class="text-sm text-gray-500">Created with <span id="model-used"></span></p>
140
  </div>
141
  <div class="image-container mx-auto max-w-lg">
142
- <img id="generated-image" class="w-full h-auto object-cover shadow-lg" src="" alt="Generated image">
143
  </div>
144
  <div class="mt-4 text-center">
145
- <button id="download" class="bg-gray-200 hover:bg-gray-300 text-black px-6 py-2 rounded-lg font-medium mt-4 transform hover:scale-105 transition-all">
146
  <span class="flex items-center justify-center">
147
- <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
148
  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path>
149
  </svg>
150
  Download
@@ -153,19 +116,19 @@
153
  </div>
154
  </div>
155
 
156
- <div id="loading" class="flex flex-col items-center justify-center py-10 hidden">
157
- <div class="loading mb-4"></div>
158
- <p class="text-gray-600">Creating your masterpiece...</p>
159
  </div>
160
 
161
- <div id="error" class="bg-red-50 text-red-800 p-4 rounded-lg hidden">
162
  <p class="font-medium">Oops! Something went wrong.</p>
163
  <p class="text-sm">Please try again or check your connection.</p>
164
  </div>
165
  </div>
166
  </div>
167
 
168
- <div class="text-center text-gray-500 text-xs mt-6">
169
  © 2025 LOKI.AI IMAGE PLAYGROUND | All rights reserved
170
  </div>
171
  </div>
@@ -180,46 +143,19 @@
180
  const resultDiv = document.getElementById('result');
181
  const loadingDiv = document.getElementById('loading');
182
  const errorDiv = document.getElementById('error');
183
- const statusDiv = document.getElementById('status');
184
  const generatedImage = document.getElementById('generated-image');
185
  const modelUsed = document.getElementById('model-used');
186
 
187
- // Animations with GSAP
188
- gsap.from('.card', {
189
- duration: 1,
190
- opacity: 0,
191
- y: 50,
192
- ease: 'power3.out'
193
- });
194
-
195
- gsap.from('h1', {
196
- duration: 1.2,
197
- opacity: 0,
198
- y: 20,
199
- delay: 0.3,
200
- ease: 'power3.out'
201
- });
202
-
203
- const staggerItems = [modelSelect, promptInput, generateBtn];
204
- gsap.from(staggerItems, {
205
- duration: 0.8,
206
- opacity: 0,
207
- y: 20,
208
- stagger: 0.2,
209
- delay: 0.5,
210
- ease: 'power3.out'
211
- });
212
-
213
  // Generate image
214
  generateBtn.addEventListener('click', async () => {
215
  const prompt = promptInput.value.trim();
216
  const model = modelSelect.value;
217
 
218
  if (!prompt) {
219
- promptInput.classList.add('ring-2', 'ring-red-500');
220
  setTimeout(() => {
221
- promptInput.classList.remove('ring-2', 'ring-red-500');
222
- }, 2000);
223
  return;
224
  }
225
 
@@ -227,7 +163,6 @@
227
  resultDiv.classList.add('hidden');
228
  errorDiv.classList.add('hidden');
229
  loadingDiv.classList.remove('hidden');
230
- statusDiv.classList.remove('hidden');
231
  generateBtn.disabled = true;
232
 
233
  try {
@@ -258,14 +193,6 @@
258
  // Assuming the response has an images array with base64 or URLs
259
  if (data.images && data.images.length > 0) {
260
  generatedImage.src = data.images[0];
261
-
262
- // Animate the image appearance
263
- gsap.from('#generated-image', {
264
- duration: 1,
265
- opacity: 0,
266
- scale: 0.9,
267
- ease: 'power3.out'
268
- });
269
  }
270
 
271
  } catch (error) {
@@ -274,7 +201,6 @@
274
  errorDiv.classList.remove('hidden');
275
  } finally {
276
  generateBtn.disabled = false;
277
- statusDiv.classList.add('hidden');
278
  }
279
  });
280
 
@@ -288,31 +214,6 @@
288
  document.body.appendChild(a);
289
  a.click();
290
  document.body.removeChild(a);
291
-
292
- // Animation feedback
293
- gsap.to('#download', {
294
- duration: 0.3,
295
- scale: 1.1,
296
- yoyo: true,
297
- repeat: 1
298
- });
299
- });
300
-
301
- // Add input animations
302
- promptInput.addEventListener('focus', () => {
303
- gsap.to(promptInput, {
304
- duration: 0.3,
305
- scale: 1.02,
306
- ease: 'power2.out'
307
- });
308
- });
309
-
310
- promptInput.addEventListener('blur', () => {
311
- gsap.to(promptInput, {
312
- duration: 0.3,
313
- scale: 1,
314
- ease: 'power2.in'
315
- });
316
  });
317
 
318
  // Enter key to generate
 
6
  <title>LOKI.AI IMAGE PLAYGROUND</title>
7
  <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
8
  <script src="https://cdn.tailwindcss.com"></script>
 
9
  <style>
10
  * {
11
  font-family: 'DM Sans', sans-serif;
 
12
  }
13
 
14
  body {
15
+ background-color: #fcfcfc;
16
  min-height: 100vh;
17
  }
18
 
19
  .card {
20
+ border: 1px solid rgba(0, 0, 0, 0.1);
21
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
22
+ border-radius: 12px;
 
23
  }
24
 
25
  .pulse {
26
+ animation: pulse 2.5s infinite;
27
  }
28
 
29
  @keyframes pulse {
30
+ 0% { opacity: 0.8; }
31
+ 50% { opacity: 1; }
32
+ 100% { opacity: 0.8; }
33
  }
34
 
35
  .loading {
36
+ width: 40px;
37
+ height: 40px;
38
+ border: 4px solid #f3f3f3;
39
  border-bottom-color: #000;
40
  border-radius: 50%;
41
+ animation: rotation 1.2s linear infinite;
42
  }
43
 
44
  @keyframes rotation {
 
47
  }
48
 
49
  .image-container {
50
+ border-radius: 8px;
51
  overflow: hidden;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
  </style>
54
  </head>
55
+ <body class="p-4 md:p-6">
56
  <div class="max-w-4xl mx-auto">
57
+ <div class="card p-6 bg-white">
58
+ <div class="flex flex-col md:flex-row items-center justify-between mb-6">
59
+ <h1 class="text-3xl font-bold text-black mb-2 md:mb-0">LOKI.AI IMAGE PLAYGROUND</h1>
60
+ <div class="pulse bg-black text-white px-3 py-1 rounded-full text-sm">Powered by LOKI.AI</div>
61
  </div>
62
 
63
+ <div class="space-y-4">
64
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
65
  <div>
66
+ <label for="model" class="block text-sm font-medium text-gray-700 mb-1">Select Model</label>
67
  <div class="relative">
68
+ <select id="model" class="block w-full px-3 py-2 bg-gray-50 border border-gray-200 rounded-lg focus:outline-none focus:ring-1 focus:ring-black appearance-none">
69
  <option value="Flux Realism">Flux Realism</option>
70
  <option value="Flux Pro Ultra">Flux Pro Ultra</option>
71
  <option value="grok-2-aurora">grok-2-aurora</option>
 
78
  <option value="dall-e-3">dall-e-3</option>
79
  </select>
80
  <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
81
+ <svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
82
  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
83
  </svg>
84
  </div>
85
  </div>
86
  </div>
87
  <div>
88
+ <label for="prompt" class="block text-sm font-medium text-gray-700 mb-1">Enter Prompt</label>
89
+ <input type="text" id="prompt" placeholder="Describe what you want to see..." class="block w-full px-3 py-2 bg-gray-50 border border-gray-200 rounded-lg focus:outline-none focus:ring-1 focus:ring-black" value="sky">
90
  </div>
91
  </div>
92
 
93
+ <div class="flex justify-center mt-2">
94
+ <button id="generate" class="bg-black text-white px-6 py-2 rounded-lg font-medium hover:bg-gray-800">
95
  Generate Image
96
  </button>
 
97
  </div>
98
 
99
+ <div id="result" class="mt-4 hidden">
100
+ <div class="text-center mb-4">
101
+ <h2 class="text-lg font-medium">Your Creation</h2>
102
  <p class="text-sm text-gray-500">Created with <span id="model-used"></span></p>
103
  </div>
104
  <div class="image-container mx-auto max-w-lg">
105
+ <img id="generated-image" class="w-full h-auto shadow-md" src="" alt="Generated image">
106
  </div>
107
  <div class="mt-4 text-center">
108
+ <button id="download" class="bg-gray-100 hover:bg-gray-200 text-black px-4 py-2 rounded-lg font-medium">
109
  <span class="flex items-center justify-center">
110
+ <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
111
  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path>
112
  </svg>
113
  Download
 
116
  </div>
117
  </div>
118
 
119
+ <div id="loading" class="flex flex-col items-center justify-center py-6 hidden">
120
+ <div class="loading mb-3"></div>
121
+ <p class="text-gray-600 text-sm">Creating your image...</p>
122
  </div>
123
 
124
+ <div id="error" class="bg-red-50 text-red-700 p-3 rounded-lg hidden">
125
  <p class="font-medium">Oops! Something went wrong.</p>
126
  <p class="text-sm">Please try again or check your connection.</p>
127
  </div>
128
  </div>
129
  </div>
130
 
131
+ <div class="text-center text-gray-400 text-xs mt-4">
132
  © 2025 LOKI.AI IMAGE PLAYGROUND | All rights reserved
133
  </div>
134
  </div>
 
143
  const resultDiv = document.getElementById('result');
144
  const loadingDiv = document.getElementById('loading');
145
  const errorDiv = document.getElementById('error');
 
146
  const generatedImage = document.getElementById('generated-image');
147
  const modelUsed = document.getElementById('model-used');
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  // Generate image
150
  generateBtn.addEventListener('click', async () => {
151
  const prompt = promptInput.value.trim();
152
  const model = modelSelect.value;
153
 
154
  if (!prompt) {
155
+ promptInput.style.borderColor = 'red';
156
  setTimeout(() => {
157
+ promptInput.style.borderColor = '';
158
+ }, 1500);
159
  return;
160
  }
161
 
 
163
  resultDiv.classList.add('hidden');
164
  errorDiv.classList.add('hidden');
165
  loadingDiv.classList.remove('hidden');
 
166
  generateBtn.disabled = true;
167
 
168
  try {
 
193
  // Assuming the response has an images array with base64 or URLs
194
  if (data.images && data.images.length > 0) {
195
  generatedImage.src = data.images[0];
 
 
 
 
 
 
 
 
196
  }
197
 
198
  } catch (error) {
 
201
  errorDiv.classList.remove('hidden');
202
  } finally {
203
  generateBtn.disabled = false;
 
204
  }
205
  });
206
 
 
214
  document.body.appendChild(a);
215
  a.click();
216
  document.body.removeChild(a);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  });
218
 
219
  // Enter key to generate