Skip to content

Configurable Outline Thickness for Drawing Shapes #42

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

Closed
sumn2u opened this issue Jun 15, 2024 · 6 comments
Closed

Configurable Outline Thickness for Drawing Shapes #42

sumn2u opened this issue Jun 15, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers up for grabs

Comments

@sumn2u
Copy link
Owner

sumn2u commented Jun 15, 2024

During masking, we have set the outline thickness using width to only one region and it's hard coded.

draw.ellipse([rx, ry, rx + rw, ry + rh], outline=color, width=3, fill=color)

image

Introduce a configuration parameter (OUTLINE_THICKNESS) to control the thickness of outlines for shapes drawn using draw.polygon and draw.rectangle, and also update the draw.ellipse width value with this.

Benefits

  • Enhances consistency and flexibility in outline appearance.
  • Simplifies maintenance by managing outline thickness globally.

Implementation Plan

  1. Add OUTLINE_THICKNESS parameter to configuration settings.
  2. Modify drawing functions to use this parameter.
  3. Update documentation and examples accordingly in README.md.

Acceptance Criteria

  • Drawing functions correctly utilize OUTLINE_THICKNESS.
  • Global adjustment of outline thickness validated.
  • Changes integrated without regression.
@sumn2u sumn2u added enhancement New feature or request good first issue Good for newcomers up for grabs labels Jun 15, 2024
@DQ4443
Copy link
Contributor

DQ4443 commented Jun 16, 2024

Hello sumn2u, I would like to help with this issue.

@DQ4443
Copy link
Contributor

DQ4443 commented Jun 17, 2024

Hey Sumn2u, I reviewed the flask section of the code and updated the draw.foo() functions with a config variable, but as the only draw.foo functions are in the download routes, the width change is only reflected in the downloaded images and not in the preview. Is this what you were looking for, or should I update the frontend/js parts of the code base too?

preview screen:
image

downloaded:
image

Another issue: when the line thickness is set to a large number (I used 30 instead of the default of 3 in the picture above), the corners are very visibly jagged. You might wish to consider implementing logic for rounding out the ends of the lines to fix this issue. This issue is definitely less noticeable on thinner outline values (as in the preview picture).

Also with regards to the README file, there is currently no mention of modifying the config.py file for the MASK_BACKGROUND_COLOR variable either, so should I add a new section to detail how a user can optionally customize these variables?

I've also noticed several other config variables that were defined in the main app.py file instead of in the config.py file. Would you like to migrate these variables all to the config file?

Lastly, I noticed that the current flask code uses the deprecated (and now redundant) flask jsonify method. Would you like to update the code to remove the "jsonify()"s ?

@sumn2u
Copy link
Owner Author

sumn2u commented Jun 17, 2024

@DQ4443 Thanks for providing the detailed information. I was not aware of the thickness issue with large numbers. Ideally, it would be nice to have a slider in the UI to control the thickness. Based on its value, the Flask application will adjust accordingly and reflect the changes in the downloaded file.

For now, we can use the config variable value and apply it in the Flask application. As for the UI, we can create a separate task to add a slider, limiting the upper bound to 5 to mitigate the thickness issue. This slider will then be linked to the Flask application.

Also with regards to the README file, there is currently no mention of modifying the config.py file for the MASK_BACKGROUND_COLOR variable either, so should I add a new section to detail how a user can optionally customize these variables?

I have added the customization instructions in the documentation section documentation section and will include more information once it's completed.

I've also noticed several other config variables that were defined in the main app.py file instead of in the config.py file. Would you like to migrate these variables all to the config file?

It would be great if you could move them to the config file. I suggest creating an issue for this task and then assigning it to yourself if you are working on it.

Lastly, I noticed that the current flask code uses the deprecated (and now redundant) flask jsonify method. Would you like to update the code to remove the "jsonify()"s ?

Sure.

Thanks for providing the feedback. I suggest creating separate issues and assigning yourself to the ones you want to work on.

@sumn2u
Copy link
Owner Author

sumn2u commented Jun 17, 2024

The current outline width used in the UI is defined in RegionShapes. Here, you can see that based on the tools, we have various strokeWidth values. We might need to create a map based on the selected tools and use it in the server.

@DQ4443
Copy link
Contributor

DQ4443 commented Jun 18, 2024

@DQ4443 Thanks for providing the detailed information. I was not aware of the thickness issue with large numbers. Ideally, it would be nice to have a slider in the UI to control the thickness. Based on its value, the Flask application will adjust accordingly and reflect the changes in the downloaded file.
For now, we can use the config variable value and apply it in the Flask application. As for the UI, we can create a separate task to add a slider, limiting the upper bound to 5 to mitigate the thickness issue. This slider will then be linked to the Flask application.

Cool I'll just implement the config variable in the backend first and create a separate PR for the frontend.

Also with regards to the README file, there is currently no mention of modifying the config.py file for the MASK_BACKGROUND_COLOR variable either, so should I add a new section to detail how a user can optionally customize these variables?

I have added the customization instructions in the documentation section documentation section and will include more information once it's completed.

Would you like me to add a section in README file to direct users to the documentation?

I've also noticed several other config variables that were defined in the main app.py file instead of in the config.py file. Would you like to migrate these variables all to the config file?

It would be great if you could move them to the config file. I suggest creating an issue for this task and then assigning it to yourself if you are working on it.

Lastly, I noticed that the current flask code uses the deprecated (and now redundant) flask jsonify method. Would you like to update the code to remove the "jsonify()"s ?

Sure.

I'll create separate PRs for these two issues

@sumn2u
Copy link
Owner Author

sumn2u commented Jun 18, 2024

Would you like me to add a section in README file to direct users to the documentation?

That would be great.

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

No branches or pull requests

2 participants