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

Public Member Functions

void SelectColor (HSVColor hsv)
 
void OnPointerDown (PointerEventData eventData)
 
void OnDrag (PointerEventData eventData)
 
void OnInitializePotentialDrag (PointerEventData ped)
 
void UpdateMarkerPosition (HSVColor hsv)
 
void ShowEnlargedPixels (Color[] colors)
 
void ShowDropperMarker (bool value)
 

Properties

Vector2 MarkerPosition [get]
 

Events

Action< Vector2 > ColorPicked
 

Private Member Functions

void Awake ()
 
void Init ()
 
Vector2 GetNormalisedPointerPosition (Vector2 position)
 
Vector2 GetClampedLocalPosition (Vector2 position)
 
void GeneratePaletteTexture (HSVColor hsv)
 
void SetMarkerPosition (Vector2 position)
 

Private Attributes

HSVColor current
 
Color[] colorArray
 
Texture2D texture
 
RawImage paletteImage
 
RectTransform marker
 
RectTransform dropperSelectionMarker
 
bool initiated
 

Detailed Description

Definition at line 9 of file ColorPalette.cs.

Member Function Documentation

◆ Awake()

void Empyrean.ColorPicker.ColorPalette.Awake ( )
inlineprivate

Definition at line 34 of file ColorPalette.cs.

35 {
36 Init();
37 }

References Empyrean.ColorPicker.ColorPalette.Init().

◆ GeneratePaletteTexture()

void Empyrean.ColorPicker.ColorPalette.GeneratePaletteTexture ( HSVColor  hsv)
inlineprivate

Definition at line 90 of file ColorPalette.cs.

91 {
92 current = hsv;
93 int width = texture.width;
94 for (int i = 0; i < width; i++)
95 {
96 for (int num = width - 1; num > 0; num--)
97 {
98 colorArray[i * width - 1 + num] = Colorist.HSVtoRGB(current.h, (float)num / (float)width, (float)i / (float)width);
99 }
100 }
101 texture.SetPixels(colorArray);
102 texture.Apply();
103 paletteImage.texture = texture;
104 }
static Color HSVtoRGB(HSVColor hsv)
Definition: Colorist.cs:107
float h
Definition: HSVColor.cs:3

References Empyrean.ColorPicker.ColorPalette.colorArray, Empyrean.ColorPicker.ColorPalette.current, HSVColor.h, Empyrean.Utils.Colorist.HSVtoRGB(), and Empyrean.ColorPicker.ColorPalette.texture.

Referenced by Empyrean.ColorPicker.ColorPalette.SelectColor().

◆ GetClampedLocalPosition()

Vector2 Empyrean.ColorPicker.ColorPalette.GetClampedLocalPosition ( Vector2  position)
inlineprivate

Definition at line 82 of file ColorPalette.cs.

83 {
84 Vector3 vector = paletteImage.gameObject.transform.InverseTransformPoint(position);
85 vector.x = Mathf.Clamp(vector.x, 0f, paletteImage.rectTransform.rect.width);
86 vector.y = Mathf.Clamp(vector.y, 0f, paletteImage.rectTransform.rect.height);
87 return vector;
88 }

References Empyrean.ColorPicker.ColorPalette.paletteImage.

Referenced by Empyrean.ColorPicker.ColorPalette.GetNormalisedPointerPosition().

◆ GetNormalisedPointerPosition()

Vector2 Empyrean.ColorPicker.ColorPalette.GetNormalisedPointerPosition ( Vector2  position)
inlineprivate

Definition at line 71 of file ColorPalette.cs.

72 {
73 Vector2 clampedLocalPosition = GetClampedLocalPosition(position);
74 return new Vector2(clampedLocalPosition.x / paletteImage.rectTransform.rect.width, clampedLocalPosition.y / paletteImage.rectTransform.rect.height);
75 }
Vector2 GetClampedLocalPosition(Vector2 position)
Definition: ColorPalette.cs:82

References Empyrean.ColorPicker.ColorPalette.GetClampedLocalPosition(), and Empyrean.ColorPicker.ColorPalette.paletteImage.

Referenced by Empyrean.ColorPicker.ColorPalette.OnDrag().

◆ Init()

void Empyrean.ColorPicker.ColorPalette.Init ( )
inlineprivate

Definition at line 39 of file ColorPalette.cs.

40 {
41 if (!initiated)
42 {
43 initiated = true;
44 int width = paletteImage.mainTexture.width;
45 int height = paletteImage.mainTexture.height;
46 texture = new Texture2D(width, height, TextureFormat.RGB24, mipChain: false);
47 colorArray = new Color[width * height];
48 }
49 }

References Color, Empyrean.ColorPicker.ColorPalette.colorArray, Empyrean.ColorPicker.ColorPalette.initiated, Empyrean.ColorPicker.ColorPalette.paletteImage, and Empyrean.ColorPicker.ColorPalette.texture.

Referenced by Empyrean.ColorPicker.ColorPalette.Awake(), and Empyrean.ColorPicker.ColorPalette.SelectColor().

◆ OnDrag()

void Empyrean.ColorPicker.ColorPalette.OnDrag ( PointerEventData  eventData)
inline

◆ OnInitializePotentialDrag()

void Empyrean.ColorPicker.ColorPalette.OnInitializePotentialDrag ( PointerEventData  ped)
inline

Definition at line 77 of file ColorPalette.cs.

78 {
79 ped.useDragThreshold = false;
80 }

◆ OnPointerDown()

void Empyrean.ColorPicker.ColorPalette.OnPointerDown ( PointerEventData  eventData)
inline

Definition at line 61 of file ColorPalette.cs.

62 {
63 OnDrag(eventData);
64 }
void OnDrag(PointerEventData eventData)
Definition: ColorPalette.cs:66

References Empyrean.ColorPicker.ColorPalette.OnDrag().

◆ SelectColor()

◆ SetMarkerPosition()

void Empyrean.ColorPicker.ColorPalette.SetMarkerPosition ( Vector2  position)
inlineprivate

Definition at line 111 of file ColorPalette.cs.

112 {
113 marker.anchorMin = position;
114 marker.anchorMax = position;
115 }

Referenced by Empyrean.ColorPicker.ColorPalette.UpdateMarkerPosition().

◆ ShowDropperMarker()

void Empyrean.ColorPicker.ColorPalette.ShowDropperMarker ( bool  value)
inline

Definition at line 134 of file ColorPalette.cs.

135 {
136 marker.gameObject.SetActive(!value);
137 dropperSelectionMarker.gameObject.SetActive(value);
138 }

References Empyrean.ColorPicker.ColorPalette.dropperSelectionMarker, and Empyrean.ColorPicker.ColorPalette.marker.

Referenced by Empyrean.ColorPicker.Dropper.PickColors(), and Empyrean.ColorPicker.Dropper.Stop().

◆ ShowEnlargedPixels()

void Empyrean.ColorPicker.ColorPalette.ShowEnlargedPixels ( Color[]  colors)
inline

Definition at line 117 of file ColorPalette.cs.

118 {
119 Color[] array = new Color[texture.width * texture.height];
120 for (int i = 0; i < texture.width; i++)
121 {
122 for (int j = 0; j < texture.width; j++)
123 {
124 int num = i * texture.width + j;
125 int num2 = i / 32 * 16 + j / 32;
126 array[num] = colors[num2];
127 }
128 }
129 texture.SetPixels(array);
130 texture.Apply();
131 paletteImage.texture = texture;
132 }

References Color, and Empyrean.ColorPicker.ColorPalette.texture.

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

◆ UpdateMarkerPosition()

void Empyrean.ColorPicker.ColorPalette.UpdateMarkerPosition ( HSVColor  hsv)
inline

Definition at line 106 of file ColorPalette.cs.

107 {
108 SetMarkerPosition(new Vector2(hsv.s, hsv.v));
109 }
void SetMarkerPosition(Vector2 position)
float s
Definition: HSVColor.cs:5
float v
Definition: HSVColor.cs:7

References HSVColor.s, Empyrean.ColorPicker.ColorPalette.SetMarkerPosition(), and HSVColor.v.

Referenced by Empyrean.ColorPicker.ColorPalette.SelectColor().

Member Data Documentation

◆ colorArray

Color [] Empyrean.ColorPicker.ColorPalette.colorArray
private

◆ current

HSVColor Empyrean.ColorPicker.ColorPalette.current
private

◆ dropperSelectionMarker

RectTransform Empyrean.ColorPicker.ColorPalette.dropperSelectionMarker
private

Definition at line 24 of file ColorPalette.cs.

Referenced by Empyrean.ColorPicker.ColorPalette.ShowDropperMarker().

◆ initiated

bool Empyrean.ColorPicker.ColorPalette.initiated
private

Definition at line 26 of file ColorPalette.cs.

Referenced by Empyrean.ColorPicker.ColorPalette.Init().

◆ marker

RectTransform Empyrean.ColorPicker.ColorPalette.marker
private

Definition at line 21 of file ColorPalette.cs.

Referenced by Empyrean.ColorPicker.ColorPalette.ShowDropperMarker().

◆ paletteImage

◆ texture

Texture2D Empyrean.ColorPicker.ColorPalette.texture
private

Property Documentation

◆ MarkerPosition

Vector2 Empyrean.ColorPicker.ColorPalette.MarkerPosition
get

Definition at line 28 of file ColorPalette.cs.

Referenced by Empyrean.ColorPicker.ColorPicker.UpdateColor().

Event Documentation

◆ ColorPicked

Action<Vector2> Empyrean.ColorPicker.ColorPalette.ColorPicked
Initial value:
= delegate
{
}

Definition at line 30 of file ColorPalette.cs.

Referenced by Empyrean.ColorPicker.ColorPalette.OnDrag().


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