kolaslab commited on
Commit
8b1d6da
1 Parent(s): 0d487ba

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +217 -19
index.html CHANGED
@@ -1,19 +1,217 @@
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>AI Art Generator</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ body {
15
+ background: #0f0f1a;
16
+ color: #fff;
17
+ font-family: 'Segoe UI', sans-serif;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ padding: 2rem;
23
+ }
24
+
25
+ .container {
26
+ max-width: 1200px;
27
+ width: 100%;
28
+ }
29
+
30
+ .camera-container {
31
+ position: relative;
32
+ width: 640px;
33
+ height: 480px;
34
+ margin: 2rem auto;
35
+ border-radius: 15px;
36
+ overflow: hidden;
37
+ box-shadow: 0 0 20px rgba(0,0,255,0.3);
38
+ }
39
+
40
+ #video {
41
+ width: 100%;
42
+ height: 100%;
43
+ object-fit: cover;
44
+ transform: scaleX(-1);
45
+ }
46
+
47
+ #canvas {
48
+ position: absolute;
49
+ top: 0;
50
+ left: 0;
51
+ width: 100%;
52
+ height: 100%;
53
+ mix-blend-mode: difference;
54
+ }
55
+
56
+ .controls {
57
+ display: flex;
58
+ gap: 1rem;
59
+ justify-content: center;
60
+ margin: 2rem 0;
61
+ }
62
+
63
+ button {
64
+ background: #4a4af0;
65
+ color: white;
66
+ border: none;
67
+ padding: 1rem 2rem;
68
+ border-radius: 25px;
69
+ cursor: pointer;
70
+ font-size: 1rem;
71
+ transition: all 0.3s ease;
72
+ }
73
+
74
+ button:hover {
75
+ background: #2a2ad0;
76
+ transform: translateY(-2px);
77
+ }
78
+
79
+ .art-gallery {
80
+ display: grid;
81
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
82
+ gap: 2rem;
83
+ margin-top: 3rem;
84
+ }
85
+
86
+ .art-piece {
87
+ position: relative;
88
+ border-radius: 10px;
89
+ overflow: hidden;
90
+ transition: transform 0.3s ease;
91
+ }
92
+
93
+ .art-piece:hover {
94
+ transform: scale(1.05);
95
+ }
96
+
97
+ .art-piece canvas {
98
+ width: 100%;
99
+ height: 300px;
100
+ object-fit: cover;
101
+ }
102
+
103
+ @keyframes pulse {
104
+ 0% { transform: scale(1); }
105
+ 50% { transform: scale(1.05); }
106
+ 100% { transform: scale(1); }
107
+ }
108
+
109
+ .generating {
110
+ animation: pulse 2s infinite;
111
+ }
112
+ </style>
113
+ </head>
114
+ <body>
115
+ <div class="container">
116
+ <div class="camera-container">
117
+ <video id="video" autoplay></video>
118
+ <canvas id="canvas"></canvas>
119
+ </div>
120
+ <div class="controls">
121
+ <button id="generateBtn">Generate Art</button>
122
+ <button id="saveBtn">Save Artwork</button>
123
+ </div>
124
+ <div class="art-gallery" id="artGallery"></div>
125
+ </div>
126
+
127
+ <script>
128
+ const video = document.getElementById('video');
129
+ const canvas = document.getElementById('canvas');
130
+ const ctx = canvas.getContext('2d');
131
+ const generateBtn = document.getElementById('generateBtn');
132
+ const saveBtn = document.getElementById('saveBtn');
133
+ const artGallery = document.getElementById('artGallery');
134
+
135
+ // Set canvas dimensions
136
+ canvas.width = 640;
137
+ canvas.height = 480;
138
+
139
+ // Access webcam
140
+ async function initCamera() {
141
+ try {
142
+ const stream = await navigator.mediaDevices.getUserMedia({ video: true });
143
+ video.srcObject = stream;
144
+ } catch (err) {
145
+ console.error('Error accessing camera:', err);
146
+ }
147
+ }
148
+
149
+ // Boltzmann machine simulation (simplified)
150
+ function boltzmannGeneration(imageData) {
151
+ const data = imageData.data;
152
+ for (let i = 0; i < data.length; i += 4) {
153
+ // Add random noise and artistic effects
154
+ const noise = Math.random() * 50 - 25;
155
+ data[i] = Math.min(255, Math.max(0, data[i] + noise)); // Red
156
+ data[i + 1] = Math.min(255, Math.max(0, data[i + 1] + noise)); // Green
157
+ data[i + 2] = Math.min(255, Math.max(0, data[i + 2] + noise)); // Blue
158
+
159
+ // Add some artistic patterns
160
+ if (Math.random() > 0.99) {
161
+ data[i] = 255 - data[i];
162
+ data[i + 1] = 255 - data[i + 1];
163
+ data[i + 2] = 255 - data[i + 2];
164
+ }
165
+ }
166
+ return imageData;
167
+ }
168
+
169
+ function generateArt() {
170
+ generateBtn.classList.add('generating');
171
+
172
+ // Capture video frame
173
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
174
+
175
+ // Get image data and apply Boltzmann machine effects
176
+ let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
177
+ imageData = boltzmannGeneration(imageData);
178
+
179
+ // Apply additional artistic effects
180
+ ctx.putImageData(imageData, 0, 0);
181
+ ctx.globalCompositeOperation = 'overlay';
182
+ ctx.fillStyle = `hsla(${Math.random() * 360}, 50%, 50%, 0.3)`;
183
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
184
+
185
+ generateBtn.classList.remove('generating');
186
+ }
187
+
188
+ function saveArtwork() {
189
+ const artPiece = document.createElement('div');
190
+ artPiece.className = 'art-piece';
191
+
192
+ const artCanvas = document.createElement('canvas');
193
+ artCanvas.width = canvas.width;
194
+ artCanvas.height = canvas.height;
195
+ const artCtx = artCanvas.getContext('2d');
196
+ artCtx.drawImage(canvas, 0, 0);
197
+
198
+ artPiece.appendChild(artCanvas);
199
+ artGallery.insertBefore(artPiece, artGallery.firstChild);
200
+ }
201
+
202
+ // Event listeners
203
+ generateBtn.addEventListener('click', generateArt);
204
+ saveBtn.addEventListener('click', saveArtwork);
205
+
206
+ // Start camera
207
+ initCamera();
208
+
209
+ // Continuous drawing
210
+ function draw() {
211
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
212
+ requestAnimationFrame(draw);
213
+ }
214
+ requestAnimationFrame(draw);
215
+ </script>
216
+ </body>
217
+ </html>