canvasframework 0.5.16 → 0.5.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/canvasframework.js +2 -0
  2. package/dist/canvasframework.js.LICENSE.txt +1 -0
  3. package/package.json +18 -17
  4. package/components/Accordion.js +0 -265
  5. package/components/AndroidDatePickerDialog.js +0 -406
  6. package/components/AppBar.js +0 -398
  7. package/components/AudioPlayer.js +0 -611
  8. package/components/Avatar.js +0 -202
  9. package/components/Banner.js +0 -342
  10. package/components/BottomNavigationBar.js +0 -433
  11. package/components/BottomSheet.js +0 -234
  12. package/components/Button.js +0 -360
  13. package/components/Camera.js +0 -644
  14. package/components/Card.js +0 -193
  15. package/components/Chart.js +0 -700
  16. package/components/Checkbox.js +0 -166
  17. package/components/Chip.js +0 -212
  18. package/components/CircularProgress.js +0 -327
  19. package/components/ContextMenu.js +0 -116
  20. package/components/DatePicker.js +0 -298
  21. package/components/Dialog.js +0 -337
  22. package/components/Divider.js +0 -125
  23. package/components/Drawer.js +0 -276
  24. package/components/FAB.js +0 -270
  25. package/components/FileUpload.js +0 -315
  26. package/components/FloatedCamera.js +0 -644
  27. package/components/IOSDatePickerWheel.js +0 -430
  28. package/components/ImageCarousel.js +0 -219
  29. package/components/ImageComponent.js +0 -223
  30. package/components/Input.js +0 -831
  31. package/components/InputDatalist.js +0 -723
  32. package/components/InputTags.js +0 -624
  33. package/components/List.js +0 -95
  34. package/components/ListItem.js +0 -269
  35. package/components/Modal.js +0 -364
  36. package/components/MorphingFAB.js +0 -428
  37. package/components/MultiSelectDialog.js +0 -206
  38. package/components/NumberInput.js +0 -271
  39. package/components/PasswordInput.js +0 -462
  40. package/components/ProgressBar.js +0 -88
  41. package/components/QRCodeReader.js +0 -539
  42. package/components/RadioButton.js +0 -151
  43. package/components/SearchInput.js +0 -315
  44. package/components/SegmentedControl.js +0 -357
  45. package/components/Select.js +0 -199
  46. package/components/SelectDialog.js +0 -255
  47. package/components/Slider.js +0 -113
  48. package/components/SliverAppBar.js +0 -139
  49. package/components/Snackbar.js +0 -243
  50. package/components/SpeedDialFAB.js +0 -397
  51. package/components/Stepper.js +0 -281
  52. package/components/SwipeableListItem.js +0 -327
  53. package/components/Switch.js +0 -147
  54. package/components/Table.js +0 -492
  55. package/components/Tabs.js +0 -423
  56. package/components/Text.js +0 -141
  57. package/components/TextField.js +0 -151
  58. package/components/TimePicker.js +0 -934
  59. package/components/Toast.js +0 -236
  60. package/components/TreeView.js +0 -420
  61. package/components/Video.js +0 -397
  62. package/components/View.js +0 -140
  63. package/components/VirtualList.js +0 -120
  64. package/core/CanvasFramework.js +0 -3034
  65. package/core/Component.js +0 -243
  66. package/core/ThemeManager.js +0 -358
  67. package/core/UIBuilder.js +0 -267
  68. package/core/WebGLCanvasAdapter.js +0 -782
  69. package/features/Column.js +0 -43
  70. package/features/Grid.js +0 -47
  71. package/features/LayoutComponent.js +0 -43
  72. package/features/OpenStreetMap.js +0 -310
  73. package/features/Positioned.js +0 -33
  74. package/features/PullToRefresh.js +0 -328
  75. package/features/Row.js +0 -40
  76. package/features/SignaturePad.js +0 -257
  77. package/features/Skeleton.js +0 -193
  78. package/features/Stack.js +0 -21
  79. package/index.js +0 -119
  80. package/manager/AccessibilityManager.js +0 -107
  81. package/manager/ErrorHandler.js +0 -59
  82. package/manager/FeatureFlags.js +0 -60
  83. package/manager/MemoryManager.js +0 -107
  84. package/manager/PerformanceMonitor.js +0 -84
  85. package/manager/SecurityManager.js +0 -54
  86. package/utils/AnimationEngine.js +0 -734
  87. package/utils/CryptoManager.js +0 -303
  88. package/utils/DataStore.js +0 -403
  89. package/utils/DevTools.js +0 -1618
  90. package/utils/DevToolsConsole.js +0 -201
  91. package/utils/EventBus.js +0 -407
  92. package/utils/FetchClient.js +0 -74
  93. package/utils/FirebaseAuth.js +0 -653
  94. package/utils/FirebaseCore.js +0 -246
  95. package/utils/FirebaseFirestore.js +0 -581
  96. package/utils/FirebaseFunctions.js +0 -97
  97. package/utils/FirebaseRealtimeDB.js +0 -498
  98. package/utils/FirebaseStorage.js +0 -612
  99. package/utils/FormValidator.js +0 -355
  100. package/utils/GeoLocationService.js +0 -62
  101. package/utils/I18n.js +0 -207
  102. package/utils/IndexedDBManager.js +0 -273
  103. package/utils/InspectionOverlay.js +0 -308
  104. package/utils/NotificationManager.js +0 -60
  105. package/utils/OfflineSyncManager.js +0 -342
  106. package/utils/PayPalPayment.js +0 -678
  107. package/utils/QueryBuilder.js +0 -478
  108. package/utils/SafeArea.js +0 -64
  109. package/utils/SecureStorage.js +0 -289
  110. package/utils/StateManager.js +0 -207
  111. package/utils/StripePayment.js +0 -552
  112. package/utils/WebSocketClient.js +0 -66
