Lashtw commited on
Commit
760b921
·
verified ·
1 Parent(s): b8167d1

Upload 8 files

Browse files
Files changed (1) hide show
  1. src/views/InstructorView.js +39 -2
src/views/InstructorView.js CHANGED
@@ -184,7 +184,10 @@ export async function renderInstructorView() {
184
  </div>
185
 
186
  <!-- Canvas Layer -->
187
- <canvas id="annotation-canvas" class="absolute inset-0 z-10 touch-none cursor-crosshair"></canvas>
 
 
 
188
  </div>
189
  </div>
190
 
@@ -1180,8 +1183,20 @@ ${item.prompt}
1180
  resize();
1181
  window.addEventListener('resize', resize);
1182
 
1183
- // Init Size UI
1184
  updateSizeBtnUI();
 
 
 
 
 
 
 
 
 
 
 
 
1185
 
1186
  // Drawing Events
1187
  const start = (e) => {
@@ -1243,14 +1258,36 @@ ${item.prompt}
1243
  currentMode = 'source-over';
1244
  currentPenColor = color;
1245
  }
 
1246
  };
1247
 
1248
  // Size Handler
1249
  window.setPenSize = (size, btn) => {
1250
  currentLineWidth = size;
1251
  updateSizeBtnUI();
 
1252
  };
1253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1254
  function updateSizeBtnUI() {
1255
  document.querySelectorAll('.size-btn').forEach(b => {
1256
  if (parseInt(b.dataset.size) === currentLineWidth) {
 
184
  </div>
185
 
186
  <!-- Canvas Layer -->
187
+ <canvas id="annotation-canvas" class="absolute inset-0 z-10 touch-none cursor-none"></canvas>
188
+
189
+ <!-- Custom Tool Cursor -->
190
+ <div id="tool-cursor" class="absolute hidden rounded-full pointer-events-none z-50 transform -translate-x-1/2 -translate-y-1/2 transition-all duration-75 linear will-change-transform shadow-sm border border-white/50"></div>
191
  </div>
192
  </div>
193
 
 
1183
  resize();
1184
  window.addEventListener('resize', resize);
1185
 
1186
+ // Init Size UI & Cursor
1187
  updateSizeBtnUI();
1188
+ updateCursorStyle();
1189
+
1190
+ // Cursor Logic
1191
+ const cursor = document.getElementById('tool-cursor');
1192
+
1193
+ canvas.addEventListener('mouseenter', () => cursor.classList.remove('hidden'));
1194
+ canvas.addEventListener('mouseleave', () => cursor.classList.add('hidden'));
1195
+ canvas.addEventListener('mousemove', (e) => {
1196
+ const { x, y } = getPos(e);
1197
+ cursor.style.left = `${x}px`;
1198
+ cursor.style.top = `${y}px`;
1199
+ });
1200
 
1201
  // Drawing Events
1202
  const start = (e) => {
 
1258
  currentMode = 'source-over';
1259
  currentPenColor = color;
1260
  }
1261
+ updateCursorStyle();
1262
  };
1263
 
1264
  // Size Handler
1265
  window.setPenSize = (size, btn) => {
1266
  currentLineWidth = size;
1267
  updateSizeBtnUI();
1268
+ updateCursorStyle();
1269
  };
1270
 
1271
+ function updateCursorStyle() {
1272
+ const cursor = document.getElementById('tool-cursor');
1273
+ if (!cursor) return;
1274
+
1275
+ // Size
1276
+ cursor.style.width = `${currentLineWidth}px`;
1277
+ cursor.style.height = `${currentLineWidth}px`;
1278
+
1279
+ // Color
1280
+ if (currentMode === 'destination-out') {
1281
+ // Eraser: White solid
1282
+ cursor.style.backgroundColor = 'white';
1283
+ cursor.style.borderColor = '#999';
1284
+ } else {
1285
+ // Pen: Tool color
1286
+ cursor.style.backgroundColor = currentPenColor;
1287
+ cursor.style.borderColor = 'rgba(255,255,255,0.8)';
1288
+ }
1289
+ }
1290
+
1291
  function updateSizeBtnUI() {
1292
  document.querySelectorAll('.size-btn').forEach(b => {
1293
  if (parseInt(b.dataset.size) === currentLineWidth) {