Replicate the app from the image.
To upload files, please first save the app
import streamlit as st
from streamlit_drawable_canvas import st_canvas
st.title("Drawing Canvas")
# Create a canvas component
canvas_result = st_canvas(
fill_color="rgba(255, 165, 0, 0.3)", # Fixed fill color with some opacity
stroke_width=3,
stroke_color="#000000",
background_color="#FFFFFF",
background_image=None,
update_streamlit=True,
height=400,
width=600,
drawing_mode="freedraw",
point_display_radius=0,
key="canvas",
)
# Display some information about the canvas
if canvas_result.image_data is not None:
st.write("Canvas updated!")
# Add some controls
st.sidebar.header("Drawing Controls")
# Color picker for stroke
stroke_color = st.sidebar.color_picker("Pick a stroke color", "#000000")
# Stroke width slider
stroke_width = st.sidebar.slider("Stroke width", 1, 25, 3)
# Drawing mode selection
drawing_mode = st.sidebar.selectbox(
"Drawing tool",
("freedraw", "line", "rect", "circle", "transform")
)
# Create canvas with updated parameters
canvas_result = st_canvas(
fill_color="rgba(255, 165, 0, 0.3)",
stroke_width=stroke_width,
stroke_color=stroke_color,
background_color="#FFFFFF",
background_image=None,
update_streamlit=True,
height=400,
width=600,
drawing_mode=drawing_mode,
point_display_radius=0 if drawing_mode == 'point' else 0,
key="main_canvas",
)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?