@@ -1,644 +0,0 @@
1
- import Component from '../core/Component.js';
2
-
3
- /**
4
- * Composant Camera autonome avec gestion directe des clics/touches
5
- * Modes : contain (tout visible + bandes), cover (remplit + crop), fit (centre sans crop)
6
- */
7
- class FloatedCamera extends Component {
8
- constructor(framework, options = {}) {
9
- super(framework, options);
10
-
11
- this.facingMode = options.facingMode || 'environment';
12
- this.autoStart = options.autoStart !== false;
13
- this.onPhoto = options.onPhoto || null;
14
-
15
- this.fitModes = ['contain', 'cover'];
16
- this.currentFitModeIndex = 0;
17
- this.fitMode = this.fitModes[this.currentFitModeIndex];
18
-
19
- this.stream = null;
20
- this.video = null;
21
- this.loaded = false;
22
- this.error = null;
23
-
24
- this.showControls = true;
25
- this.torchSupported = false;
26
- this.torchOn = false;
27
- this.captureButtonRadius = 35;
28
- this.modeButtonSize = 40;
29
-
30
- // Feedback capture
31
- this.flashTimer = null;
32
- this.previewPhoto = null; // dataUrl dernière photo
33
- this.previewTimeout = null;
34
-
35
- this.isStarting = false;
36
- }
37
-
38
- static cleanupAllCameras() {
39
- const allVideos = document.querySelectorAll('video');
40
- allVideos.forEach(video => {
41
- // Arrêter les streams
42
- if (video.srcObject) {
43
- const stream = video.srcObject;
44
- if (stream && stream.getTracks) {
45
- stream.getTracks().forEach(track => track.stop());
46
- }
47
- video.srcObject = null;
48
- }
49
-
50
- // Supprimer du DOM
51
- if (video.parentNode) {
52
- video.parentNode.removeChild(video);
53
- }
54
- });
55
- }
56
-
57
- async _mount() {
58
- super._mount?.();
59
-
60
- // Redémarrage auto si besoin
61
- if (this.autoStart && !this.stream && !this.isStarting) {
62
- this.isStarting = true;
63
- await this.startCamera();
64
- this.isStarting = false;
65
- }
66
-
67
- this.setupEventListeners();
68
- }
69
-
70
- destroy() {
71
- this.removeEventListeners();
72
- this.stopCamera();
73
- if (this.flashTimer) clearTimeout(this.flashTimer);
74
- if (this.previewTimeout) clearTimeout(this.previewTimeout);
75
- super.destroy?.();
76
- }
77
-
78
- // Écoute directe (indépendante du framework)
79
- setupEventListeners() {
80
- this.onTouchStart = this.handleTouchStart.bind(this);
81
- this.onTouchMove = this.handleTouchMove.bind(this);
82
- this.onTouchEnd = this.handleTouchEnd.bind(this);
83
- this.onMouseDown = this.handleMouseDown.bind(this);
84
- this.onMouseMove = this.handleMouseMove.bind(this);
85
- this.onMouseUp = this.handleMouseUp.bind(this);
86
-
87
- const canvas = this.framework.canvas;
88
- canvas.addEventListener('touchstart', this.onTouchStart, { passive: false });
89
- canvas.addEventListener('touchmove', this.onTouchMove, { passive: false });
90
- canvas.addEventListener('touchend', this.onTouchEnd, { passive: false });
91
- canvas.addEventListener('mousedown', this.onMouseDown);
92
- canvas.addEventListener('mousemove', this.onMouseMove);
93
- canvas.addEventListener('mouseup', this.onMouseUp);
94
- }
95
-
96
- removeEventListeners() {
97
- const canvas = this.framework.canvas;
98
- canvas.removeEventListener('touchstart', this.onTouchStart);
99
- canvas.removeEventListener('touchmove', this.onTouchMove);
100
- canvas.removeEventListener('touchend', this.onTouchEnd);
101
- canvas.removeEventListener('mousedown', this.onMouseDown);
102
- canvas.removeEventListener('mousemove', this.onMouseMove);
103
- canvas.removeEventListener('mouseup', this.onMouseUp);
104
- }
105
-
106
- // Coordonnées locales
107
- getLocalPos(clientX, clientY) {
108
- const rect = this.framework.canvas.getBoundingClientRect();
109
- const globalX = clientX - rect.left;
110
- const globalY = clientY - rect.top - this.framework.scrollOffset;
111
- return {
112
- x: globalX - this.x,
113
- y: globalY - this.y
114
- };
115
- }
116
-
117
- handleTouchStart(e) {
118
- e.preventDefault();
119
- const touch = e.touches[0];
120
- const pos = this.getLocalPos(touch.clientX, touch.clientY);
121
- this.handlePress(pos.x, pos.y);
122
- }
123
-
124
- handleTouchMove(e) {
125
- e.preventDefault();
126
- }
127
-
128
- handleTouchEnd(e) {
129
- e.preventDefault();
130
- }
131
-
132
- handleMouseDown(e) {
133
- const pos = this.getLocalPos(e.clientX, e.clientY);
134
- this.handlePress(pos.x, pos.y);
135
- }
136
-
137
- handleMouseMove(e) {}
138
-
139
- handleMouseUp(e) {}
140
-
141
- async startCamera() {
142
- FloatedCamera.cleanupAllCameras();
143
- if (this.stream) return;
144
-
145
- try {
146
- this.stopCamera();
147
-
148
- this.stream = await navigator.mediaDevices.getUserMedia({
149
- video: {
150
- facingMode: this.facingMode,
151
- width: { ideal: 1280 },
152
- height: { ideal: 720 },
153
- frameRate: { ideal: 30 }
154
- }
155
- });
156
-
157
- const [track] = this.stream.getVideoTracks();
158
- const caps = track.getCapabilities?.() || {};
159
- this.torchSupported = !!caps.torch;
160
-
161
- this.video = document.createElement('video');
162
- this.video.autoplay = true;
163
- this.video.playsInline = true;
164
- this.video.muted = true;
165
- this.video.srcObject = this.stream;
166
-
167
- this.video.style.position = 'fixed';
168
- this.video.style.left = '-9999px';
169
- this.video.style.top = '-9999px';
170
- this.video.style.width = '1px';
171
- this.video.style.height = '1px';
172
- document.body.appendChild(this.video);
173
-
174
- await new Promise(resolve => {
175
- this.video.onloadedmetadata = () => {
176
- this.loaded = true;
177
- this.video.play().catch(e => console.warn('Play auto échoué:', e));
178
- resolve();
179
- };
180
- this.video.onerror = (e) => {
181
- this.error = 'Erreur vidéo';
182
- console.error('Video error:', e);
183
- resolve();
184
- };
185
- });
186
-
187
- this.markDirty();
188
- } catch (err) {
189
- this.error = err.message || 'Accès caméra refusé';
190
- console.error('Échec getUserMedia:', err);
191
- this.markDirty();
192
- }
193
- }
194
-
195
- stopCamera() {
196
- if (this.stream) {
197
- this.stream.getTracks().forEach(track => track.stop());
198
- this.stream = null;
199
- }
200
- if (this.video) {
201
- if (this.video.parentNode) {
202
- this.video.parentNode.removeChild(this.video);
203
- }
204
- this.video.srcObject = null;
205
- this.video = null;
206
- }
207
- this.loaded = false;
208
- this.markDirty();
209
- }
210
-
211
- async switchCamera() {
212
- this.stopCamera();
213
- this.facingMode = this.facingMode === 'user' ? 'environment' : 'user';
214
- await this.startCamera();
215
- }
216
-
217
- async toggleTorch() {
218
- if (!this.torchSupported || !this.stream) return;
219
-
220
- const [track] = this.stream.getVideoTracks();
221
- try {
222
- await track.applyConstraints({
223
- advanced: [{ torch: !this.torchOn }]
224
- });
225
- this.torchOn = !this.torchOn;
226
- this.markDirty();
227
- } catch (err) {
228
- console.warn('Torch impossible:', err);
229
- }
230
- }
231
-
232
- capturePhoto() {
233
- if (!this.loaded || !this.video) {
234
- console.warn('Capture impossible : caméra pas prête');
235
- return null;
236
- }
237
-
238
- const canvas = document.createElement('canvas');
239
- canvas.width = this.video.videoWidth;
240
- canvas.height = this.video.videoHeight;
241
-
242
- const ctx = canvas.getContext('2d');
243
- ctx.drawImage(this.video, 0, 0);
244
-
245
- const dataUrl = canvas.toDataURL('image/jpeg', 0.92);
246
- if (this.onPhoto) this.onPhoto(dataUrl);
247
- console.log('Photo capturée ! DataURL:', dataUrl.substring(0, 50) + '...');
248
-
249
- // Feedback : flash + preview 3s
250
- this.flashTimer = setTimeout(() => {
251
- this.flashTimer = null;
252
- this.markDirty();
253
- }, 200);
254
-
255
- this.previewPhoto = dataUrl;
256
- this.previewTimeout = setTimeout(() => {
257
- this.previewPhoto = null;
258
- this.markDirty();
259
- }, 3000);
260
-
261
- this.markDirty();
262
- return dataUrl;
263
- }
264
-
265
- switchFitMode() {
266
- this.currentFitModeIndex = (this.currentFitModeIndex + 1) % this.fitModes.length;
267
- this.fitMode = this.fitModes[this.currentFitModeIndex];
268
- this.markDirty();
269
- }
270
-
271
- handlePress(relX, relY) {
272
-
273
- // Capture centrale
274
- const captureX = this.width / 2;
275
- const captureY = this.height - 60;
276
- if (Math.hypot(relX - captureX, relY - captureY) < this.captureButtonRadius + 10) {
277
- this.capturePhoto();
278
- return;
279
- }
280
-
281
- // Switch caméra
282
- if (relX < 60 && relY < 60) {
283
- this.switchCamera();
284
- return;
285
- }
286
-
287
- // Torch
288
- if (this.torchSupported && relX > this.width - 60 && relY < 60) {
289
- this.toggleTorch();
290
- return;
291
- }
292
-
293
- // Switch mode
294
- const modeButtonX = this.width - 80;
295
- const modeButtonY = 20;
296
- if (relX > modeButtonX && relX < modeButtonX + this.modeButtonSize &&
297
- relY > modeButtonY && relY < modeButtonY + this.modeButtonSize) {
298
- this.switchFitMode();
299
- return;
300
- }
301
- }
302
-
303
- drawContainIcon(ctx, x, y, size) {
304
- // Icône "contain" : rectangle avec flèches vers l'intérieur
305
- const pad = size * 0.2;
306
- ctx.strokeStyle = '#000';
307
- ctx.lineWidth = 2;
308
-
309
- // Rectangle extérieur
310
- ctx.strokeRect(x + pad, y + pad, size - pad * 2, size - pad * 2);
311
-
312
- // Flèches pointant vers l'intérieur
313
- const arrowSize = size * 0.15;
314
- ctx.fillStyle = '#000';
315
-
316
- // Flèche haut
317
- ctx.beginPath();
318
- ctx.moveTo(x + size/2, y + pad - 2);
319
- ctx.lineTo(x + size/2 - arrowSize, y + pad + arrowSize);
320
- ctx.lineTo(x + size/2 + arrowSize, y + pad + arrowSize);
321
- ctx.fill();
322
-
323
- // Flèche bas
324
- ctx.beginPath();
325
- ctx.moveTo(x + size/2, y + size - pad + 2);
326
- ctx.lineTo(x + size/2 - arrowSize, y + size - pad - arrowSize);
327
- ctx.lineTo(x + size/2 + arrowSize, y + size - pad - arrowSize);
328
- ctx.fill();
329
-
330
- // Flèche gauche
331
- ctx.beginPath();
332
- ctx.moveTo(x + pad - 2, y + size/2);
333
- ctx.lineTo(x + pad + arrowSize, y + size/2 - arrowSize);
334
- ctx.lineTo(x + pad + arrowSize, y + size/2 + arrowSize);
335
- ctx.fill();
336
-
337
- // Flèche droite
338
- ctx.beginPath();
339
- ctx.moveTo(x + size - pad + 2, y + size/2);
340
- ctx.lineTo(x + size - pad - arrowSize, y + size/2 - arrowSize);
341
- ctx.lineTo(x + size - pad - arrowSize, y + size/2 + arrowSize);
342
- ctx.fill();
343
- }
344
-
345
- drawCoverIcon(ctx, x, y, size) {
346
- // Icône "cover" : rectangle avec flèches vers l'extérieur
347
- const pad = size * 0.2;
348
- ctx.strokeStyle = '#000';
349
- ctx.lineWidth = 2;
350
-
351
- // Rectangle intérieur
352
- ctx.strokeRect(x + pad, y + pad, size - pad * 2, size - pad * 2);
353
-
354
- // Flèches pointant vers l'extérieur
355
- const arrowSize = size * 0.15;
356
- ctx.fillStyle = '#000';
357
-
358
- // Flèche haut
359
- ctx.beginPath();
360
- ctx.moveTo(x + size/2, y + 2);
361
- ctx.lineTo(x + size/2 - arrowSize, y + arrowSize + 2);
362
- ctx.lineTo(x + size/2 + arrowSize, y + arrowSize + 2);
363
- ctx.fill();
364
-
365
- // Flèche bas
366
- ctx.beginPath();
367
- ctx.moveTo(x + size/2, y + size - 2);
368
- ctx.lineTo(x + size/2 - arrowSize, y + size - arrowSize - 2);
369
- ctx.lineTo(x + size/2 + arrowSize, y + size - arrowSize - 2);
370
- ctx.fill();
371
-
372
- // Flèche gauche
373
- ctx.beginPath();
374
- ctx.moveTo(x + 2, y + size/2);
375
- ctx.lineTo(x + arrowSize + 2, y + size/2 - arrowSize);
376
- ctx.lineTo(x + arrowSize + 2, y + size/2 + arrowSize);
377
- ctx.fill();
378
-
379
- // Flèche droite
380
- ctx.beginPath();
381
- ctx.moveTo(x + size - 2, y + size/2);
382
- ctx.lineTo(x + size - arrowSize - 2, y + size/2 - arrowSize);
383
- ctx.lineTo(x + size - arrowSize - 2, y + size/2 + arrowSize);
384
- ctx.fill();
385
- }
386
-
387
- drawContainIcon(ctx, x, y, size) {
388
- // Icône "contain" : rectangle avec flèches vers l'intérieur
389
- const pad = size * 0.2;
390
- ctx.strokeStyle = '#000';
391
- ctx.lineWidth = 2;
392
-
393
- // Rectangle extérieur
394
- ctx.strokeRect(x + pad, y + pad, size - pad * 2, size - pad * 2);
395
-
396
- // Flèches pointant vers l'intérieur
397
- const arrowSize = size * 0.15;
398
- ctx.fillStyle = '#000';
399
-
400
- // Flèche haut
401
- ctx.beginPath();
402
- ctx.moveTo(x + size/2, y + pad - 2);
403
- ctx.lineTo(x + size/2 - arrowSize, y + pad + arrowSize);
404
- ctx.lineTo(x + size/2 + arrowSize, y + pad + arrowSize);
405
- ctx.fill();
406
-
407
- // Flèche bas
408
- ctx.beginPath();
409
- ctx.moveTo(x + size/2, y + size - pad + 2);
410
- ctx.lineTo(x + size/2 - arrowSize, y + size - pad - arrowSize);
411
- ctx.lineTo(x + size/2 + arrowSize, y + size - pad - arrowSize);
412
- ctx.fill();
413
-
414
- // Flèche gauche
415
- ctx.beginPath();
416
- ctx.moveTo(x + pad - 2, y + size/2);
417
- ctx.lineTo(x + pad + arrowSize, y + size/2 - arrowSize);
418
- ctx.lineTo(x + pad + arrowSize, y + size/2 + arrowSize);
419
- ctx.fill();
420
-
421
- // Flèche droite
422
- ctx.beginPath();
423
- ctx.moveTo(x + size - pad + 2, y + size/2);
424
- ctx.lineTo(x + size - pad - arrowSize, y + size/2 - arrowSize);
425
- ctx.lineTo(x + size - pad - arrowSize, y + size/2 + arrowSize);
426
- ctx.fill();
427
- }
428
-
429
- drawCoverIcon(ctx, x, y, size) {
430
- // Icône "cover" : rectangle avec flèches vers l'extérieur
431
- const pad = size * 0.2;
432
- ctx.strokeStyle = '#000';
433
- ctx.lineWidth = 2;
434
-
435
- // Rectangle intérieur
436
- ctx.strokeRect(x + pad, y + pad, size - pad * 2, size - pad * 2);
437
-
438
- // Flèches pointant vers l'extérieur
439
- const arrowSize = size * 0.15;
440
- ctx.fillStyle = '#000';
441
-
442
- // Flèche haut
443
- ctx.beginPath();
444
- ctx.moveTo(x + size/2, y + 2);
445
- ctx.lineTo(x + size/2 - arrowSize, y + arrowSize + 2);
446
- ctx.lineTo(x + size/2 + arrowSize, y + arrowSize + 2);
447
- ctx.fill();
448
-
449
- // Flèche bas
450
- ctx.beginPath();
451
- ctx.moveTo(x + size/2, y + size - 2);
452
- ctx.lineTo(x + size/2 - arrowSize, y + size - arrowSize - 2);
453
- ctx.lineTo(x + size/2 + arrowSize, y + size - arrowSize - 2);
454
- ctx.fill();
455
-
456
- // Flèche gauche
457
- ctx.beginPath();
458
- ctx.moveTo(x + 2, y + size/2);
459
- ctx.lineTo(x + arrowSize + 2, y + size/2 - arrowSize);
460
- ctx.lineTo(x + arrowSize + 2, y + size/2 + arrowSize);
461
- ctx.fill();
462
-
463
- // Flèche droite
464
- ctx.beginPath();
465
- ctx.moveTo(x + size - 2, y + size/2);
466
- ctx.lineTo(x + size - arrowSize - 2, y + size/2 - arrowSize);
467
- ctx.lineTo(x + size - arrowSize - 2, y + size/2 + arrowSize);
468
- ctx.fill();
469
- }
470
-
471
- drawSwitchCameraIcon(ctx, x, y, size) {
472
- // Icône de switch caméra : deux caméras avec flèche circulaire
473
- const centerX = x + size / 2;
474
- const centerY = y + size / 2;
475
- const radius = size * 0.35;
476
-
477
- ctx.strokeStyle = '#ffffff';
478
- ctx.lineWidth = 3;
479
- ctx.lineCap = 'round';
480
-
481
- // Arc circulaire (flèche de rotation)
482
- ctx.beginPath();
483
- ctx.arc(centerX, centerY, radius, -Math.PI * 0.7, Math.PI * 0.7);
484
- ctx.stroke();
485
-
486
- // Flèche en haut à droite
487
- const arrowSize = size * 0.15;
488
- const arrowAngle = Math.PI * 0.7;
489
- const arrowX = centerX + radius * Math.cos(arrowAngle);
490
- const arrowY = centerY + radius * Math.sin(arrowAngle);
491
-
492
- ctx.fillStyle = '#ffffff';
493
- ctx.beginPath();
494
- ctx.moveTo(arrowX, arrowY);
495
- ctx.lineTo(arrowX - arrowSize, arrowY - arrowSize * 0.5);
496
- ctx.lineTo(arrowX - arrowSize * 0.5, arrowY + arrowSize);
497
- ctx.fill();
498
-
499
- // Mini caméra au centre
500
- const camWidth = size * 0.25;
501
- const camHeight = size * 0.18;
502
- const camX = centerX - camWidth / 2;
503
- const camY = centerY - camHeight / 2;
504
-
505
- ctx.fillStyle = '#ffffff';
506
- ctx.fillRect(camX, camY, camWidth, camHeight);
507
-
508
- // Objectif
509
- ctx.fillStyle = '#000';
510
- ctx.beginPath();
511
- ctx.arc(centerX, centerY, size * 0.08, 0, Math.PI * 2);
512
- ctx.fill();
513
- }
514
-
515
- draw(ctx) {
516
- ctx.save();
517
-
518
- ctx.fillStyle = '#000';
519
- ctx.fillRect(this.x, this.y, this.width, this.height);
520
-
521
- // Flash blanc après capture
522
- if (this.flashTimer) {
523
- ctx.fillStyle = 'rgba(255,255,255,0.6)';
524
- ctx.fillRect(this.x, this.y, this.width, this.height);
525
- }
526
-
527
- if (this.error) {
528
- ctx.fillStyle = '#ff4444';
529
- ctx.font = '16px Arial';
530
- ctx.textAlign = 'center';
531
- ctx.textBaseline = 'middle';
532
- ctx.fillText(this.error, this.x + this.width/2, this.y + this.height/2);
533
- } else if (!this.loaded) {
534
- ctx.fillStyle = '#fff';
535
- ctx.font = '16px Arial';
536
- ctx.textAlign = 'center';
537
- ctx.textBaseline = 'middle';
538
- ctx.fillText('Démarrage caméra...', this.x + this.width/2, this.y + this.height/2);
539
- } else if (this.video && this.loaded) {
540
- const videoRatio = this.video.videoWidth / this.video.videoHeight;
541
- const canvasRatio = this.width / this.height;
542
-
543
- let drawWidth = this.width;
544
- let drawHeight = this.height;
545
- let offsetX = 0;
546
- let offsetY = 0;
547
-
548
- if (this.fitMode === 'cover') {
549
- if (videoRatio > canvasRatio) {
550
- drawHeight = this.height;
551
- drawWidth = drawHeight * videoRatio;
552
- offsetX = (this.width - drawWidth) / 2;
553
- } else {
554
- drawWidth = this.width;
555
- drawHeight = drawWidth / videoRatio;
556
- offsetY = (this.height - drawHeight) / 2;
557
- }
558
- } else if (this.fitMode === 'contain') {
559
- if (videoRatio > canvasRatio) {
560
- drawWidth = this.width;
561
- drawHeight = drawWidth / videoRatio;
562
- offsetY = (this.height - drawHeight) / 2;
563
- } else {
564
- drawHeight = this.height;
565
- drawWidth = drawHeight * videoRatio;
566
- offsetX = (this.width - drawWidth) / 2;
567
- }
568
- }
569
-
570
- ctx.drawImage(this.video, this.x + offsetX, this.y + offsetY, drawWidth, drawHeight);
571
-
572
- // Mini preview dernière photo (bas droite, 3s)
573
- if (this.previewPhoto) {
574
- const previewSize = 80;
575
- const img = new Image();
576
- img.src = this.previewPhoto;
577
- ctx.drawImage(img, this.x + this.width - previewSize - 10, this.y + this.height - previewSize - 10, previewSize, previewSize);
578
- ctx.strokeStyle = '#fff';
579
- ctx.lineWidth = 2;
580
- ctx.strokeRect(this.x + this.width - previewSize - 10, this.y + this.height - previewSize - 10, previewSize, previewSize);
581
- }
582
- }
583
-
584
- // Contrôles bas
585
- ctx.fillStyle = 'rgba(0,0,0,0.5)';
586
- ctx.fillRect(this.x, this.y + this.height - 100, this.width, 100);
587
-
588
- // Bouton capture
589
- ctx.fillStyle = '#ffffff';
590
- ctx.beginPath();
591
- ctx.arc(this.x + this.width/2, this.y + this.height - 50, this.captureButtonRadius, 0, Math.PI * 2);
592
- ctx.fill();
593
-
594
- ctx.strokeStyle = '#ff4444';
595
- ctx.lineWidth = 6;
596
- ctx.beginPath();
597
- ctx.arc(this.x + this.width/2, this.y + this.height - 50, this.captureButtonRadius + 10, 0, Math.PI * 2);
598
- ctx.stroke();
599
-
600
- // Switch caméra avec icône
601
- const switchBtnX = this.x + 20;
602
- const switchBtnY = this.y + 20;
603
- const switchBtnSize = 50;
604
-
605
- // Fond semi-transparent
606
- ctx.fillStyle = 'rgba(0,0,0,0.5)';
607
- ctx.beginPath();
608
- ctx.arc(switchBtnX + switchBtnSize/2, switchBtnY + switchBtnSize/2, switchBtnSize/2, 0, Math.PI * 2);
609
- ctx.fill();
610
-
611
- // Icône
612
- this.drawSwitchCameraIcon(ctx, switchBtnX, switchBtnY, switchBtnSize);
613
-
614
- // Torch
615
- if (this.torchSupported) {
616
- ctx.fillStyle = this.torchOn ? '#ffeb3b' : '#ffffff';
617
- ctx.fillText('⚡', this.x + this.width - 50, this.y + 45);
618
- }
619
-
620
- // Bouton switch mode avec icône
621
- const btnX = this.x + this.width - 80;
622
- const btnY = this.y + 20;
623
-
624
- // Fond du bouton
625
- ctx.fillStyle = 'rgba(255,255,255,0.9)';
626
- ctx.fillRect(btnX, btnY, this.modeButtonSize, this.modeButtonSize);
627
-
628
- // Bordure
629
- ctx.strokeStyle = '#000';
630
- ctx.lineWidth = 2;
631
- ctx.strokeRect(btnX, btnY, this.modeButtonSize, this.modeButtonSize);
632
-
633
- // Dessiner l'icône appropriée
634
- if (this.fitMode === 'contain') {
635
- this.drawContainIcon(ctx, btnX, btnY, this.modeButtonSize);
636
- } else {
637
- this.drawCoverIcon(ctx, btnX, btnY, this.modeButtonSize);
638
- }
639
-
640
- ctx.restore();
641
- }
642
- }
643
-
644
- export default FloatedCamera;