Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClippingBoxes Context #13

Merged
merged 2 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[WIP]
  • Loading branch information
okathira committed Feb 22, 2021
commit 0a9404cb6d22d24ccaf2225a910265ec0e58a332
14 changes: 13 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ import { cameraSize, videoConstraints } from "./defaultConfig";

const App: React.FC = () => {
const [baseCanvas, setBaseCanvas] = useState(createCanvas(cameraSize));
const [boxesProps, setBoxesProps] = useState<BoxProps[]>([]);
const [boxesProps, setBoxesProps] = useState<BoxProps[]>([
{
key: 0,
srcX: 50,
srcY: 100,
srcWidth: 1000,
srcHeight: 500,
showX: 50,
showY: 100,
showWidth: 1000,
showHeight: 500,
},
]);

const cameraRef = useRef<Webcam>(null);
const frameInterval = useRef<NodeJS.Timeout>();
Expand Down
8 changes: 6 additions & 2 deletions src/ClippingBoxes.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from "react";
import { Image } from "react-konva";
import { useBoxesProps } from "./contextData";

const ClippingBoxes: React.FC<{
currentFrame: CanvasImageSource;
boxesProps: BoxProps[]; // TODO: コンテキストにするとレンダリングされないのを治す
}> = ({ currentFrame, boxesProps }) => {
_boxesProps: BoxProps[]; // TODO: コンテキストにするとレンダリングされないのを治す
}> = ({ currentFrame, _boxesProps }) => {
const boxesProps = useBoxesProps();

return (
<>
{(() =>
// _boxesProps
boxesProps.map((boxProps) => (
<Image
key={boxProps.key}
Expand Down
2 changes: 1 addition & 1 deletion src/OutputArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const OutputArea: React.FC<{
>
<Layer>
<Image image={baseCanvas} />
<ClippingBoxes currentFrame={baseCanvas} boxesProps={boxesProps} />
<ClippingBoxes currentFrame={baseCanvas} _boxesProps={boxesProps} />
</Layer>
</Stage>
);
Expand Down