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

feat: enable convertBitmapToLEDHex to trim or keep empty columns #1140

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

ZauberNerd
Copy link
Contributor

@ZauberNerd ZauberNerd commented Jan 4, 2025

This commit renames the previously unused isDrawn parameter to trim
and uses it to decide whether empty columns should be removed or not.

Summary by Sourcery

New Features:

  • Added a trim parameter to convertBitmapToLEDHex to control whether empty columns are removed during conversion.

This commit renames the previously unused `isDrawn` parameter to `trim`
and uses it to decide whether empty columns should be removed or not.
Copy link
Contributor

sourcery-ai bot commented Jan 4, 2025

Reviewer's Guide by Sourcery

This pull request renames the isDrawn parameter of the convertBitmapToLEDHex function to trim and uses it to determine whether or not to remove empty columns from the image before converting it to the LED hex format. The convertBitmapToLEDHex function now trims empty columns by default. The change also updates the call sites to pass true to the trim parameter.

Sequence diagram for bitmap to LED hex conversion with trimming

sequenceDiagram
    participant Client
    participant Converters

    Client->>Converters: convertBitmapToLEDHex(image, trim=true)
    Note over Converters: Process image from left to right
    Note over Converters: If trim=true, remove empty columns
    Note over Converters: Process image from right to left
    Note over Converters: If trim=true, remove empty columns
    Converters-->>Client: Return LED hex format strings
Loading

Class diagram showing Converters class changes

classDiagram
    class Converters {
        +convertBitmapToLEDHex(List~List~int~~ image, bool trim) List~String~
        note for Converters "Parameter renamed from isDrawn to trim"
        note for Converters "trim=true removes empty columns"
    }
Loading

State diagram for bitmap processing with trim option

stateDiagram-v2
    [*] --> CheckColumn
    CheckColumn --> SumPixels: For each column
    SumPixels --> CheckTrim: Sum = 0
    CheckTrim --> MarkForRemoval: trim = true
    CheckTrim --> KeepColumn: trim = false
    SumPixels --> KeepColumn: Sum > 0
    MarkForRemoval --> NextColumn
    KeepColumn --> NextColumn
    NextColumn --> CheckColumn: More columns
    NextColumn --> [*]: No more columns
Loading

File-Level Changes

Change Details Files
Renamed the isDrawn parameter to trim and updated its usage in the convertBitmapToLEDHex function.
  • Renamed the isDrawn parameter to trim.
  • Added logic to remove empty columns based on the value of the trim parameter.
  • Updated the logic for marking pixels in empty columns with -1 to be conditional on the trim parameter.
lib/bademagic_module/utils/converters.dart
Updated the call sites of the convertBitmapToLEDHex function to pass true for the trim parameter.
  • Changed the value passed to the convertBitmapToLEDHex function's second argument to true.
lib/bademagic_module/utils/image_utils.dart
lib/view/draw_badge_screen.dart
test/converters_test.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ZauberNerd ZauberNerd changed the title Trimfeat: enable convertBitmapToLEDHex to trim or keep empty columns feat: enable convertBitmapToLEDHex to trim or keep empty columns Jan 4, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ZauberNerd - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please add a test case that verifies the behavior when trim=false to ensure both code paths are covered
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@adityastic adityastic merged commit 0f5b982 into fossasia:flutter_app Jan 5, 2025
7 checks passed
@ZauberNerd ZauberNerd deleted the trim branch January 5, 2025 11:34
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.

2 participants