Skip to content

Commit

Permalink
feat: circle
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-kfd committed Jul 2, 2021
1 parent 1b0a0fa commit a7fca24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/components/s-circle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function SCircle(props: SCircleProps) {
const DOT_R = 5
const CIRCLE_NUM = 3
const CIRCLE_DELAY = 2000
const CIRCLE_SCALE_OFFSET = 80

const canvas = useRef<Canvas>()
const circle = useRef<IShape>()
Expand Down Expand Up @@ -63,12 +64,15 @@ export default function SCircle(props: SCircleProps) {
})

const addCircle = () => {
return (canvas.current as Canvas).addShape('path', {
return (canvas.current as Canvas).addShape('circle', {
attrs: {
stroke: LINE_COLOR,
lineWidth: 2,
path: getCirclePath(X, Y, R),
opacity: 0
opacity: 0,
x: X,
y: Y,
r: R
//path: getCirclePath(X, Y, R),
}
})
};
Expand Down Expand Up @@ -96,7 +100,8 @@ export default function SCircle(props: SCircleProps) {
circleArr.current.push(addCircle())
circleArr.current[index].animate((ratio: number) => {
return {
path: getCirclePath(X, Y, R + ratio * 80),
r: R + ratio * CIRCLE_SCALE_OFFSET,
// path: getCirclePath(X, Y, R + ratio * 80),
opacity: ratio > 0.02 && ratio < 0.9 ? 0.8 - ratio * 0.8 : 0
}
}, animateOption)
Expand All @@ -112,7 +117,7 @@ export default function SCircle(props: SCircleProps) {
const deg = circleDotDegArr.current[index] + ratio * 360 - 180
const l = Math.cos(deg * Math.PI / 180)
const t = Math.sin(deg * Math.PI / 180)
const r = R + ratio * 80
const r = R + ratio * CIRCLE_SCALE_OFFSET
return {
x: X + l * r,
y: Y + t * r,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Canvas, IShape } from "@antv/g-canvas";
import { Canvas } from "@antv/g-canvas";
import { ext } from '@antv/matrix-util';

const { transform } = ext
Expand Down

0 comments on commit a7fca24

Please sign in to comment.