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

Add Polyline/Polygon #10

Open
andfanilo opened this issue Aug 26, 2020 · 14 comments
Open

Add Polyline/Polygon #10

andfanilo opened this issue Aug 26, 2020 · 14 comments
Assignees
Labels
enhancement New feature or request

Comments

@andfanilo
Copy link
Owner

andfanilo commented Aug 26, 2020

As a user I want to be able to draw polyline (one click during line drawing = one new anchor point)

fabricjs/fabric.js#6319

@andfanilo andfanilo added the enhancement New feature or request label Aug 26, 2020
@andfanilo andfanilo changed the title Add Polyline Add Polyline/Polygon Sep 12, 2020
@robmarkcole
Copy link

I have a use case for this :-)

@andfanilo
Copy link
Owner Author

Ahah okay :)
leaving notes for myself:

  • should we be able to edit a ploygon point per point? or transform should apply to all polygon and just delkete/build one if needed?
  • is polyline really interesting? or focus on polygon first? maybe if fill color then do polygon else if none make polyline?
  • whole lot of polygon drawing on google so not scared XD

@hiankun
Copy link
Contributor

hiankun commented May 14, 2021

I have came up with very messy code to draw "polygons" in my own tests. There are temporary line segments and polygons during the drawing process.

The code so far has a main problem which I believe due to my very limited understanding of Fabric.js and the mechanism of Streamlit. When drawing the "polygons", I have to disable "Update in realtime" or the aforementioned line segments will appear in the canvas and the polygon won't be created.

Should I create a PR to show you the code?

streamlit-polypath

@andfanilo
Copy link
Owner Author

Sure @hiankun ! That'll help kickstart the conversation.
If the only problem is disabling the update in realtime part we could try and reorganize which events provoke a Streamlit rerender ;) so feel free to share via PR
Fanilo 🎈

@hiankun
Copy link
Contributor

hiankun commented May 15, 2021

Hi, I have created the PR #51 . Please check it when you have time to review. :-)

@andfanilo
Copy link
Owner Author

Thanks, I saw the PR, I'll have a look ASAP this week! (I have some other deadlines to solve first :( ...)

@hiankun
Copy link
Contributor

hiankun commented May 17, 2021

@andfanilo No hurry. Take your time please.

@andfanilo
Copy link
Owner Author

@robmarkcole @hiankun #51 has been merged and I made a new 0.8.0 release. I pushed an update to the demo to add polygon to the Basic example. I'll let you play with it, test it, and then will promote it on the forums/social media around late Tuesday 😉

Thanks Hian-Kun for the awesome contribution!

@hiankun
Copy link
Contributor

hiankun commented Jun 7, 2021

I am so lucky to contribute to such a great project. Thank you for all the discussion and instruction. :-)

@hiankun
Copy link
Contributor

hiankun commented Jun 7, 2021

@andfanilo

I pushed an update to the demo to add polygon to the Basic example.

Should we add a description to tell users that now they can use right-click to update the canvas?

@andfanilo
Copy link
Owner Author

Yeah I added it in the CHANGELOG and in the demo app description but I did not commit/push those yet. Will do at the same time as promoting the release.

@hiankun
Copy link
Contributor

hiankun commented Jun 14, 2021

I have been using v0.8.0 in my app and found two bugs. Write them down here:

  1. When using double-click to cancel latest point, we have to move mouse to any other position to make it work. If we keep double-clicking at the same position then it won't cancel anything.
  2. After canceling a polygon with double-clicks, if we don't use right-click to "update", then the cancelled polygon will appear as a zero-sized polygon in the json data as shown in the screenshot. Other "update mechanisms" won't remove the zero-sized polygon. Only right-click will do the trick. (Edit: The right-click only remove the latest zero-sized polygon.)

2021-06-14-195010_708x490_scrot

@hiankun
Copy link
Contributor

hiankun commented Jun 14, 2021

Another bug, which might be also related to the right-click interfering with the update mechanism (just a quick guess).

When canvas has a background image, the latest drawn polygon will be removed if we right-click again. However, if we do any other operations such as left-click or draw another shape, the right-click won't remove that polygon. The bug looks like the previous bug that the right-click only remove the zero-sized polygon which is created by the latest operation on the canvas.

@andfanilo
Copy link
Owner Author

Thanks for updating,

I'm currently installing my new personal workstation, hopefully it will be finished this weekend and I can come back to studying this issue!

Fanilo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants