< Summary

Class:GDX.Jobs.ParallelFor.Color32CompareJob
Assembly:GDX
File(s):D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Jobs/ParallelFor/Color32CompareJob.cs
Covered lines:0
Uncovered lines:13
Coverable lines:13
Total lines:54
Line coverage:0% (0 of 13)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:1
Method coverage:0% (0 of 1)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Execute(...)0%30500%

File(s)

D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Jobs/ParallelFor/Color32CompareJob.cs

#LineLine coverage
 1// Copyright (c) 2020-2022 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using Unity.Burst;
 6using Unity.Collections;
 7using Unity.Jobs;
 8using UnityEngine;
 9
 10namespace GDX.Jobs.ParallelFor
 11{
 12    [BurstCompile]
 13    public struct Color32CompareJob : IJobParallelFor
 14    {
 15        /// <summary>
 16        ///     The left-hand side <see cref="Unity.Collections.NativeArray{T}" /> typed as <see cref="byte" />.
 17        /// </summary>
 18        [ReadOnly] public NativeArray<Color32> A;
 19
 20        /// <summary>
 21        ///     The right-hand side <see cref="Unity.Collections.NativeArray{T}" /> typed as <see cref="byte" />.
 22        /// </summary>
 23        [ReadOnly] public NativeArray<Color32> B;
 24
 25        /// <summary>
 26        ///     The percent difference between the two values.
 27        /// </summary>
 28        [WriteOnly] public NativeArray<float> Percentage;
 29
 30        /// <summary>
 31        /// Executable work for the provided index.
 32        /// </summary>
 33        /// <param name="index">The index of the Parallel for loop at which to perform work.</param>
 34        public void Execute(int index)
 035        {
 036            if (A[index].r == B[index].r &&
 37                A[index].g == B[index].g &&
 38                A[index].b == B[index].b &&
 39                A[index].a == B[index].a)
 040            {
 041                Percentage[index] = 1f;
 042            }
 43            else
 044            {
 045                float rDiff = 1f - Mathf.Abs(A[index].r / 255 - B[index].r / 255);
 046                float gDiff = 1f - Mathf.Abs(A[index].g / 255 - B[index].g / 255);
 047                float bDiff = 1f - Mathf.Abs(A[index].b / 255 - B[index].b / 255);
 048                float aDiff = 1f - Mathf.Abs(A[index].a / 255 - B[index].a / 255);
 49
 050                Percentage[index] = (rDiff + gDiff + bDiff + aDiff) / 4f;
 051            }
 052        }
 53    }
 54}

Methods/Properties

Execute(System.Int32)