Skip to content
Snippets Groups Projects

Feature: Add a way to set the polygon length from the star-toolbar

Merged Aman Gupta requested to merge techbugaman/inkscape:feature-polygon-length into master

Had a great time adding this new feature:
Inspired by the code written by @doctormo for adding a way to set the polygon length from the star-toolbar, I updated that code to output the correct polygon length and fix the transformation issues.

Logic for pointy star:
For every vertex, compute two distances i.e outer to inner vertex distance and inner to next outer vertex distance (covering a whole spoke of the star). After the above computation, we have total perimeter with us. Let's divide this with total number of sides (i.e 2*n) so that we get our average side length.

Logic for flattened polygon:
Compute total perimeter of the polygon by finding distance between consecutive vertices. Let's divide this with total number of sides (i.e n) so that we get our average polygon length.

Just to add on: There will be some minor precision inaccuracies(very very small) in length calculation as we are doing addition and division with floating point numbers.

Here is the video featuring how the new feature will look like: After_Fix

Edited by Aman Gupta

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Martin Owens
    • Resolved by Aman Gupta

      I started on a code review but stopped when I realised that the solution you're using involves storing an attribute in the polygon object. Since this is a red flag, I'll stop the review here and we can talk more about if this is needed or if it can be re-coded a different way.

  • Martin Owens requested review from @doctormo

    requested review from @doctormo

    • Resolved by Aman Gupta

      Maybe you shouldn't worry about object properties dialog. It underwent some significant changes in the separate branch I've been working on. I think it will be easy to enhance it later to cover this new entry. All I need is functions to call to read a length and to change it, so I can reuse the logic.

  • Aman Gupta added 1 commit

    added 1 commit

    • 70419515 - Fixed transformation issues and reverted changes of dialog

    Compare with previous version

  • Aman Gupta changed title from Feature: Add a way to set the polygon length from the star-toolbar and properties dialog to Feature: Add a way to set the polygon length from the star-toolbar

    changed title from Feature: Add a way to set the polygon length from the star-toolbar and properties dialog to Feature: Add a way to set the polygon length from the star-toolbar

  • Aman Gupta changed the description

    changed the description

  • Aman Gupta resolved all threads

    resolved all threads

    • Resolved by Aman Gupta

      @doctormo please have a review. I have done the following changes:

      1. Added setSideLength() that also resolves the transformation issues.
      2. Revert back all the object properties dialog changes as @mkov is doing significant changes related to it in a separate branch.
      3. Removed the dependency on storing an attribute in polygon object as it was a red flag.
      4. Uploaded new video for reference.
      Edited by Aman Gupta
  • Martin Owens approved this merge request

    approved this merge request

  • Martin Owens resolved all threads

    resolved all threads

    • Resolved by Aman Gupta

      I think label "Length" is going to be ambiguous. Maybe "Side" for a polygon would be better? Not sure what to use for a star.

      Is there a reason why this new length value is remembered in preferences?

  • Aman Gupta added 1 commit

    added 1 commit

    Compare with previous version

  • Aman Gupta resolved all threads

    resolved all threads

  • merged

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading