Skip to content

Commit

Permalink
Demo for v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanilo Andrianasolo committed Jan 30, 2021
1 parent 1156ebf commit c3b6edc
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 4 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Created by .ignore support plugin (hsz.mobi)
.idea
.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Streamlit Drawable Canvas demo on Streamlit Sharing

[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/andfanilo/streamlit-drawable-canvas-demo/master/app.py)
[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/andfanilo/streamlit-drawable-canvas-demo/master/app.py)
6 changes: 6 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import pandas as pd
from PIL import Image
import streamlit as st
Expand All @@ -24,6 +25,10 @@
)
realtime_update = st.sidebar.checkbox("Update in realtime", True)

with open("star_state.json", "r") as f:
star_state = json.load(f)
star_state["background"] = bg_color

# Create a canvas component
canvas_result = st_canvas(
fill_color="rgba(255, 165, 0, 0.3)", # Fixed fill color with some opacity
Expand All @@ -34,6 +39,7 @@
update_streamlit=realtime_update,
height=150,
drawing_mode=drawing_mode,
initial_drawing=star_state if st.sidebar.checkbox("Initialize with star") else None,
key="canvas",
)

Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# this is a shim to work with S4A for now, until requirements are read from folder containing the Streamlit Python script
streamlit>=0.65
streamlit-drawable-canvas
streamlit>=0.69
streamlit-drawable-canvas>=0.6
138 changes: 138 additions & 0 deletions star_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"version": "3.6.3",
"objects": [
{
"type": "path",
"version": "3.6.3",
"originX": "left",
"originY": "top",
"left": 106.5,
"top": 17.5,
"width": 196.6,
"height": 125,
"fill": null,
"stroke": "#000000",
"strokeWidth": 3,
"strokeDashArray": null,
"strokeLineCap": "round",
"strokeDashOffset": 0,
"strokeLineJoin": "round",
"strokeMiterLimit": 10,
"scaleX": 1,
"scaleY": 1,
"angle": 0,
"flipX": false,
"flipY": false,
"opacity": 1,
"shadow": null,
"visible": true,
"clipTo": null,
"backgroundColor": "",
"fillRule": "nonzero",
"paintFirst": "fill",
"globalCompositeOperation": "source-over",
"transformMatrix": null,
"skewX": 0,
"skewY": 0,
"path": [
["M", 174.997, 73.003],
["Q", 175, 73, 178, 68],
["Q", 181, 63, 185, 55.5],
["Q", 189, 48, 193.5, 41],
["Q", 198, 34, 201.5, 29],
["Q", 205, 24, 206.5, 21.5],
["Q", 208, 19, 208.5, 19],
["Q", 209, 19, 209.5, 21.5],
["Q", 210, 24, 212, 34.5],
["Q", 214, 45, 215.5, 54.5],
["Q", 217, 64, 218.5, 72],
["Q", 220, 80, 220.5, 82],
["Q", 221, 84, 221, 85],
["Q", 221, 86, 221.5, 86],
["Q", 222, 86, 222.5, 86],
["Q", 223, 86, 224.5, 85.5],
["Q", 226, 85, 231, 85],
["Q", 236, 85, 243.5, 85],
["Q", 251, 85, 260, 85],
["Q", 269, 85, 278, 85],
["Q", 287, 85, 293, 85],
["Q", 299, 85, 302, 85],
["Q", 305, 85, 304, 85],
["Q", 303, 85, 300.5, 85.5],
["Q", 298, 86, 294, 87.5],
["Q", 290, 89, 286, 90],
["Q", 282, 91, 273.5, 94.5],
["Q", 265, 98, 255, 100.5],
["Q", 245, 103, 238, 104.5],
["Q", 231, 106, 228, 107],
["Q", 225, 108, 224, 108.5],
["Q", 223, 109, 223.5, 110],
["Q", 224, 111, 229, 118],
["Q", 234, 125, 235, 127.5],
["Q", 236, 130, 236.5, 132],
["Q", 237, 134, 238, 136],
["Q", 239, 138, 239, 139],
["Q", 239, 140, 239, 141],
["Q", 239, 142, 239, 142.5],
["Q", 239, 143, 239, 143.5],
["Q", 239, 144, 238.5, 144],
["Q", 238, 144, 237, 144],
["Q", 236, 144, 230, 140.5],
["Q", 224, 137, 221, 135.5],
["Q", 218, 134, 215, 132.5],
["Q", 212, 131, 209, 129],
["Q", 206, 127, 205.5, 126.5],
["Q", 205, 126, 204, 124.5],
["Q", 203, 123, 202.5, 122.5],
["Q", 202, 122, 201, 121.5],
["Q", 200, 121, 199.5, 120.5],
["Q", 199, 120, 198.5, 120],
["Q", 198, 120, 195.5, 118],
["Q", 193, 116, 192.5, 114.5],
["Q", 192, 113, 191.5, 112.5],
["Q", 191, 112, 190.5, 112],
["Q", 190, 112, 188.5, 112.5],
["Q", 187, 113, 186, 113.5],
["Q", 185, 114, 183, 114.5],
["Q", 181, 115, 173.5, 118.5],
["Q", 166, 122, 157.5, 124],
["Q", 149, 126, 140, 127],
["Q", 131, 128, 124, 129],
["Q", 117, 130, 114, 130],
["Q", 111, 130, 110.5, 130],
["Q", 110, 130, 110.5, 130],
["Q", 111, 130, 112, 130],
["Q", 113, 130, 113.5, 129.5],
["Q", 114, 129, 115.5, 128],
["Q", 117, 127, 117.5, 126.5],
["Q", 118, 126, 119.5, 125.5],
["Q", 121, 125, 124.5, 122.5],
["Q", 128, 120, 131.5, 119],
["Q", 135, 118, 138.5, 116.5],
["Q", 142, 115, 146.5, 113],
["Q", 151, 111, 157.5, 107.5],
["Q", 164, 104, 166.5, 103.5],
["Q", 169, 103, 169.5, 102.5],
["Q", 170, 102, 167, 101.5],
["Q", 164, 101, 155, 98],
["Q", 146, 95, 138.5, 92],
["Q", 131, 89, 123.5, 85.5],
["Q", 116, 82, 112.5, 81],
["Q", 109, 80, 108.5, 79.5],
["Q", 108, 79, 108, 78],
["Q", 108, 77, 109.5, 77],
["Q", 111, 77, 112.5, 76.5],
["Q", 114, 76, 116.5, 75.5],
["Q", 119, 75, 121, 74.5],
["Q", 123, 74, 129.5, 72],
["Q", 136, 70, 140, 69.5],
["Q", 144, 69, 149, 68.5],
["Q", 154, 68, 158.5, 68],
["Q", 163, 68, 165, 68],
["Q", 167, 68, 169, 68],
["L", 171.003, 68]
]
}
],
"background": "#eee"
}

0 comments on commit c3b6edc

Please sign in to comment.