Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added zoom, text and eraser #153

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion streamlit_drawable_canvas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def st_canvas(
initial_drawing: dict = None,
display_toolbar: bool = True,
point_display_radius: int = 3,
font_name: str = "Arial", # Pass font name
key=None,
) -> CanvasResult:
"""Create a drawing canvas in Streamlit app. Retrieve the RGBA image data into a 4D numpy array (r, g, b, alpha)
Expand Down Expand Up @@ -125,8 +126,12 @@ def st_canvas(
background_image_url = st_image.image_to_url(
background_image, width, True, "RGB", "PNG", f"drawable-canvas-bg-{md5(background_image.tobytes()).hexdigest()}-{key}"
)
background_image_url = st._config.get_option("server.baseUrlPath") + background_image_url
base_url_path: str = st._config.get_option("server.baseUrlPath").strip("/")
if base_url_path:
base_url_path = "/" + base_url_path
background_image_url = base_url_path + background_image_url
background_color = ""


# Clean initial drawing, override its background color
initial_drawing = (
Expand All @@ -147,6 +152,7 @@ def st_canvas(
initialDrawing=initial_drawing,
displayToolbar=display_toolbar,
displayRadius=point_display_radius,
fontFamily=font_name,
key=key,
default=None,
)
Expand Down
Loading