< Summary

Information
Class: JeremyAnsel.Media.WavefrontObj.ObjMaterialColor
Assembly: JeremyAnsel.Media.WavefrontObj
File(s): C:\projects\jeremyansel-media-wavefrontobj\JeremyAnsel.Media.WavefrontObj\JeremyAnsel.Media.WavefrontObj\ObjMaterialColor.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 66
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
get_IsSpectral()100%11100%
get_IsRGB()100%22100%
get_IsXYZ()100%22100%
ToDebuggerDisplayString()100%44100%

File(s)

C:\projects\jeremyansel-media-wavefrontobj\JeremyAnsel.Media.WavefrontObj\JeremyAnsel.Media.WavefrontObj\ObjMaterialColor.cs

#LineLine coverage
 1// <copyright file="ObjMaterialColor.cs" company="Jérémy Ansel">
 2// Copyright (c) 2017, 2019 Jérémy Ansel
 3// </copyright>
 4// <license>
 5// Licensed under the MIT license. See LICENSE.txt
 6// </license>
 7
 8namespace JeremyAnsel.Media.WavefrontObj;
 9
 10[System.Diagnostics.DebuggerDisplay("{ToDebuggerDisplayString(),nq}")]
 11public class ObjMaterialColor
 12{
 313    public ObjMaterialColor()
 14    {
 315        this.SpectralFactor = 1.0f;
 316    }
 17
 18    public ObjMaterialColor(float x, float y, float z)
 319        : this()
 20    {
 321        this.Color = new ObjVector3(x, y, z);
 322    }
 23
 24    public ObjMaterialColor(string? spectralFileName)
 325        : this()
 26    {
 327        this.SpectralFileName = spectralFileName;
 328    }
 29
 30    public ObjMaterialColor(string? spectralFileName, float factor)
 331        : this()
 32    {
 333        this.SpectralFileName = spectralFileName;
 334        this.SpectralFactor = factor;
 335    }
 36
 37    public ObjVector3 Color { get; set; }
 38
 39    // ReSharper disable once InconsistentNaming
 40    public bool UseXYZColorSpace { get; set; }
 41
 42    public string? SpectralFileName { get; set; }
 43
 44    public float SpectralFactor { get; set; }
 45
 46    public bool IsSpectral
 47    {
 48        get
 49        {
 350            return !string.IsNullOrWhiteSpace(this.SpectralFileName);
 51        }
 52    }
 53
 54    // ReSharper disable once InconsistentNaming
 355    public bool IsRGB => !IsSpectral && !UseXYZColorSpace;
 56
 57    // ReSharper disable once InconsistentNaming
 358    public bool IsXYZ => !IsSpectral && UseXYZColorSpace;
 59
 60    private string ToDebuggerDisplayString()
 61    {
 362        if (IsSpectral) return $"Spectral:{SpectralFileName} Factor:{SpectralFactor}";
 363        if (UseXYZColorSpace) return $"X:{Color.X} Y:{Color.Y} Z:{Color.Z}";
 364        return $"R:{Color.X} G:{Color.Y} B:{Color.Z}";
 65    }
 66}