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

fix(UI): gates upper edge drawing issue fix #4929

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Darshan808
Copy link

Description

Issue

This pull request addresses issue #4928 : Corner Triangular Edge Display Issue Of Logic Gates.

Problem

The issue arises due to the upper edges of circuit elements, particularly gates with triangular corners like OR Gate, NOR Gate, X-OR Gate, etc., being slightly distorted on the default zoom level. This distortion affects the UI negatively, causing an inconsistent appearance.

Root Cause

Upon investigating, it was found that the distortion occurs during the drawing of the gates. While drawing curves, the Math.round() function is correctly used to round off decimal numbers. However, when moving the canvas context (ctx), Math.round() is not applied to the moving coordinates. As a result, when the ctx.closePath() method is called, the presence of decimal numbers, particularly .5 in both x and y coordinates, causes the upper edge distortion.

Solution

To resolve this issue, Math.round() is applied to the values before moving the ctx. This ensures that the coordinates are always rounded to whole numbers, resulting in smooth curve creation for the gates drawing.

Impact

Implementing this solution ensures consistent and distortion-free rendering of the circuit elements' upper edges, enhancing the UI experience for users.

Changes Made

  • Applied Math.round() to coordinates before moving the canvas context to ensure whole number values.
  • Tested the changes thoroughly to ensure they resolve the issue without introducing any other problems.

Testing

Manual testing was done to validate the changes.

Screenshots

####Before
Screenshot 2024-05-13 174850
Screenshot 2024-05-13 174822
Screenshot 2024-05-13 203051

####After (in every condition)
Screenshot 2024-05-13 174906
Screenshot 2024-05-13 221921

Copy link

codeclimate bot commented May 13, 2024

Code Climate has analyzed commit 722bd70 and detected 0 issues on this pull request.

View more on Code Climate.

@tachyons tachyons requested a review from Prerna-0202 May 14, 2024 01:22
@Darshan808
Copy link
Author

@Prerna-0202 Please review my PR. Or please tell me if i am missing something.

Copy link
Member

@Prerna-0202 Prerna-0202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🚀 @Darshan808 . Thanks for this fix.

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

Successfully merging this pull request may close these issues.

None yet

2 participants