diff --git a/src/App.js b/src/App.js index e6fe1c9..8945619 100644 --- a/src/App.js +++ b/src/App.js @@ -753,6 +753,9 @@ function App() { const [LOGGEDINUSER,setLOGGEDINUSER] = useState("") const [LOGGEDINHASH,setLOGGEDINHASH] = useState("") + const [gridDimensionsX,setGridDimensionsX] = useState(5) + const [gridDimensionsY,setGridDimensionsY] = useState(5) + function GetData(table,row,col,id){ var data = id?DATAID:DATA @@ -833,7 +836,7 @@ function App() {
+ + Width: {setGridDimensionsX(Number(f.currentTarget.value))}} value={gridDimensionsX}/> + Height: {setGridDimensionsY(Number(f.currentTarget.value))}} value={gridDimensionsY}/>
diff --git a/src/skilltree/skillTree.js b/src/skilltree/skillTree.js index 78f7286..6fa753a 100644 --- a/src/skilltree/skillTree.js +++ b/src/skilltree/skillTree.js @@ -1,12 +1,20 @@ -import { useRef,useEffect } from 'react'; +import { useRef,useEffect,useState } from 'react'; import { contextType } from 'react-modal'; function SkillTree(p) { const canvasRef = useRef(null) + const [width,setWidth] = useState(0) + const [height,setHeight] = useState(0) useEffect(() => { + setWidth(p.gridSize[0]*p.gridDimensionsX+p.gridPadding[0]*(p.gridDimensionsX-1)) + setHeight(p.gridSize[1]*p.gridDimensionsY+p.gridPadding[1]*(p.gridDimensionsY-1)) + }, [p.skillLines,p.gridSize,p.gridPadding,p.gridDimensionsX,p.gridDimensionsY]) + + useEffect(()=>{ const canvas = canvasRef.current const context = canvas.getContext('2d') + context.clearRect(0,0,width,height) context.fillStyle = '#AA6666' /*for (var x=0;x + width={width} + height={height} ref={canvasRef} {...p}/> } export {SkillTree} \ No newline at end of file