// Copyright (c) Meta Platforms, Inc. and affiliates. // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. import React from "react"; import Circle from "./Pose/Circle"; import Line from "./Pose/Line"; export default function App() { // grab global vars inserted by the Flask app const cfg = window.cfg; const imageData = window.image.data; const imageHeight = cfg.height; const imageWidth = cfg.width; const originalPoints = cfg.skeleton; const [points, setPoints] = React.useState(() => JSON.parse(JSON.stringify(originalPoints)) ); const [hoveredJoint, setHoveredJoint] = React.useState(null); const [isMoving, setIsMoving] = React.useState(false); return ( <>
{points.map((pt) => { if (!pt.parent) return; let parent = points.find((p) => p.name === pt.parent); return ( = 0 } /> ); })} {points.map((pt) => ( { const newPos = [pos.x, pos.y]; const newPts = points.map((p) => p.name !== pt.name ? p : { ...p, loc: newPos } ); setPoints(newPts); setIsMoving(pos.active); }} onHover={(enter) => { setHoveredJoint(enter ? pt.name : null); }} strokeWidth="2" stroke="white" r="4" /> ))} {hoveredJoint ? (
{hoveredJoint?.replace("l_", "left ")?.replace("r_", "right ")}
) : null}
); }