Elin Decompiled Documentation EA 23.307 Stable
Loading...
Searching...
No Matches
Empyrean.ColorPicker.Dropper Class Reference
Inheritance diagram for Empyrean.ColorPicker.Dropper:

Public Member Functions

void PickColors (Action< Color > onColorPicked, Action onDropCanceled)
 
void Stop ()
 

Public Attributes

Coroutine coroutine
 
Action onDropCanceled
 

Static Public Attributes

const int BlockWidth = 16
 
const int BlockHeight = 16
 

Private Member Functions

void Awake ()
 
void OnDestroy ()
 
void Start ()
 
void Update ()
 
void UpdateRenderTextureIfNecessary ()
 
IEnumerator EnlargeAreaAroundPointer ()
 
void UpdateTexture ()
 
void UpdateColorByMousePosition ()
 
void OnBlockerClicked ()
 

Private Attributes

ColorPalette palette
 
Button blockerPrefab
 
Button blocker
 
RenderTexture renderTexture
 
Texture2D texture2D
 
Texture2D pixelBlock
 
Color color
 
Color[] black16x16 = new Color[256]
 
Action< ColoronColorPicked
 

Detailed Description

Definition at line 8 of file Dropper.cs.

Member Function Documentation

◆ Awake()

void Empyrean.ColorPicker.Dropper.Awake ( )
inlineprivate

Definition at line 38 of file Dropper.cs.

39 {
40 Camera.main.targetTexture = renderTexture;
41 renderTexture = new RenderTexture(Screen.width, Screen.height, 24);
42 texture2D = new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, mipChain: false);
43 pixelBlock = new Texture2D(16, 16, TextureFormat.ARGB32, mipChain: false);
44 for (int i = 0; i < black16x16.Length; i++)
45 {
46 black16x16[i] = Color.black;
47 }
48 }
RenderTexture renderTexture
Definition: Dropper.cs:22

References Empyrean.ColorPicker.Dropper.black16x16, Color, Empyrean.ColorPicker.Dropper.pixelBlock, Empyrean.ColorPicker.Dropper.renderTexture, and Empyrean.ColorPicker.Dropper.texture2D.

◆ EnlargeAreaAroundPointer()

IEnumerator Empyrean.ColorPicker.Dropper.EnlargeAreaAroundPointer ( )
inlineprivate

Definition at line 84 of file Dropper.cs.

85 {
86 while (true)
87 {
88 yield return new WaitForEndOfFrame();
91 int num = (int)Mathf.Clamp(Input.mousePosition.x, 0f, texture2D.width);
92 int num2 = (int)Mathf.Clamp(Input.mousePosition.y, 0f, texture2D.height);
93 Vector2 vector = new Vector2(num - 8, num2 - 8);
94 Vector2 vector2 = new Vector2(num + 8, num2 + 8);
95 Vector2 vector3 = new Vector2(Mathf.Clamp(vector.x, 0f, texture2D.width - 8), Mathf.Clamp(vector.y, 0f, texture2D.height - 8));
96 Vector2 vector4 = new Vector2(Mathf.Clamp(vector2.x, 8f, texture2D.width), Mathf.Clamp(vector2.y, 8f, texture2D.height));
97 int blockWidth = (int)vector4.x - (int)vector3.x;
98 int blockHeight = (int)vector4.y - (int)vector3.y;
99 Color[] pixels = texture2D.GetPixels((int)vector3.x, (int)vector3.y, blockWidth, blockHeight);
100 float num3 = vector3.x - vector.x;
101 float num4 = vector3.y - vector.y;
102 pixelBlock.SetPixels(0, 0, 16, 16, black16x16);
103 pixelBlock.SetPixels((int)num3, (int)num4, blockWidth, blockHeight, pixels);
105 }
106 }
void ShowEnlargedPixels(Color[] colors)

References Empyrean.ColorPicker.Dropper.black16x16, Color, Empyrean.ColorPicker.Dropper.palette, Empyrean.ColorPicker.Dropper.pixelBlock, Empyrean.ColorPicker.ColorPalette.ShowEnlargedPixels(), Empyrean.ColorPicker.Dropper.texture2D, Empyrean.ColorPicker.Dropper.UpdateColorByMousePosition(), and Empyrean.ColorPicker.Dropper.UpdateTexture().

Referenced by Empyrean.ColorPicker.Dropper.PickColors().

◆ OnBlockerClicked()

◆ OnDestroy()

void Empyrean.ColorPicker.Dropper.OnDestroy ( )
inlineprivate

Definition at line 50 of file Dropper.cs.

51 {
52 if ((bool)renderTexture)
53 {
54 UnityEngine.Object.Destroy(renderTexture);
55 }
56 if ((bool)texture2D)
57 {
58 UnityEngine.Object.Destroy(texture2D);
59 }
60 if ((bool)pixelBlock)
61 {
62 UnityEngine.Object.Destroy(pixelBlock);
63 }
64 }

References Empyrean.ColorPicker.Dropper.pixelBlock, Empyrean.ColorPicker.Dropper.renderTexture, and Empyrean.ColorPicker.Dropper.texture2D.

◆ PickColors()

void Empyrean.ColorPicker.Dropper.PickColors ( Action< Color onColorPicked,
Action  onDropCanceled 
)
inline

Definition at line 127 of file Dropper.cs.

