Drawable canvas

Hello @Alexander_Hexemer, responded on the GIthub issue but maybe that could help others:

Under the hood, json_data is a FabricJS object exported in JSON with .toObject.
It seems for a scaled object, you will need to apply the scaleX/scaleY factor to the height/width to retrieve the correct values. FabricJS preserves the original dimensions and applies a ratio independently.

st.text(f"Scaled height: {dic['height'] * dic['scaleY']}")
st.text(f"Scaled width: {dic['width'] * dic['scaleX']}")

doesn’t seem like rotating the rectangle adds more complexity :slight_smile: .

@andfanilo Thanks for this great component!

After playing around with this a while, I’m still trying to figure out if there is a way to pass drawings to the canvas or load a state from Streamlit? Has anyone had any success with this?

Hello @tcfkaj, welcome to the community !

Coming soon :wink:


1 Like

Hi im not that familiar with the component yet but id like to know if it is possible to have a jpg as background picture so u can draw above it. oh wait i just found it.


1 Like