@ray-js/lamp-circle-picker 1.0.13-beta-3 → 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.
@@ -68,7 +68,7 @@ export default function Home() {
68
68
  <LampCirclePicker
69
69
  value={temperature}
70
70
  innerRingRadius={80}
71
- showInnerCircle
71
+ showInnerCircle={false}
72
72
  colorList={[
73
73
  { offset: 0, color: '#ff0000' },
74
74
  { offset: 0.5, color: '#00ff00' },
@@ -283,38 +283,48 @@ export default Render({
283
283
  // 计算色环中线半径
284
284
  const midRadius = (innerRadius + (outerRadius - innerRadius) / 2) * scale;
285
285
 
286
- // 切线方向的平移距离(2px,考虑scale
287
- const offset = 2 * scale;
286
+ // 切向偏移量(4px,考虑scale),用于消除某些机型上的间隙
287
+ const tangentOffset = 4 * scale;
288
288
 
289
289
  // 起始端点(135度位置)
290
290
  const startAngleRad = (startAngle * Math.PI) / 180;
291
- // 切线方向是半径方向顺时针旋转90度(+π/2),沿色环正向平移
291
+ // 切向方向:顺时针旋转90
292
292
  const startTangentAngle = startAngleRad + Math.PI / 2;
293
293
  const startX =
294
- centerX + midRadius * Math.cos(startAngleRad) + offset * Math.cos(startTangentAngle);
294
+ centerX + midRadius * Math.cos(startAngleRad) + tangentOffset * Math.cos(startTangentAngle);
295
295
  const startY =
296
- centerY + midRadius * Math.sin(startAngleRad) + offset * Math.sin(startTangentAngle);
296
+ centerY + midRadius * Math.sin(startAngleRad) + tangentOffset * Math.sin(startTangentAngle);
297
297
  const startColor = gradientColors[1] || gradientColors[0]; // 使用第一个颜色
298
298
 
299
299
  // 结束端点(405度位置)
300
300
  const endAngleRad = (endAngle * Math.PI) / 180;
301
- // 切线方向是半径方向逆时针旋转90度(-π/2),沿色环反向平移
301
+ // 切向方向:逆时针旋转90
302
302
  const endTangentAngle = endAngleRad - Math.PI / 2;
303
- const endX = centerX + midRadius * Math.cos(endAngleRad) + offset * Math.cos(endTangentAngle);
304
- const endY = centerY + midRadius * Math.sin(endAngleRad) + offset * Math.sin(endTangentAngle);
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);
305
307
  const endColor =
306
308
  gradientColors[gradientColors.length - 2] || gradientColors[gradientColors.length - 1]; // 使用最后一个颜色
307
309
 
308
310
  // 重置合成操作以正常绘制端点
309
311
  ctx.globalCompositeOperation = 'source-over';
310
312
 
311
- // 起始端点 - 使用半圆,封闭色环起点
312
- // 半圆应该朝向色环外侧(逆时针方向),角度范围是从色环切线的外侧到内侧
313
- const startHalfCircleStart = startAngleRad - Math.PI; // 色环外侧
314
- const startHalfCircleEnd = startAngleRad; // 色环内侧
313
+ // 起始端点 - 使用闭合路径绘制半圆,确保与色环无缝衔接
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);
315
319
 
316
320
  ctx.beginPath();
317
- ctx.arc(startX, startY, endpointRadius, startHalfCircleStart, startHalfCircleEnd, false);
321
+ // 从半圆弧的起点(内侧)开始
322
+ ctx.moveTo(startArcInnerX, startArcInnerY);
323
+ // 绘制半圆弧到外侧
324
+ ctx.arc(startX, startY, endpointRadius, startAngleRad, startAngleRad - Math.PI, true);
325
+ // 连接回起点,形成闭合路径
326
+ ctx.lineTo(startArcInnerX, startArcInnerY);
327
+ ctx.closePath();
318
328
 
319
329
  // 使用与色环相同的径向渐变
320
330
  const startGradient = ctx.createRadialGradient(
@@ -327,18 +337,24 @@ export default Render({
327
337
  );
328
338
  startGradient.addColorStop(0, startColor);
329
339
  startGradient.addColorStop(1, startColor);
330
-
331
340
  ctx.fillStyle = startGradient;
332
341
  ctx.fill();
333
- ctx.closePath();
334
342
 
335
- // 结束端点 - 使用半圆,封闭色环终点
336
- // 半圆应该朝向色环外侧(顺时针方向),角度范围是从色环切线的内侧到外侧
337
- const endHalfCircleStart = endAngleRad; // 色环内侧
338
- const endHalfCircleEnd = endAngleRad + Math.PI; // 色环外侧
343
+ // 结束端点 - 使用闭合路径绘制半圆,确保与色环无缝衔接
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);
339
349
 
340
350
  ctx.beginPath();
341
- ctx.arc(endX, endY, endpointRadius, endHalfCircleStart, endHalfCircleEnd, false);
351
+ // 从半圆弧的起点(内侧)开始
352
+ ctx.moveTo(endArcInnerX, endArcInnerY);
353
+ // 绘制半圆弧到外侧
354
+ ctx.arc(endX, endY, endpointRadius, endAngleRad, endAngleRad + Math.PI, false);
355
+ // 连接回起点,形成闭合路径
356
+ ctx.lineTo(endArcInnerX, endArcInnerY);
357
+ ctx.closePath();
342
358
 
343
359
  // 使用与色环相同的径向渐变
344
360
  const endGradient = ctx.createRadialGradient(
@@ -351,10 +367,8 @@ export default Render({
351
367
  );
352
368
  endGradient.addColorStop(0, endColor);
353
369
  endGradient.addColorStop(1, endColor);
354
-
355
370
  ctx.fillStyle = endGradient;
356
371
  ctx.fill();
357
- ctx.closePath();
358
372
  },
359
373
 
360
374
  // 环形色盘 降级绘制
package/lib/index.js CHANGED
@@ -52,9 +52,9 @@ const LampCirclePicker = props => {
52
52
  return /*#__PURE__*/React.createElement(View, {
53
53
  className: clsx(styled.container, styled.flexCenter),
54
54
  style: style
55
- }, /*#__PURE__*/React.createElement(View, {
56
- className: clsx(styled.innerBox, styled.flexCenter)
57
55
  }, showInnerCircle && /*#__PURE__*/React.createElement(View, {
56
+ className: clsx(styled.innerBox, styled.flexCenter)
57
+ }, /*#__PURE__*/React.createElement(View, {
58
58
  className: styled.ringIcon,
59
59
  style: {
60
60
  width: innerImgRadius,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-circle-picker",
3
- "version": "1.0.13-beta-3",
3
+ "version": "1.0.13-beta-5",
4
4
  "description": "照明缺角色环",
5
5
  "main": "lib/index",
6
6
  "files": [