128 {
129 this.onDropCanceled = onDropCanceled;
130 this.onColorPicked = onColorPicked;
131 palette.ShowDropperMarker(value: true);
132 blocker = UnityEngine.Object.Instantiate(blockerPrefab);
133 blocker.onClick.AddListener(OnBlockerClicked);
134 coroutine = blocker.StartCoroutine(EnlargeAreaAroundPointer());
135 }
IEnumerator EnlargeAreaAroundPointer()
Definition: Dropper.cs:84

References Empyrean.ColorPicker.Dropper.blocker, Empyrean.ColorPicker.Dropper.blockerPrefab, Empyrean.ColorPicker.Dropper.coroutine, Empyrean.ColorPicker.Dropper.EnlargeAreaAroundPointer(), Empyrean.ColorPicker.Dropper.OnBlockerClicked(), Empyrean.ColorPicker.Dropper.onColorPicked, Empyrean.ColorPicker.Dropper.onDropCanceled, Empyrean.ColorPicker.Dropper.palette, and Empyrean.ColorPicker.ColorPalette.ShowDropperMarker().

Referenced by Empyrean.ColorPicker.ColorPicker.StartDropper().

◆ Start()

void Empyrean.ColorPicker.Dropper.Start ( )
inlineprivate

Definition at line 66 of file Dropper.cs.

67 {
68 }

◆ Stop()

void Empyrean.ColorPicker.Dropper.Stop ( )
inline

◆ Update()

void Empyrean.ColorPicker.Dropper.Update ( )
inlineprivate

◆ UpdateColorByMousePosition()

void Empyrean.ColorPicker.Dropper.UpdateColorByMousePosition ( )
inlineprivate

Definition at line 114 of file Dropper.cs.

115 {
116 int num = (int)Mathf.Clamp(Input.mousePosition.x, 0f, texture2D.width);
117 int num2 = (int)Mathf.Clamp(Input.mousePosition.y, 0f, texture2D.height);
118 Vector2 vector = new Vector2(num - 8, num2 - 8);
119 Vector2 vector2 = new Vector2(num + 8, num2 + 8);
120 Vector2 vector3 = new Vector2(Mathf.Clamp(vector.x, 0f, texture2D.width - 8), Mathf.Clamp(vector.y, 0f, texture2D.height - 8));
121 Vector2 vector4 = new Vector2(Mathf.Clamp(vector2.x, 8f, texture2D.width), Mathf.Clamp(vector2.y, 8f, texture2D.height));
122 int num3 = (int)vector4.x - (int)vector3.x;
123 int num4 = (int)vector4.y - (int)vector3.y;
124 color = texture2D.GetPixel((int)vector3.x + num3 / 2, (int)vector3.y + num4 / 2);
125 }

References Empyrean.ColorPicker.Dropper.color, and Empyrean.ColorPicker.Dropper.texture2D.

Referenced by Empyrean.ColorPicker.Dropper.EnlargeAreaAroundPointer(), and Empyrean.ColorPicker.Dropper.OnBlockerClicked().

◆ UpdateRenderTextureIfNecessary()

void Empyrean.ColorPicker.Dropper.UpdateRenderTextureIfNecessary ( )
inlineprivate

Definition at line 75 of file Dropper.cs.

76 {
77 if (renderTexture.width != Screen.width || renderTexture.height != Screen.height)
78 {
79 UnityEngine.Object.Destroy(renderTexture);
80 renderTexture = new RenderTexture(Screen.width, Screen.height, 24);
81 }
82 }

References Empyrean.ColorPicker.Dropper.renderTexture.

Referenced by Empyrean.ColorPicker.Dropper.Update().

◆ UpdateTexture()

void Empyrean.ColorPicker.Dropper.UpdateTexture ( )
inlineprivate

Definition at line 108 of file Dropper.cs.

109 {
110 texture2D.ReadPixels(new Rect(0f, 0f, renderTexture.width, renderTexture.height), 0, 0);
111 texture2D.Apply();
112 }

References Empyrean.ColorPicker.Dropper.renderTexture, and Empyrean.ColorPicker.Dropper.texture2D.

Referenced by Empyrean.ColorPicker.Dropper.EnlargeAreaAroundPointer().

Member Data Documentation

◆ black16x16

Color [] Empyrean.ColorPicker.Dropper.black16x16 = new Color[256]
private

◆ blocker

Button Empyrean.ColorPicker.Dropper.blocker
private

◆ blockerPrefab

Button Empyrean.ColorPicker.Dropper.blockerPrefab
private

Definition at line 14 of file Dropper.cs.

Referenced by Empyrean.ColorPicker.Dropper.PickColors().

◆ BlockHeight

const int Empyrean.ColorPicker.Dropper.BlockHeight = 16
static

Definition at line 18 of file Dropper.cs.

◆ BlockWidth

const int Empyrean.ColorPicker.Dropper.BlockWidth = 16
static

Definition at line 16 of file Dropper.cs.

◆ color

Color Empyrean.ColorPicker.Dropper.color
private

◆ coroutine

Coroutine Empyrean.ColorPicker.Dropper.coroutine

◆ onColorPicked

Action<Color> Empyrean.ColorPicker.Dropper.onColorPicked
private

◆ onDropCanceled

Action Empyrean.ColorPicker.Dropper.onDropCanceled

◆ palette

◆ pixelBlock

Texture2D Empyrean.ColorPicker.Dropper.pixelBlock
private

◆ renderTexture

◆ texture2D


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