public void NotifyRGBUpdated() { // Set HSV from RGB HSV.ToHSV(tempColour, out _H, out _S, out _V); _A = tempColour.a; // rebuild textures CreateColourPickerBG(); CreateHuePickerBG(); CreateAlphaPickerBG(); // set slider positions _huePosition = (1f - _H) / UnitsPerPixel; _position.x = _S / UnitsPerPixel; _position.y = (1f - _V) / UnitsPerPixel; _alphaPosition = (1f - _A) / UnitsPerPixel; // set the colour block and update hex fields CreatePreviewBG(ref _tempPreviewBG, tempColour); _hexOut = _hexIn = RGBtoHex(tempColour); }
private void CreateColourPickerBG() { float S, V; int w = _pickerSize; int h = _pickerSize; float wu = UnitsPerPixel; float hu = UnitsPerPixel; Texture2D tex = new Texture2D(w, h); // HSV colours, H in slider, S horizontal, V vertical. for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { S = x * wu; V = y * hu; tex.SetPixel(x, y, HSV.ToRGBA(H, S, V, A)); } } tex.Apply(); SwapTexture(ref _colourPickerBG, tex); }