-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
269 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { animated, useSpring } from 'react-spring'; | ||
|
||
type CircleVizProps = { | ||
r: number; | ||
cx: number; | ||
cy: number; | ||
fill: string; | ||
stroke: string; | ||
fillOpacity: number; | ||
strokeWidth: number; | ||
onMouseDown: () => void; | ||
onMouseUp: () => void; | ||
}; | ||
|
||
export const Circle = ({ | ||
r, | ||
cx, | ||
cy, | ||
fill, | ||
stroke, | ||
fillOpacity, | ||
strokeWidth, | ||
onMouseDown, | ||
onMouseUp, | ||
}: CircleVizProps) => { | ||
const springProps = useSpring({ | ||
to: { r, cx, cy, fill, stroke, fillOpacity, strokeWidth }, | ||
}); | ||
|
||
return ( | ||
<animated.circle | ||
cursor={'pointer'} | ||
strokeWidth={springProps.strokeWidth} | ||
fillOpacity={springProps.fillOpacity} | ||
r={springProps.r} | ||
cy={springProps.cy} | ||
cx={springProps.cx} | ||
stroke={springProps.stroke} | ||
fill={springProps.fill} | ||
onMouseDown={onMouseDown} | ||
onMouseUp={onMouseUp} | ||
/> | ||
); | ||
}; |
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,24 @@ | ||
import { animated, useSpring } from 'react-spring'; | ||
|
||
type LineVizProps = { | ||
x1: number; | ||
y1: number; | ||
x2: number; | ||
y2: number; | ||
}; | ||
|
||
export const Line = ({ x1, y1, x2, y2 }: LineVizProps) => { | ||
const springProps = useSpring({ | ||
to: { x1, y1, x2, y2 }, | ||
}); | ||
|
||
return ( | ||
<animated.line | ||
x1={springProps.x1} | ||
y1={springProps.y1} | ||
x2={springProps.x2} | ||
y2={springProps.y2} | ||
stroke="black" | ||
/> | ||
); | ||
}; |
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
Oops, something went wrong.