add color information to the operation context. create color classes for letters and paths to use

This commit is contained in:
Eliot Jones
2019-08-04 16:47:47 +01:00
parent 1d551d6de3
commit 0b9ae1db13
22 changed files with 323 additions and 25 deletions

View File

@@ -35,6 +35,20 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
switch (Operands.Count)
{
case 1:
operationContext.ColorSpaceContext.SetNonStrokingColorGray(Operands[0]);
break;
case 3:
operationContext.ColorSpaceContext.SetNonStrokingColorRgb(Operands[0], Operands[1], Operands[2]);
break;
case 4:
operationContext.ColorSpaceContext.SetNonStrokingColorCmyk(Operands[0], Operands[1], Operands[2], Operands[3]);
break;
default:
return;
}
}
/// <inheritdoc />

View File

@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Colors;
using Tokens;
using Writer;
@@ -53,6 +54,25 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
if (operationContext.ColorSpaceContext.CurrentNonStrokingColorSpace.GetFamily() != ColorSpaceFamily.Device)
{
return;
}
switch (Operands.Count)
{
case 1:
operationContext.ColorSpaceContext.SetNonStrokingColorGray(Operands[0]);
break;
case 3:
operationContext.ColorSpaceContext.SetNonStrokingColorRgb(Operands[0], Operands[1], Operands[2]);
break;
case 4:
operationContext.ColorSpaceContext.SetNonStrokingColorCmyk(Operands[0], Operands[1], Operands[2], Operands[3]);
break;
default:
return;
}
}
/// <inheritdoc />

View File

@@ -54,7 +54,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetNonStrokingColorCmyk(C, M, Y, K);
operationContext.ColorSpaceContext.SetNonStrokingColorCmyk(C, M, Y, K);
}
/// <inheritdoc />

View File

@@ -33,7 +33,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetNonStrokingColorGray(Gray);
operationContext.ColorSpaceContext.SetNonStrokingColorGray(Gray);
}
/// <inheritdoc />

View File

@@ -47,7 +47,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetNonStrokingColorRgb(R, G, B);
operationContext.ColorSpaceContext.SetNonStrokingColorRgb(R, G, B);
}
/// <inheritdoc />

View File

@@ -36,7 +36,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetNonStrokingColorspace(Name);
operationContext.ColorSpaceContext.SetNonStrokingColorspace(Name);
}
/// <inheritdoc />

View File

@@ -38,13 +38,13 @@
switch (Operands.Count)
{
case 1:
operationContext.ColorspaceContext.SetStrokingColorGray(Operands[0]);
operationContext.ColorSpaceContext.SetStrokingColorGray(Operands[0]);
break;
case 3:
operationContext.ColorspaceContext.SetStrokingColorRgb(Operands[0], Operands[1], Operands[2]);
operationContext.ColorSpaceContext.SetStrokingColorRgb(Operands[0], Operands[1], Operands[2]);
break;
case 4:
operationContext.ColorspaceContext.SetStrokingColorCmyk(Operands[0], Operands[1], Operands[2], Operands[3]);
operationContext.ColorSpaceContext.SetStrokingColorCmyk(Operands[0], Operands[1], Operands[2], Operands[3]);
break;
default:
return;

View File

@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Colors;
using Tokens;
using Writer;
@@ -40,7 +41,7 @@
}
/// <summary>
/// Create a new <see cref="SetStrokeColor"/>.
/// Create a new <see cref="SetStrokeColorAdvanced"/>.
/// </summary>
/// <param name="operands">The color operands.</param>
/// <param name="patternName">The pattern name.</param>
@@ -53,6 +54,25 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
if (operationContext.ColorSpaceContext.CurrentStrokingColorSpace.GetFamily() != ColorSpaceFamily.Device)
{
return;
}
switch (Operands.Count)
{
case 1:
operationContext.ColorSpaceContext.SetStrokingColorGray(Operands[0]);
break;
case 3:
operationContext.ColorSpaceContext.SetStrokingColorRgb(Operands[0], Operands[1], Operands[2]);
break;
case 4:
operationContext.ColorSpaceContext.SetStrokingColorCmyk(Operands[0], Operands[1], Operands[2], Operands[3]);
break;
default:
return;
}
}
/// <inheritdoc />

View File

@@ -54,7 +54,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetStrokingColorCmyk(C, M, Y, K);
operationContext.ColorSpaceContext.SetStrokingColorCmyk(C, M, Y, K);
}
/// <inheritdoc />

View File

@@ -33,7 +33,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetStrokingColorGray(Gray);
operationContext.ColorSpaceContext.SetStrokingColorGray(Gray);
}
/// <inheritdoc />

View File

@@ -47,7 +47,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetStrokingColorRgb(R, G, B);
operationContext.ColorSpaceContext.SetStrokingColorRgb(R, G, B);
}
/// <inheritdoc />

View File

@@ -36,7 +36,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ColorspaceContext.SetStrokingColorspace(Name);
operationContext.ColorSpaceContext.SetStrokingColorspace(Name);
}
/// <inheritdoc />