Browse Source

remove redundent code

af/merge-core
Scott Williams 9 years ago
parent
commit
54a641ba2e
  1. 4
      src/ImageSharp.Drawing/Pens/IPen.cs
  2. 21
      src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs
  3. 27
      src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs
  4. 40
      src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs

4
src/ImageSharp.Drawing/Pens/IPen.cs

@ -16,9 +16,9 @@ namespace ImageSharp.Drawing.Pens
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Gets the stoke fill.
/// Gets the stroke fill.
/// </summary>
IBrush<TPixel> StokeFill { get; }
IBrush<TPixel> StrokeFill { get; }
}
/// <summary>

21
src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs

@ -27,8 +27,8 @@ namespace ImageSharp.Drawing.Pens
public class Pen<TPixel> : IPen<TPixel>
where TPixel : struct, IPixel<TPixel>
{
private static readonly float[] EmptyPattern = new float[0];
private readonly float[] pattern;
private static readonly ReadOnlySpan<float> EmptyPattern = new float[0];
private readonly ReadOnlySpan<float> pattern;
/// <summary>
/// Initializes a new instance of the <see cref="ImageSharp.Drawing.Pens.Pen{TPixel}"/> class.
@ -36,7 +36,7 @@ namespace ImageSharp.Drawing.Pens
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <param name="pattern">The pattern.</param>
public Pen(TPixel color, float width, float[] pattern)
public Pen(TPixel color, float width, ReadOnlySpan<float> pattern)
: this(new SolidBrush<TPixel>(color), width, pattern)
{
}
@ -47,9 +47,9 @@ namespace ImageSharp.Drawing.Pens
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <param name="pattern">The pattern.</param>
public Pen(IBrush<TPixel> brush, float width, float[] pattern)
public Pen(IBrush<TPixel> brush, float width, ReadOnlySpan<float> pattern)
{
this.StokeFill = brush;
this.StrokeFill = brush;
this.StrokeWidth = width;
this.pattern = pattern;
}
@ -74,17 +74,8 @@ namespace ImageSharp.Drawing.Pens
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ImageSharp.Drawing.Pens.Pen{TPixel}"/> class.
/// </summary>
/// <param name="pen">The pen.</param>
internal Pen(Pen<TPixel> pen)
: this(pen.StokeFill, pen.StrokeWidth, pen.pattern)
{
}
/// <inheritdoc/>
public IBrush<TPixel> StokeFill { get; }
public IBrush<TPixel> StrokeFill { get; }
/// <inheritdoc/>
public float StrokeWidth { get; }

27
src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs

@ -1,27 +0,0 @@
// <copyright file="ColoredPointInfo.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Processors
{
using ImageSharp.PixelFormats;
/// <summary>
/// Returns details about how far away from the inside of a shape and the color the pixel could be.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
public struct ColoredPointInfo<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// The color
/// </summary>
public TPixel Color;
/// <summary>
/// The distance from element
/// </summary>
public float DistanceFromElement;
}
}

40
src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs

@ -1,40 +0,0 @@
// <copyright file="PenApplicator.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Processors
{
using System;
using ImageSharp.PixelFormats;
/// <summary>
/// primitive that converts a <see cref="PointInfo"/> into a color and a distance away from the drawable part of the path.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
public abstract class PenApplicator<TPixel> : IDisposable
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Gets the required region.
/// </summary>
/// <value>
/// The required region.
/// </value>
public abstract RectangleF RequiredRegion { get; }
/// <inheritdoc/>
public abstract void Dispose();
/// <summary>
/// Gets a <see cref="ColoredPointInfo{TPixel}" /> from a point represented by a <see cref="PointInfo" />.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <param name="info">The information to extract color details about.</param>
/// <returns>
/// Returns the color details and distance from a solid bit of the line.
/// </returns>
public abstract ColoredPointInfo<TPixel> GetColor(int x, int y, PointInfo info);
}
}
Loading…
Cancel
Save