@@ -28,6 +28,8 @@ const Canvas: React.FC = () => {
2828
2929 const toggleViewMode = ( ) => setIs3DMode ( ! is3DMode )
3030
31+ const getStrokeThickness = ( thickness ?: number ) => thickness ?? pathThickness
32+
3133 // Function to handle shape creation
3234 const createShape = useCallback (
3335 ( props : ShapeInterface ) => {
@@ -48,13 +50,13 @@ const Canvas: React.FC = () => {
4850 if ( props . endX === undefined || props . endY === undefined ) return
4951
5052 g . beginStroke ( props . strokeColor )
51- . setStrokeStyle ( props ?. thickness ?? pathThickness )
53+ . setStrokeStyle ( getStrokeThickness ( props ?. thickness ) )
5254 . moveTo ( 0 , 0 )
5355 . lineTo ( props . endX - props . x , props . endY - props . y )
5456 break
5557 case 'path' :
5658 if ( props ?. points && props . points ?. length > 1 ) {
57- g . beginStroke ( props . strokeColor ) . setStrokeStyle ( props ?. thickness ?? pathThickness )
59+ g . beginStroke ( props . strokeColor ) . setStrokeStyle ( getStrokeThickness ( props ?. thickness ) )
5860 g . moveTo ( props . points [ 0 ] . x , props . points [ 0 ] . y )
5961
6062 props . points . forEach ( ( point : { x : number ; y : number } , index : number ) => {
@@ -102,7 +104,7 @@ const Canvas: React.FC = () => {
102104 const g = this . graphics
103105 g . clear ( )
104106 . beginStroke ( props . strokeColor )
105- . setStrokeStyle ( props ?. thickness ?? pathThickness )
107+ . setStrokeStyle ( getStrokeThickness ( props ?. thickness ) )
106108 . moveTo ( 0 , 0 )
107109 . lineTo ( props . endX - props . x , props . endY - props . y )
108110 } else if ( props . type === 'path' && props . points ) {
0 commit comments