public void ColorD_From_ColorB_White()
    {
        var color = new ColorD(new ColorB(255, 255, 255, 255));

        Assert.That(color.Red, Is.EqualTo(1.0));
        Assert.That(color.Green, Is.EqualTo(1.0));
        Assert.That(color.Blue, Is.EqualTo(1.0));
        Assert.That(color.Alpha, Is.EqualTo(1.0));
    }
    public void DolorF_Grayscale()
    {
        var color = new ColorD(0.123);

        Assert.That(color.Red, Is.EqualTo(0.123));
        Assert.That(color.Green, Is.EqualTo(0.123));
        Assert.That(color.Blue, Is.EqualTo(0.123));
        Assert.That(color.Alpha, Is.EqualTo(1.000));
    }
    public void ColorD_From_ColorF()
    {
        var color = new ColorD(new ColorF(0.123f, 0.234f, 0.345f, 0.456f));

        Assert.That(IsApproximately(color.Red, 0.123, 0.001));
        Assert.That(IsApproximately(color.Green, 0.234, 0.001));
        Assert.That(IsApproximately(color.Blue, 0.345, 0.001));
        Assert.That(IsApproximately(color.Alpha, 0.456, 0.001));
    }
    public void ColorD_From_ColorB_Black()
    {
        var color = new ColorD(new ColorB(0, 0, 0, 0));

        Assert.That(color.Red, Is.EqualTo(0.0));
        Assert.That(color.Green, Is.EqualTo(0.0));
        Assert.That(color.Blue, Is.EqualTo(0.0));
        Assert.That(color.Alpha, Is.EqualTo(0.0));
    }
    public void ColorD_From_ColorB()
    {
        var color = new ColorD(new ColorB(12, 23, 34, 45));

        Assert.That(IsApproximately(color.Red, 0.047, 0.001));
        Assert.That(IsApproximately(color.Green, 0.090, 0.001));
        Assert.That(IsApproximately(color.Blue, 0.133, 0.001));
        Assert.That(IsApproximately(color.Alpha, 0.176, 0.001));
    }
    public void ColorD_RGBA()
    {
        var color = new ColorD(0.123, 0.234, 0.345, 0.456);

        Assert.That(color.Red, Is.EqualTo(0.123));
        Assert.That(color.Green, Is.EqualTo(0.234));
        Assert.That(color.Blue, Is.EqualTo(0.345));
        Assert.That(color.Alpha, Is.EqualTo(0.456));
    }
    public void ColorD_ToColorF()
    {
        var color1 = new ColorD(0.123, 0.234, 0.345, 0.456);
        var color2 = color1.ToColorF();

        Assert.That(color2, Is.TypeOf(typeof(ColorF)));
        Assert.That(IsApproximately(color2.Red, 0.123, 0.001));
        Assert.That(IsApproximately(color2.Green, 0.234, 0.001));
        Assert.That(IsApproximately(color2.Blue, 0.345, 0.001));
        Assert.That(IsApproximately(color2.Alpha, 0.456, 0.001));
    }
    public void ColorD_ToColorB()
    {
        var color1 = new ColorD(0.123, 0.234, 0.345, 0.456);
        var color2 = color1.ToColorB();

        Assert.That(color2, Is.TypeOf(typeof(ColorB)));
        Assert.That(color2.Red, Is.EqualTo(31));
        Assert.That(color2.Green, Is.EqualTo(60));
        Assert.That(color2.Blue, Is.EqualTo(88));
        Assert.That(color2.Alpha, Is.EqualTo(116));
    }
Exemple #9
0
 public void XmlWrite(XmlWriter writer)
 {
     writer.WriteStartElement(nameof(PaintingMachineConfiguration));
     writer.WriteElementString(nameof(Flow), Flow.ToString());
     writer.WriteStartElement("PaintColors");
     ColorA.XmlWrite(writer, nameof(ColorA));
     ColorB.XmlWrite(writer, nameof(ColorB));
     ColorC.XmlWrite(writer, nameof(ColorC));
     ColorD.XmlWrite(writer, nameof(ColorD));
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
Exemple #10
0
 public void XmlRead(XmlReader reader)
 {
     reader.ReadStartElement(nameof(PaintingMachineConfiguration));
     Flow = reader.ReadElementContentAsDouble(nameof(Flow), "");
     reader.ReadStartElement("PaintColors");
     ColorA.XmlRead(reader, nameof(ColorA));
     ColorB.XmlRead(reader, nameof(ColorB));
     ColorC.XmlRead(reader, nameof(ColorC));
     ColorD.XmlRead(reader, nameof(ColorD));
     reader.ReadEndElement();
     reader.ReadEndElement();
 }