@ray-js/lamp-circle-picker 1.0.11-beta-3 → 1.0.11-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 -0
- package/lib/component/index.js +1 -0
- package/lib/component/props.d.ts +6 -0
- package/lib/component/rjs/index.js +10 -0
- package/lib/component/rjs/index.rjs +10 -12
- package/lib/index.js +2 -0
- package/lib/props.d.ts +7 -1
- package/package.json +1 -1
package/lib/component/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export default function RectColor(props) {
|
|
|
15
15
|
canvasId: props.canvasId,
|
|
16
16
|
colorList: (_props$colorList = props.colorList) !== null && _props$colorList !== void 0 ? _props$colorList : [],
|
|
17
17
|
useEventChannel: props.useEventChannel,
|
|
18
|
+
lineCap: props.lineCap || 'round',
|
|
18
19
|
eventChannelName: props.eventChannelName,
|
|
19
20
|
touchCircleStrokeStyle: props.touchCircleStrokeStyle,
|
|
20
21
|
touchCircleLineWidth: touchCircleLineWidth,
|
package/lib/component/props.d.ts
CHANGED
|
@@ -35,6 +35,12 @@ export interface IProps {
|
|
|
35
35
|
* @default false
|
|
36
36
|
*/
|
|
37
37
|
useEventChannel?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @description.zh 绘制的圆环末端样式
|
|
40
|
+
* @description.en Drawn ring end style
|
|
41
|
+
* @default round
|
|
42
|
+
*/
|
|
43
|
+
lineCap?: 'butt' | 'round';
|
|
38
44
|
/**
|
|
39
45
|
* @description.zh 色盘渐变颜色列表
|
|
40
46
|
* @description.en Color plate gradient color list
|
|
@@ -41,6 +41,10 @@ Component({
|
|
|
41
41
|
type: String,
|
|
42
42
|
value: 'lampCirclePickerEventChannel'
|
|
43
43
|
},
|
|
44
|
+
lineCap: {
|
|
45
|
+
type: String,
|
|
46
|
+
value: 'round'
|
|
47
|
+
},
|
|
44
48
|
touchCircleStrokeStyle: String,
|
|
45
49
|
touchCircleLineWidth: Number,
|
|
46
50
|
onTouchStart: Function,
|
|
@@ -106,13 +110,19 @@ Component({
|
|
|
106
110
|
useEventChannel,
|
|
107
111
|
eventChannelName,
|
|
108
112
|
colorList,
|
|
113
|
+
lineCap = 'round',
|
|
109
114
|
touchCircleStrokeStyle = '',
|
|
110
115
|
touchCircleLineWidth = 0
|
|
111
116
|
} = this.data;
|
|
117
|
+
// 防止重复渲染
|
|
118
|
+
if (this.lastValue === value) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
112
121
|
canvasId && this.render.renderAnnulusColor(canvasId, radius, innerRingRadius, value, {
|
|
113
122
|
useEventChannel,
|
|
114
123
|
eventChannelName,
|
|
115
124
|
hideThumb,
|
|
125
|
+
lineCap,
|
|
116
126
|
colorList,
|
|
117
127
|
touchCircleStrokeStyle,
|
|
118
128
|
touchCircleLineWidth
|
|
@@ -7,15 +7,15 @@ function reverseColorStops(colorStops) {
|
|
|
7
7
|
return [];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const _reversedColorStops = colorStops.map(stop => ({
|
|
11
11
|
offset: 1 - stop.offset,
|
|
12
12
|
color: stop.color,
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
15
|
// 由于反转 offset 后,需要根据新的 offset 重新排序
|
|
16
|
-
|
|
16
|
+
_reversedColorStops.sort((a, b) => a.offset - b.offset);
|
|
17
17
|
|
|
18
|
-
return
|
|
18
|
+
return _reversedColorStops;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export default Render({
|
|
@@ -264,7 +264,6 @@ export default Render({
|
|
|
264
264
|
|
|
265
265
|
// 环形色盘 降级绘制
|
|
266
266
|
async renderAnnulusColorLowRank(id, radius, innerRingRadius, options = {}) {
|
|
267
|
-
console.warn('renderAnnulusColorLowRank', JSON.stringify(options));
|
|
268
267
|
let canvas = null;
|
|
269
268
|
const { touchCircleStrokeStyle, ringBorderColor } =
|
|
270
269
|
options;
|
|
@@ -302,15 +301,13 @@ export default Render({
|
|
|
302
301
|
const offsetDegree = 270;
|
|
303
302
|
const endDegree = startDegree + offsetDegree;
|
|
304
303
|
|
|
305
|
-
// 颜色渲染时 按照逆时针渲染,需要按照顺时针渲染, 所以需要反转
|
|
306
|
-
const reversedColorStops = reverseColorStops(colorList);
|
|
307
304
|
this.drawRingWithConicGradient({
|
|
308
305
|
startAngle: startDegree,
|
|
309
306
|
endAngle: endDegree,
|
|
310
307
|
offsetDegree,
|
|
311
308
|
innerRadius: innerRingRadius,
|
|
312
309
|
outerRadius: radius,
|
|
313
|
-
colorList:
|
|
310
|
+
colorList: colorList,
|
|
314
311
|
canvas,
|
|
315
312
|
ctx,
|
|
316
313
|
centerX: poxCenterX,
|
|
@@ -327,7 +324,7 @@ export default Render({
|
|
|
327
324
|
// 环形色盘
|
|
328
325
|
async renderAnnulusColor(id, radius, innerRingRadius, temp = 0, options = {}) {
|
|
329
326
|
let canvas = null;
|
|
330
|
-
const { touchCircleStrokeStyle = '', touchCircleLineWidth = 0, hideThumb = false } = options || {};
|
|
327
|
+
const { touchCircleStrokeStyle = '', touchCircleLineWidth = 0, hideThumb = false, lineCap = 'round' } = options || {};
|
|
331
328
|
this.touchCircleStrokeStyle = touchCircleStrokeStyle;
|
|
332
329
|
this.touchCircleLineWidth = touchCircleLineWidth;
|
|
333
330
|
this.hideThumb = hideThumb;
|
|
@@ -351,18 +348,19 @@ export default Render({
|
|
|
351
348
|
|
|
352
349
|
const startAngle = Math.PI * 0.75;
|
|
353
350
|
const endAngle = Math.PI * 0.25;
|
|
354
|
-
|
|
351
|
+
const counterclockwise = false;
|
|
355
352
|
ctx.beginPath();
|
|
356
353
|
ctx.arc(
|
|
357
354
|
radius * 2,
|
|
358
355
|
radius * 2,
|
|
359
356
|
innerRingRadius * 2 + (radius - innerRingRadius),
|
|
360
357
|
startAngle,
|
|
361
|
-
endAngle
|
|
358
|
+
endAngle,
|
|
359
|
+
counterclockwise
|
|
362
360
|
);
|
|
363
361
|
|
|
364
362
|
let grd = null;
|
|
365
|
-
if (ctx.createConicGradient) {
|
|
363
|
+
if (ctx.createConicGradient && lineCap === 'round') {
|
|
366
364
|
try {
|
|
367
365
|
grd = ctx.createConicGradient(startAngle - Math.PI * 0.1, radius * 2, radius * 2);
|
|
368
366
|
options.colorList?.forEach(item => {
|
|
@@ -373,7 +371,7 @@ export default Render({
|
|
|
373
371
|
//给曲线着色
|
|
374
372
|
ctx.strokeStyle = grd;
|
|
375
373
|
//连接处样式
|
|
376
|
-
ctx.lineCap = 'round';
|
|
374
|
+
ctx.lineCap = lineCap || 'round';
|
|
377
375
|
//给环着色
|
|
378
376
|
ctx.stroke();
|
|
379
377
|
ctx.closePath();
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const LampCirclePicker = props => {
|
|
|
16
16
|
colorList,
|
|
17
17
|
useEventChannel,
|
|
18
18
|
eventChannelName,
|
|
19
|
+
lineCap,
|
|
19
20
|
titleStyle,
|
|
20
21
|
descStyle,
|
|
21
22
|
descText,
|
|
@@ -57,6 +58,7 @@ const LampCirclePicker = props => {
|
|
|
57
58
|
touchCircleStrokeStyle: touchCircleStrokeStyle,
|
|
58
59
|
innerRingRadius: innerRingRadius,
|
|
59
60
|
colorList: _colorList,
|
|
61
|
+
lineCap: lineCap,
|
|
60
62
|
useEventChannel: useEventChannel || false,
|
|
61
63
|
eventChannelName: eventChannelName,
|
|
62
64
|
onTouchStart: onTouchStart,
|
package/lib/props.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface IProps {
|
|
|
19
19
|
* @description.en Whether to hide the drag ring
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
|
-
hideThumb
|
|
22
|
+
hideThumb?: boolean;
|
|
23
23
|
/**
|
|
24
24
|
* @description.en temperature
|
|
25
25
|
* @description.zh 色温
|
|
@@ -74,6 +74,12 @@ export interface IProps {
|
|
|
74
74
|
* @default null
|
|
75
75
|
*/
|
|
76
76
|
eventChannelName?: string;
|
|
77
|
+
/**
|
|
78
|
+
* @description.zh 绘制的圆环末端样式
|
|
79
|
+
* @description.en Drawn ring end style
|
|
80
|
+
* @default round
|
|
81
|
+
*/
|
|
82
|
+
lineCap?: 'butt' | 'round';
|
|
77
83
|
/**
|
|
78
84
|
* @description.en titleStyle
|
|
79
85
|
* @description.zh 标题样式
|