Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lamp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夜猫
lamp
Commits
46f54cd3
Commit
46f54cd3
authored
Nov 18, 2022
by
zhushengjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
角度转换并获取定位
parent
a0d00443
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
13 deletions
+44
-13
index.tsx
src/components/hubCircle/index.tsx
+8
-8
index.tsx
src/components/hubColorCircle/index.tsx
+36
-5
No files found.
src/components/hubCircle/index.tsx
View file @
46f54cd3
...
@@ -76,18 +76,19 @@ const HubCircle: React.FC<Props> = props => {
...
@@ -76,18 +76,19 @@ const HubCircle: React.FC<Props> = props => {
let
rad
;
let
rad
;
let
left
=
79
;
let
left
=
79
;
let
top
=
0
;
let
top
=
0
;
if
(
tempValue
>
=
500
)
{
if
(
tempValue
>
500
)
{
rad
=
((
tempValue
-
500
)
*
(
dataSourse
.
angleLimit
/
500
)
*
Math
.
PI
)
/
180
;
rad
=
((
tempValue
-
500
)
*
(
dataSourse
.
angleLimit
/
500
)
*
Math
.
PI
)
/
180
;
const
y
=
dataSourse
.
bar_c_r
*
Math
.
cos
(
rad
);
const
y
=
dataSourse
.
bar_c_r
*
Math
.
cos
(
rad
);
const
x
=
dataSourse
.
bar_c_r
*
Math
.
sin
(
rad
);
const
x
=
dataSourse
.
bar_c_r
*
Math
.
sin
(
rad
);
left
=
left
-
dataSourse
.
bar_r
+
x
;
left
+=
x
;
top
=
dataSourse
.
circle_r
-
y
-
dataSourse
.
bar_r
;
top
=
dataSourse
.
circle_r
-
y
-
dataSourse
.
bar_r
;
}
}
if
(
tempValue
<
500
)
{
if
(
tempValue
<
500
)
{
rad
=
(
tempValue
*
(
dataSourse
.
angleLimit
/
500
)
*
Math
.
PI
)
/
180
;
rad
=
(
(
500
-
tempValue
)
*
(
dataSourse
.
angleLimit
/
500
)
*
Math
.
PI
)
/
180
;
const
x
=
dataSourse
.
bar_c_r
*
Math
.
cos
(
rad
);
const
x
=
dataSourse
.
bar_c_r
*
Math
.
sin
(
rad
);
const
y
=
dataSourse
.
bar_c_r
*
Math
.
cos
(
rad
);
const
y
=
dataSourse
.
bar_c_r
*
Math
.
cos
(
rad
);
left
=
left
+
dataSourse
.
bar_r
-
x
;
left
-=
x
;
top
=
dataSourse
.
circle_r
-
y
-
dataSourse
.
bar_r
;
top
=
dataSourse
.
circle_r
-
y
-
dataSourse
.
bar_r
;
}
}
return
{
return
{
...
@@ -305,7 +306,6 @@ const HubCircle: React.FC<Props> = props => {
...
@@ -305,7 +306,6 @@ const HubCircle: React.FC<Props> = props => {
top
:
`${circleLocation.top}px`
,
top
:
`${circleLocation.top}px`
,
width
:
`${dataSourse.bar_r * 2}px`
,
width
:
`${dataSourse.bar_r * 2}px`
,
height
:
`${dataSourse.bar_r * 2}px`
,
height
:
`${dataSourse.bar_r * 2}px`
,
transform
:
`translateX(${translateX}px) translateY(${translateY}px)`
,
}
}
}
}
onTouchStart=
{
handleBarTouch
}
onTouchStart=
{
handleBarTouch
}
onTouchMove=
{
handleBarMove
}
onTouchMove=
{
handleBarMove
}
...
@@ -314,7 +314,7 @@ const HubCircle: React.FC<Props> = props => {
...
@@ -314,7 +314,7 @@ const HubCircle: React.FC<Props> = props => {
</
View
>
</
View
>
</
View
>
</
View
>
<
View
className=
{
styles
.
panel
}
>
<
View
className=
{
styles
.
panel
}
>
<
View
className=
{
styles
.
configList
}
>
{
/*
<View className={styles.configList}>
<Image src={imgs.icon_bhd} className={styles.icoImg} />
<Image src={imgs.icon_bhd} className={styles.icoImg} />
<View className={styles.slider}>
<View className={styles.slider}>
<Slider
<Slider
...
@@ -335,7 +335,7 @@ const HubCircle: React.FC<Props> = props => {
...
@@ -335,7 +335,7 @@ const HubCircle: React.FC<Props> = props => {
)}
)}
%
%
</Text>
</Text>
</
View
>
</View>
*/
}
<
View
className=
{
styles
.
configList
}
>
<
View
className=
{
styles
.
configList
}
>
<
Image
src=
{
imgs
.
icon_ld
}
className=
{
styles
.
icoImg
}
/>
<
Image
src=
{
imgs
.
icon_ld
}
className=
{
styles
.
icoImg
}
/>
<
View
className=
{
styles
.
slider
}
>
<
View
className=
{
styles
.
slider
}
>
...
...
src/components/hubColorCircle/index.tsx
View file @
46f54cd3
...
@@ -43,6 +43,7 @@ const HubCircle: React.FC<Props> = props => {
...
@@ -43,6 +43,7 @@ const HubCircle: React.FC<Props> = props => {
circle_r
:
100
,
// 圆形外半径(容器宽度/2)
circle_r
:
100
,
// 圆形外半径(容器宽度/2)
circle_b
:
42
,
// 圆形边距
circle_b
:
42
,
// 圆形边距
bar_r
:
21
,
// 小球半径(圆形边距/2)
bar_r
:
21
,
// 小球半径(圆形边距/2)
bar_c_r
:
100
-
21
,
// 小球轨迹半径(圆形边距/2)
hue
:
270
,
hue
:
270
,
};
};
...
@@ -62,15 +63,46 @@ const HubCircle: React.FC<Props> = props => {
...
@@ -62,15 +63,46 @@ const HubCircle: React.FC<Props> = props => {
const
[
dataState
,
setDataState
]
=
useState
({
const
[
dataState
,
setDataState
]
=
useState
({
hue
:
Hue
,
// 角度展示 0 ~ 180
hue
:
Hue
,
// 角度展示 0 ~ 180
temp_value
:
500
,
temp_value
:
Temp_value
,
bright_value
:
500
,
bright_value
:
Bright_value
,
nowColor
:
hueToColor
(
Hue
),
// 当前颜色
nowColor
:
hueToColor
(
Hue
),
// 当前颜色
});
});
const
circleLocationOrigin
=
(
hue
:
number
)
=>
{
let
angel
=
hue
-
90
;
let
rad
;
let
left
=
79
;
let
top
=
0
;
if
(
angel
>
180
)
{
angel
=
-
(
360
-
angel
);
}
if
(
angel
<
0
)
{
rad
=
(
-
angel
*
Math
.
PI
)
/
180
;
const
y
=
dataSourse
.
bar_c_r
*
Math
.
cos
(
rad
);
const
x
=
dataSourse
.
bar_c_r
*
Math
.
sin
(
rad
);
left
+=
x
;
top
=
dataSourse
.
circle_r
-
y
-
dataSourse
.
bar_r
;
}
if
(
angel
>
0
)
{
rad
=
(
angel
*
Math
.
PI
)
/
180
;
const
x
=
dataSourse
.
bar_c_r
*
Math
.
sin
(
rad
);
const
y
=
dataSourse
.
bar_c_r
*
Math
.
cos
(
rad
);
left
-=
x
;
top
=
dataSourse
.
circle_r
-
y
-
dataSourse
.
bar_r
;
}
return
{
left
,
top
,
};
};
const
[
circleLocation
,
setCircleLocation
]
=
useState
({
const
[
circleLocation
,
setCircleLocation
]
=
useState
({
// 小球位置
// 小球位置
left
:
79
,
left
:
circleLocationOrigin
(
Hue
).
left
,
top
:
0
,
top
:
circleLocationOrigin
(
Hue
).
top
,
});
});
const
toParseInt
=
(
value
:
number
):
number
=>
{
const
toParseInt
=
(
value
:
number
):
number
=>
{
...
@@ -80,7 +112,6 @@ const HubCircle: React.FC<Props> = props => {
...
@@ -80,7 +112,6 @@ const HubCircle: React.FC<Props> = props => {
const
handleCirleClick
=
(
e
:
any
,
item
:
colorItem
):
void
=>
{
const
handleCirleClick
=
(
e
:
any
,
item
:
colorItem
):
void
=>
{
e
.
origin
.
stopPropagation
();
e
.
origin
.
stopPropagation
();
const
dpValue
=
hsvToDpdata
(
dataState
.
hue
,
dataState
.
temp_value
,
dataState
.
bright_value
);
const
dpValue
=
hsvToDpdata
(
dataState
.
hue
,
dataState
.
temp_value
,
dataState
.
bright_value
);
console
.
log
(
dpValue
);
props
.
onSetDpState
(
'colour_data'
,
dpValue
);
props
.
onSetDpState
(
'colour_data'
,
dpValue
);
const
index
=
colorArr
.
findIndex
(
el
=>
{
const
index
=
colorArr
.
findIndex
(
el
=>
{
return
(
return
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment