-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 3D point cloud supports custom colors in annotation
- Loading branch information
1 parent
5f52b80
commit a4733c7
Showing
10 changed files
with
181 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/lb-components/src/components/colorPalette/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @file Color Palette | ||
* @author lixinghua <[email protected]> | ||
* @date 2023.04.24 | ||
*/ | ||
import React from 'react'; | ||
import { RgbaColorPicker } from 'react-colorful'; | ||
import { toRGBAObj, toRGBAStr } from '@/utils/colorUtils'; | ||
|
||
interface IProps { | ||
defaultColor?: string; | ||
setColor: (color: string) => void; | ||
} | ||
|
||
const Palette = (props: IProps) => { | ||
const { setColor, defaultColor } = props; | ||
|
||
return ( | ||
<RgbaColorPicker | ||
color={defaultColor && toRGBAObj(defaultColor)} | ||
onChange={(values) => { | ||
const colorStr = toRGBAStr(values); | ||
setColor(colorStr); | ||
}} | ||
/> | ||
); | ||
}; | ||
export default Palette; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* transform rgba(a,g,b), to {r,g,b,a} / [r,g,b,a] | ||
* @param color | ||
*/ | ||
export const toRGBAObj = (rgbStr: string, toArray?: boolean) => { | ||
const match = rgbStr.replace(/[rgba()]/g, '').split(','); | ||
if (match) { | ||
const [r, g, b, a] = match; | ||
if (toArray) { | ||
return [r, g, b, a]; | ||
} | ||
return { r: Number(r), g: Number(g), b: Number(b), a: Number(a) }; | ||
} | ||
return ''; | ||
}; | ||
|
||
/** | ||
* transform {a,g,b,a} to rgba{r,g,b,a} | ||
* @param color | ||
*/ | ||
export const toRGBAStr = (color: { r: number; g: number; b: number; a: number }) => | ||
`rgba(${color.r},${color.g},${color.b},${color.a})`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters