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

Remove Region and add new Clip Extension #150

Merged
merged 18 commits into from
Jul 30, 2021
Merged

Conversation

JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #105

  • Removes all references to Region and inheriting types.
  • Adds new Clip(IImageProcessingContext, IPath, Action<IImageProcessingContext>) extension with functionality copied from samples

@JimBobSquarePants JimBobSquarePants added this to the 1.0.0-rc.1 milestone Jul 10, 2021
@codecov
Copy link

codecov bot commented Jul 10, 2021

Codecov Report

Merging #150 (9a6a0b1) into master (1bf8714) will increase coverage by 0.00%.
The diff coverage is 98.43%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #150   +/-   ##
=======================================
  Coverage   69.86%   69.87%           
=======================================
  Files          90       88    -2     
  Lines        5141     5135    -6     
  Branches     1049     1048    -1     
=======================================
- Hits         3592     3588    -4     
+ Misses       1338     1337    -1     
+ Partials      211      210    -1     
Flag Coverage Δ
unittests 69.87% <98.43%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/ImageSharp.Drawing/Processing/ImageBrush.cs 87.75% <93.10%> (+0.25%) ⬆️
...p.Drawing/Processing/Extensions/ClearExtensions.cs 100.00% <100.00%> (ø)
...awing/Processing/Extensions/ClearPathExtensions.cs 100.00% <100.00%> (ø)
.../Processing/Extensions/ClearRectangleExtensions.cs 100.00% <100.00%> (ø)
...rawing/Processing/Extensions/ClipPathExtensions.cs 100.00% <100.00%> (ø)
...rp.Drawing/Processing/Extensions/FillExtensions.cs 100.00% <100.00%> (ø)
...Processing/Extensions/FillPathBuilderExtensions.cs 100.00% <100.00%> (ø)
...rawing/Processing/Extensions/FillPathExtensions.cs 100.00% <100.00%> (ø)
...Processing/Processors/Drawing/ClipPathProcessor.cs 100.00% <100.00%> (ø)
...ng/Processors/Drawing/ClipPathProcessor{TPixel}.cs 100.00% <100.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bf8714...9a6a0b1. Read the comment docs.

@antonfirsov antonfirsov self-assigned this Jul 22, 2021
enable image brush to be only draw a portion of the source image
Copy link
Member

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

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

Implementation and tests look good.

We need to clean up the terminology used in API naming and docs, because currently it feels confusing to me. The problem is that IPath can be used for many things in the Drawing library, it's name doesn't carry the purpose (which I personally dislike, but it's a common practice in drawing libraries). My recommendation is to use the term "Region" (or an equivalent unambiguously descriptive term) in parameter/property names & docs for IPath defining a region to fill, or boundary for a recursive processor.

We also need to find a better name for the new Clip method.

Update: Taking another look, I don't dislike Clip that much anymore, but I think we should still consider alternatives.

public static IImageProcessingContext Clear(
this IImageProcessingContext source,
Color color,
IPath path) =>
Copy link
Member

@antonfirsov antonfirsov Jul 24, 2021

Choose a reason for hiding this comment

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

I would consider renaming path to region everywhere.

@@ -32,9 +36,9 @@ public FillPathProcessor(DrawingOptions options, IBrush brush, IPath shape)
public IBrush Brush { get; }

/// <summary>
/// Gets the region that this processor applies to.
/// Gets the logic path that this processor applies to.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Gets the logic path that this processor applies to.
/// Gets the <see cref="Path"/> defining the region to fill.

/// </summary>
public IPath Shape { get; }
public IPath Path { get; }
Copy link
Member

Choose a reason for hiding this comment

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

I think "region" is a better name when it's about filling:

Suggested change
public IPath Path { get; }
public IPath Region { get; }

/// <summary>
/// Allows the recursive application of processing operations against an image.
/// </summary>
public class RecursiveImageProcessor : IImageProcessor
Copy link
Member

Choose a reason for hiding this comment

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

ProcessInsideRegionProcessor?

/// <param name="path">The target path to operate within.</param>
/// <param name="operation">The operation to perform on the source.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Clip(
Copy link
Member

Choose a reason for hiding this comment

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

I think Clip is a very generic overloaded and ambiguous name, doesn't help API discoverability in this case.

I wouldn'be afraid of going verbose here, for example ProcessInsideRegion would be a better name for this.

@JimBobSquarePants
Copy link
Member Author

@antonfirsov I've applied a lot of renaming and updated XML docs based on your suggestions. I found that I was straying into #94 territory though as I waded through each connected method so have stopped where I am for now.

I maintained Clip as the method name (I think people will get it) and renamed the processor ClipPathProcessor

@JimBobSquarePants
Copy link
Member Author

I'm merging this. We can do a final API review before RC1

@JimBobSquarePants JimBobSquarePants merged commit b58a245 into master Jul 30, 2021
@JimBobSquarePants JimBobSquarePants deleted the js/region-clip branch July 30, 2021 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Region and implement "ProcessInsideShape" within ImageSharp.Drawing
3 participants