From 172f28107205676d20249704ba89133418a828d7 Mon Sep 17 00:00:00 2001 From: brausjonas Date: Fri, 7 Jul 2023 20:37:20 +0200 Subject: [PATCH] Font Size Settings --- src/Drawing.js | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Drawing.js b/src/Drawing.js index 9ce1d90..16f30df 100644 --- a/src/Drawing.js +++ b/src/Drawing.js @@ -13,8 +13,7 @@ let lastPositions = [] let strokeWidth = 2 let lastMouse = 0 let eraserColor = "rgb(255, 255, 255)" -let lastStrokeWidthPencil = 2, lastStrokeWidthEraser = 20, lastStrokeWidthRect = 2, lastStrokeWidthCircle = 2, - lastStrokeWidthLine = 2 +let lastStrokeWidthPencil = 2, lastStrokeWidthEraser = 20, lastStrokeWidthRect = 2, lastStrokeWidthCircle = 2, lastStrokeWidthText = 16, lastStrokeWidthLine = 2 let hintCanvas @@ -309,6 +308,9 @@ export default function Drawing(p) { } else if (e.target.value === "line") { setStrokeWidthSliderValue(lastStrokeWidthLine) strokeWidth = lastStrokeWidthLine + } else if(e.target.value === "text") { + setStrokeWidthSliderValue(lastStrokeWidthText) + strokeWidth = lastStrokeWidthText } } @@ -344,12 +346,12 @@ export default function Drawing(p) { position: "absolute", top: textInputY, left: textInputX, - fontSize: 25, + fontSize: strokeWidthSliderValue + "px", fontFamily: "sans-serif" }} onKeyDown={e => { if (e.key === "Enter") { mouseDownCanvas = false - context.font = "25px sans-serif" + context.font = strokeWidthSliderValue + "px sans-serif" context.textAlign = "center" context.fillText(textInput.value, formAnchor.x, formAnchor.y + 10) textInput.value = "" @@ -422,6 +424,8 @@ export default function Drawing(p) {
+ + {/*Color Selector*/} + { + setColorValue(e.target.value) + }} value={colorValue}/>
+ { setStrokeWidthSliderValue(e.currentTarget.value) strokeWidth = e.currentTarget.value @@ -590,29 +609,20 @@ export default function Drawing(p) { } else if (selectedTool === "line") { lastStrokeWidthLine = strokeWidth } + else if(selectedTool === "text") { + lastStrokeWidthText = strokeWidth + } }} style={{ pointerEvents: "auto", - display: ((selectedTool === "selector" || selectedTool === "text" || selectedTool === "mover") ? "none" : "block") + display: ((selectedTool === "selector" || selectedTool === "mover") ? "none" : "block") }}/>

{strokeWidthSliderValue}

- {/*Color Selector*/} - { - setColorValue(e.target.value) - }} value={colorValue}/>