Thanks to visit codestin.com
Credit goes to github.com

Skip to content

consider undeprecating Image::inverted #24

@backwardspy

Description

@backwardspy

hi! i really like this crate for how easy it makes image manipulation, and as such i would like to make a suggestion about its API.

implementing Not for inverting an image is a neat trick, and does provide a convenient shortcut, however in longer method chains i believe it hurts readability.

here is an example of a method chain that i think is harmed by the new syntax:

// old
let result = image
    .cropped(300, 300, 800, 800)
    .inverted()
    .brightened(50)
    .hue_rotated(180);

// new
let result = (!image.cropped(300, 300, 800, 800))
    .brightened(50)
    .hue_rotated(180);

in my opinion it's harder to tell at a glance what the second one does, and it also took me a couple of attempts to get the parentheses in the correct place to produce the same output. for example, this slight change (swapped ! and ( by accident) changes where the inversion happens and produces a different output than i wanted:

let result = !(image.cropped(300, 300, 800, 800))
    .brightened(50)
    .hue_rotated(180);

i don't necessarily believe you should remove the option of using !, just that it would be nice if .inverted() was not deprecated at the same time.

please let me know your thoughts, and thanks for the awesome crate!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions