@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.
- package/example/src/pages/index.tsx +1 -1
- package/lib/component/rjs/index.rjs +36 -22
- package/lib/index.js +2 -2
- package/package.json +1 -1
|
@@ -283,38 +283,48 @@ export default Render({
|
|
|
283
283
|
// 计算色环中线半径
|
|
284
284
|
const midRadius = (innerRadius + (outerRadius - innerRadius) / 2) * scale;
|
|
285
285
|
|
|
286
|
-
//
|
|
287
|
-
const
|
|
286
|
+
// 切向偏移量(4px,考虑scale),用于消除某些机型上的间隙
|
|
287
|
+
const tangentOffset = 4 * scale;
|
|
288
288
|
|
|
289
289
|
// 起始端点(135度位置)
|
|
290
290
|
const startAngleRad = (startAngle * Math.PI) / 180;
|
|
291
|
-
//
|
|
291
|
+
// 切向方向:顺时针旋转90度
|
|
292
292
|
const startTangentAngle = startAngleRad + Math.PI / 2;
|
|
293
293
|
const startX =
|
|
294
|
-
centerX + midRadius * Math.cos(startAngleRad) +
|
|
294
|
+
centerX + midRadius * Math.cos(startAngleRad) + tangentOffset * Math.cos(startTangentAngle);
|
|
295
295
|
const startY =
|
|
296
|
-
centerY + midRadius * Math.sin(startAngleRad) +
|
|
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
|
-
//
|
|
301
|
+
// 切向方向:逆时针旋转90度
|
|
302
302
|
const endTangentAngle = endAngleRad - Math.PI / 2;
|
|
303
|
-
const endX =
|
|
304
|
-
|
|
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
|
|
314
|
-
const
|
|
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
|
-
|
|
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
|
|
338
|
-
const
|
|
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
|
-
|
|
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,
|