import { memo } from 'react' const styleBase = { stroke: 'none', strokeLinecap: 'butt', strokeLinejoin: 'miter', } const styleCasing = { ...styleBase, fill: '#808080', }; const styleGround = { ...styleBase, fill: '#deaa87', }; const styleTower = { ...styleBase, fill: '#999999', }; const styleWell = { ...styleBase, fill: '#37abc8', }; const styleBitDrive = { ...styleBase, fill: '#ff8080', }; const styleBitTool = { ...styleBase, fill: '#f9f9f9', }; const styleBlock = { ...styleBase, fill: '#ffdd55', }; // const stylePump1 = { // ...styleBase, // fill: '#5fd35f', // }; // const stylePump2 = { // ...styleBase, // fill: '#b3b3b3', // }; export const RigMnemo = memo(({ blockPosition, bitPosition, wellDepth }) => { let blockPositionY = 0 let bitPositionY = 0 const isBlockVisible = Number.isFinite(blockPosition) const isBitVisible = Number.isFinite(bitPosition) && Number.isFinite(wellDepth) if (isBlockVisible) blockPositionY = -35 + (50 * (30 - +blockPosition) / 30) if (isBitVisible) { const bitPositionLocal = +bitPosition const wellDepthLocal = +wellDepth const altitude = 8 //-75 + 75*bitPositionProc const bitPositionProc = (bitPositionLocal)/(wellDepthLocal) if (bitPositionLocal < altitude) bitPositionY = -75 + 16 * bitPositionLocal/altitude else bitPositionY = -59 + 59 * bitPositionLocal / wellDepthLocal if( wellDepthLocal > 20 && (wellDepthLocal - bitPositionLocal) > 2 && bitPositionProc > 0.96) bitPositionY = -2 } const blockTranslate = `translate(-75, ${blockPositionY})` const bitTranslate = `translate(0, ${bitPositionY})` return ( {isBitVisible && ( )} {isBlockVisible && ( )} {/* */} ) }) export default RigMnemo