PrakhAI commited on
Commit
1415c4c
·
1 Parent(s): 543bd37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -22
app.py CHANGED
@@ -20,25 +20,26 @@ print([(k, type(v)) for (k, v) in state.items()])
20
  # x = st.slider('Select a value')
21
  # st.write(x, 'squared is', x * x)
22
 
23
-
24
- canvas_result = st_canvas(
25
- fill_color="rgba(255, 165, 0, 0.3)", # Fixed fill color with some opacity
26
- stroke_width=st.sidebar.slider("Brush width: ", 1, 100, 10),
27
- stroke_color=st.sidebar.color_picker("Enter brush color hex: "),
28
- background_color=st.sidebar.color_picker("Enter background color hex: ", "#eee"),
29
- background_image=None,
30
- update_streamlit=st.sidebar.checkbox("Update in realtime", True),
31
- height=150,
32
- drawing_mode=st.sidebar.checkbox("Drawing mode ?", True),
33
- point_display_radius=point_display_radius if st.sidebar.selectbox(
34
- "Drawing tool:",
35
- ("freedraw", "line", "rect", "circle", "transform", "polygon", "point"),
36
- ) == "point" else 0,
37
- display_toolbar=st.sidebar.checkbox("Display toolbar", True),
38
- key="canvas",
39
- )
40
-
41
- # Do something interesting with the image data and paths
42
- if canvas_result.image_data is not None:
43
- st.image(canvas_result.image_data)
44
-
 
 
20
  # x = st.slider('Select a value')
21
  # st.write(x, 'squared is', x * x)
22
 
23
+ def canvas():
24
+ canvas_result = st_canvas(
25
+ fill_color="rgba(255, 165, 0, 0.3)", # Fixed fill color with some opacity
26
+ stroke_width=st.sidebar.slider("Brush width: ", 1, 100, 10),
27
+ stroke_color=st.sidebar.color_picker("Enter brush color hex: "),
28
+ background_color=st.sidebar.color_picker("Enter background color hex: ", "#eee"),
29
+ background_image=None,
30
+ update_streamlit=st.sidebar.checkbox("Update in realtime", True),
31
+ height=150,
32
+ drawing_mode=st.sidebar.checkbox("Drawing mode ?", True),
33
+ point_display_radius=point_display_radius if st.sidebar.selectbox(
34
+ "Drawing tool:",
35
+ ("freedraw", "line", "rect", "circle", "transform", "polygon", "point"),
36
+ ) == "point" else 0,
37
+ display_toolbar=st.sidebar.checkbox("Display toolbar", True),
38
+ key="canvas",
39
+ )
40
+
41
+ # Do something interesting with the image data and paths
42
+ if canvas_result.image_data is not None:
43
+ st.image(canvas_result.image_data)
44
+
45
+ canvas()