Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
GradientEffect Class Reference
Inheritance diagram for GradientEffect:

Public Member Functions

override void ModifyMesh (VertexHelper vh)
 
void ModifyVertices (List< UIVertex > vertexList)
 

Public Attributes

GradientMode gradientMode
 
GradientDir gradientDir
 
bool overwriteAllColor
 
Color vertex1 = Color.white
 
Color vertex2 = Color.black
 

Properties

Graphic targetGraphic [get]
 

Private Member Functions

bool CompareCarefully (Color col1, Color col2)
 

Private Attributes

Graphic _targetGraphic
 

Detailed Description

Definition at line 6 of file GradientEffect.cs.

Member Function Documentation

◆ CompareCarefully()

bool GradientEffect.CompareCarefully ( Color  col1,
Color  col2 
)
inlineprivate

Definition at line 109 of file GradientEffect.cs.

110 {
111 if (Mathf.Abs(col1.r - col2.r) < 0.003f && Mathf.Abs(col1.g - col2.g) < 0.003f && Mathf.Abs(col1.b - col2.b) < 0.003f && Mathf.Abs(col1.a - col2.a) < 0.003f)
112 {
113 return true;
114 }
115 return false;
116 }

Referenced by ModifyVertices().

◆ ModifyMesh()

override void GradientEffect.ModifyMesh ( VertexHelper  vh)
inline

Definition at line 32 of file GradientEffect.cs.

33 {
34 if (IsActive())
35 {
36 List<UIVertex> list = new List<UIVertex>();
37 vh.GetUIVertexStream(list);
38 ModifyVertices(list);
39 vh.Clear();
40 vh.AddUIVertexTriangleStream(list);
41 }
42 }
void ModifyVertices(List< UIVertex > vertexList)

References ModifyVertices().

◆ ModifyVertices()

void GradientEffect.ModifyVertices ( List< UIVertex >  vertexList)
inline

Definition at line 44 of file GradientEffect.cs.

45 {
46 if (!IsActive() || vertexList.Count == 0)
47 {
48 return;
49 }
50 int count = vertexList.Count;
51 UIVertex uIVertex = vertexList[0];
52 if (gradientMode == GradientMode.Global)
53 {
54 if (gradientDir == GradientDir.DiagonalLeftToRight || gradientDir == GradientDir.DiagonalRightToLeft)
55 {
56 gradientDir = GradientDir.Vertical;
57 }
58 float num = ((gradientDir == GradientDir.Vertical) ? vertexList[vertexList.Count - 1].position.y : vertexList[vertexList.Count - 1].position.x);
59 float num2 = ((gradientDir == GradientDir.Vertical) ? vertexList[0].position.y : vertexList[0].position.x) - num;
60 for (int i = 0; i < count; i++)
61 {
62 uIVertex = vertexList[i];
63 if (overwriteAllColor || !(uIVertex.color != targetGraphic.color))
64 {
65 ref Color32 color = ref uIVertex.color;
66 color *= Color.Lerp(vertex2, vertex1, (((gradientDir == GradientDir.Vertical) ? uIVertex.position.y : uIVertex.position.x) - num) / num2);
67 vertexList[i] = uIVertex;
68 }
69 }
70 return;
71 }
72 for (int j = 0; j < count; j++)
73 {
74 uIVertex = vertexList[j];
75 if (overwriteAllColor || CompareCarefully(uIVertex.color, targetGraphic.color))
76 {
77 switch (gradientDir)
78 {
79 case GradientDir.Vertical:
80 {
81 ref Color32 color4 = ref uIVertex.color;
82 color4 *= ((j % 4 == 0 || (j - 1) % 4 == 0) ? vertex1 : vertex2);
83 break;
84 }
85 case GradientDir.Horizontal:
86 {
87 ref Color32 color5 = ref uIVertex.color;
88 color5 *= ((j % 4 == 0 || (j - 3) % 4 == 0) ? vertex1 : vertex2);
89 break;
90 }
91 case GradientDir.DiagonalLeftToRight:
92 {
93 ref Color32 color3 = ref uIVertex.color;
94 color3 *= ((j % 4 == 0) ? vertex1 : (((j - 2) % 4 == 0) ? vertex2 : Color.Lerp(vertex2, vertex1, 0.5f)));
95 break;
96 }
97 case GradientDir.DiagonalRightToLeft:
98 {
99 ref Color32 color2 = ref uIVertex.color;
100 color2 *= (((j - 1) % 4 == 0) ? vertex1 : (((j - 3) % 4 == 0) ? vertex2 : Color.Lerp(vertex2, vertex1, 0.5f)));
101 break;
102 }
103 }
104 vertexList[j] = uIVertex;
105 }
106 }
107 }
GradientDir
Definition: GradientDir.cs:2
GradientMode
Definition: GradientMode.cs:2
GradientMode gradientMode
GradientDir gradientDir
bool CompareCarefully(Color col1, Color col2)
Graphic targetGraphic

References Color, CompareCarefully(), gradientDir, gradientMode, overwriteAllColor, targetGraphic, vertex1, and vertex2.

Referenced by ModifyMesh().

Member Data Documentation

◆ _targetGraphic

Graphic GradientEffect._targetGraphic
private

Definition at line 18 of file GradientEffect.cs.

◆ gradientDir

GradientDir GradientEffect.gradientDir

Definition at line 10 of file GradientEffect.cs.

Referenced by ModifyVertices().

◆ gradientMode

GradientMode GradientEffect.gradientMode

Definition at line 8 of file GradientEffect.cs.

Referenced by ModifyVertices().

◆ overwriteAllColor

bool GradientEffect.overwriteAllColor

Definition at line 12 of file GradientEffect.cs.

Referenced by ModifyVertices().

◆ vertex1

Color GradientEffect.vertex1 = Color.white

Definition at line 14 of file GradientEffect.cs.

Referenced by ModifyVertices().

◆ vertex2

Color GradientEffect.vertex2 = Color.black

Definition at line 16 of file GradientEffect.cs.

Referenced by ModifyVertices().

Property Documentation

◆ targetGraphic

Graphic GradientEffect.targetGraphic
getprivate

Definition at line 20 of file GradientEffect.cs.

21 {
22 get
23 {
24 if (_targetGraphic == null)
25 {
26 _targetGraphic = GetComponent<Graphic>();
27 }
28 return _targetGraphic;
29 }
30 }
Graphic _targetGraphic

Referenced by ModifyVertices().


The documentation for this class was generated from the following file: