@ray-js/lamp-circle-picker 1.0.13-beta-4 → 1.0.13-beta-5

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.
@@ -283,16 +283,27 @@ export default Render({
283
283
  // 计算色环中线半径
284
284
  const midRadius = (innerRadius + (outerRadius - innerRadius) / 2) * scale;
285
285
 
286
+ // 切向偏移量(4px,考虑scale),用于消除某些机型上的间隙
287
+ const tangentOffset = 4 * scale;
288
+
286
289
  // 起始端点(135度位置)
287
290
  const startAngleRad = (startAngle * Math.PI) / 180;
288
- const startX = centerX + midRadius * Math.cos(startAngleRad);
289
- const startY = centerY + midRadius * Math.sin(startAngleRad);
291
+ // 切向方向:顺时针旋转90度
292
+ const startTangentAngle = startAngleRad + Math.PI / 2;
293
+ const startX =
294
+ centerX + midRadius * Math.cos(startAngleRad) + tangentOffset * Math.cos(startTangentAngle);
295
+ const startY =
296
+ centerY + midRadius * Math.sin(startAngleRad) + tangentOffset * Math.sin(startTangentAngle);
290
297
  const startColor = gradientColors[1] || gradientColors[0]; // 使用第一个颜色
291
298
 
292
299
  // 结束端点(405度位置)
293
300
  const endAngleRad = (endAngle * Math.PI) / 180;
294
- const endX = centerX + midRadius * Math.cos(endAngleRad);
295
- const endY = centerY + midRadius * Math.sin(endAngleRad);
301
+ // 切向方向:逆时针旋转90度
302
+ const endTangentAngle = endAngleRad - Math.PI / 2;
303
+ const endX =
304
+ centerX + midRadius * Math.cos(endAngleRad) + tangentOffset * Math.cos(endTangentAngle);
305
+ const endY =
306
+ centerY + midRadius * Math.sin(endAngleRad) + tangentOffset * Math.sin(endTangentAngle);
296
307
  const endColor =
297
308
  gradientColors[gradientColors.length - 2] || gradientColors[gradientColors.length - 1]; // 使用最后一个颜色
298
309
 
@@ -300,18 +311,19 @@ export default Render({
300
311
  ctx.globalCompositeOperation = 'source-over';
301
312
 
302
313
  // 起始端点 - 使用闭合路径绘制半圆,确保与色环无缝衔接
303
- // 计算色环内外边缘的起点坐标
304
- const startInnerX = centerX + innerRadius * scale * Math.cos(startAngleRad);
305
- const startInnerY = centerY + innerRadius * scale * Math.sin(startAngleRad);
306
- const startOuterX = centerX + outerRadius * scale * Math.cos(startAngleRad);
307
- const startOuterY = centerY + outerRadius * scale * Math.sin(startAngleRad);
314
+ // 计算半圆弧的起始和结束点(基于半圆中心和半径)
315
+ const startArcInnerX = startX + endpointRadius * Math.cos(startAngleRad);
316
+ const startArcInnerY = startY + endpointRadius * Math.sin(startAngleRad);
317
+ const startArcOuterX = startX + endpointRadius * Math.cos(startAngleRad - Math.PI);
318
+ const startArcOuterY = startY + endpointRadius * Math.sin(startAngleRad - Math.PI);
308
319
 
309
320
  ctx.beginPath();
310
- // 从内边缘开始
311
- ctx.moveTo(startInnerX, startInnerY);
312
- // 绘制半圆弧(从内边缘到外边缘)
321
+ // 从半圆弧的起点(内侧)开始
322
+ ctx.moveTo(startArcInnerX, startArcInnerY);
323
+ // 绘制半圆弧到外侧
313
324
  ctx.arc(startX, startY, endpointRadius, startAngleRad, startAngleRad - Math.PI, true);
314
- // 闭合路径(从外边缘回到内边缘)
325
+ // 连接回起点,形成闭合路径
326
+ ctx.lineTo(startArcInnerX, startArcInnerY);
315
327
  ctx.closePath();
316
328
 
317
329
  // 使用与色环相同的径向渐变
@@ -325,23 +337,23 @@ export default Render({
325
337
  );
326
338
  startGradient.addColorStop(0, startColor);
327
339
  startGradient.addColorStop(1, startColor);
328
-
329
340
  ctx.fillStyle = startGradient;
330
341
  ctx.fill();
331
342
 
332
343
  // 结束端点 - 使用闭合路径绘制半圆,确保与色环无缝衔接
333
- // 计算色环内外边缘的终点坐标
334
- const endInnerX = centerX + innerRadius * scale * Math.cos(endAngleRad);
335
- const endInnerY = centerY + innerRadius * scale * Math.sin(endAngleRad);
336
- const endOuterX = centerX + outerRadius * scale * Math.cos(endAngleRad);
337
- const endOuterY = centerY + outerRadius * scale * Math.sin(endAngleRad);
344
+ // 计算半圆弧的起始和结束点(基于半圆中心和半径)
345
+ const endArcInnerX = endX + endpointRadius * Math.cos(endAngleRad);
346
+ const endArcInnerY = endY + endpointRadius * Math.sin(endAngleRad);
347
+ const endArcOuterX = endX + endpointRadius * Math.cos(endAngleRad + Math.PI);
348
+ const endArcOuterY = endY + endpointRadius * Math.sin(endAngleRad + Math.PI);
338
349
 
339
350
  ctx.beginPath();
340
- // 从内边缘开始
341
- ctx.moveTo(endInnerX, endInnerY);
342
- // 绘制半圆弧(从内边缘到外边缘)
351
+ // 从半圆弧的起点(内侧)开始
352
+ ctx.moveTo(endArcInnerX, endArcInnerY);
353
+ // 绘制半圆弧到外侧
343
354
  ctx.arc(endX, endY, endpointRadius, endAngleRad, endAngleRad + Math.PI, false);
344
- // 闭合路径(从外边缘回到内边缘)
355
+ // 连接回起点,形成闭合路径
356
+ ctx.lineTo(endArcInnerX, endArcInnerY);
345
357
  ctx.closePath();
346
358
 
347
359
  // 使用与色环相同的径向渐变
@@ -355,7 +367,6 @@ export default Render({
355
367
  );
356
368
  endGradient.addColorStop(0, endColor);
357
369
  endGradient.addColorStop(1, endColor);
358
-
359
370
  ctx.fillStyle = endGradient;
360
371
  ctx.fill();
361
372
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-circle-picker",
3
- "version": "1.0.13-beta-4",
3
+ "version": "1.0.13-beta-5",
4
4
  "description": "照明缺角色环",
5
5
  "main": "lib/index",
6
6
  "files": [