Skip to content

Commit

Permalink
Add To-methods for size padding;
Browse files Browse the repository at this point in the history
  • Loading branch information
onepiecefreak3 committed Jan 7, 2025
1 parent c2eef18 commit df590b5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
namespace Kanvas.Contract.Configuration
using SixLabors.ImageSharp;

namespace Kanvas.Contract.Configuration
{
public delegate void CreatePaddedSizeDelegate(ISizePaddingConfigurationBuilder builder);

public interface ISizePaddingConfigurationBuilder
{
ISizePaddingDimensionConfigurationBuilder Width { get; }
ISizePaddingDimensionConfigurationBuilder Height { get; }


IImageConfigurationBuilder To(Size size);
IImageConfigurationBuilder To(CreatePaddedSizeDelegate sizeDelegate);

IImageConfigurationBuilder ToPowerOfTwo(int steps = 1);

IImageConfigurationBuilder ToMultiple(int multiple);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Kanvas/Configuration/ImageConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ public class ImageConfigurationBuilder : IIndexedImageConfigurationBuilder

private readonly EncodingConfigurationBuilder _encodingConfigurationBuilder;
private readonly PaletteEncodingConfigurationBuilder _paletteEncodingConfigurationBuilder;
private readonly ColorShaderConfigurationBuilder _colorShaderConfigurationBuilder;
private readonly SizePaddingConfigurationBuilder _sizePaddingConfigurationBuilder;
private readonly PixelRemappingConfigurationBuilder _pixelRemappingConfigurationBuilder;
private readonly ColorShaderConfigurationBuilder _colorShaderConfigurationBuilder;
private QuantizationConfigurationBuilder? _quantizationConfigurationBuilder;

public IEncodingConfigurationBuilder Transcode => _encodingConfigurationBuilder;

public IPaletteEncodingConfigurationBuilder TranscodePalette => _paletteEncodingConfigurationBuilder;

public IColorShaderConfigurationBuilder ColorShader => _colorShaderConfigurationBuilder;

public ISizePaddingConfigurationBuilder PadSize => _sizePaddingConfigurationBuilder;

public IRemapPixelsConfigurationBuilder RemapPixels => _pixelRemappingConfigurationBuilder;

public IColorShaderConfigurationBuilder ColorShader => _colorShaderConfigurationBuilder;

public ImageConfigurationBuilder() : this(new ImageTranscoderOptions())
{
}
Expand Down
15 changes: 15 additions & 0 deletions src/lib/Kanvas/Configuration/SizePaddingConfigurationBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Kanvas.Contract.Configuration;
using Kanvas.DataClasses.Configuration;
using SixLabors.ImageSharp;

namespace Kanvas.Configuration
{
Expand All @@ -19,6 +20,20 @@ public SizePaddingConfigurationBuilder(IImageConfigurationBuilder parent, SizePa
_heightBuilder = new SizePaddingDimensionConfigurationBuilder(this, heightDelegate => options.HeightDelegate = heightDelegate);
}

public IImageConfigurationBuilder To(Size size)
{
_widthBuilder.To(size.Width);
_heightBuilder.To(size.Height);

return _parent;
}

public IImageConfigurationBuilder To(CreatePaddedSizeDelegate sizeDelegate)
{
sizeDelegate(this);
return _parent;
}

public IImageConfigurationBuilder ToPowerOfTwo(int steps = 1)
{
_widthBuilder.ToPowerOfTwo(steps);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Kanvas/DataClasses/ImageTranscoderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ internal class ImageTranscoderOptions
{
public ImageConfigurationOptions ImageOptions { get; } = new();
public EncodingConfigurationOptions EncodingOptions { get; } = new();
public ColorShaderConfigurationOptions ColorShaderOptions { get; } = new();
public SizePaddingConfigurationOptions SizePaddingOptions { get; } = new();
public PixelRemappingConfigurationOptions PixelRemappingOptions { get; } = new();
public ColorShaderConfigurationOptions ColorShaderOptions { get; } = new();
public QuantizationConfigurationOptions? QuantizationOptions { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/lib/Kanvas/Kanvas.Debug.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Kanvas</id>
<version>2.1.1</version>
<version>2.1.2</version>
<description>A library containing image transcodings and quantizations usable in the Kuriimu2 eco-system.</description>

<authors>onepiecefreak;IcySon55</authors>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Kanvas/Kanvas.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Kanvas</id>
<version>2.1.1</version>
<version>2.1.2</version>
<description>A library containing image transcodings and quantizations usable in the Kuriimu2 eco-system.</description>

<authors>onepiecefreak;IcySon55</authors>
Expand Down

0 comments on commit df590b5

Please sign in to comment.