示例#1
0
 public Double4(Double4 v)
 {
     x = v.x;
     y = v.y;
     z = v.z;
     w = v.w;
 }
        private void UpdateTextures()
        {
            if (pickerOutOfDate || sliderOutOfDate)
            {
                Double4 pickerPosFraction = pickerCoords / maxValue;
                Double4 arrangement = new Double4();
                Colour pickedColour;

                for (int y = 0; y < textureResolution; ++y)
                {
                    if (pickerOutOfDate)
                    {
                        double yFraction = ((double)y / (double)maxValue);
                        int yy = (y * textureResolution);
                        for (int x = 0; x < textureResolution; ++x)
                        {
                            double xFraction = ((double)x / (double)maxValue);
                            arrangement = GetPickerArrangement(sliderAxis, xFraction, yFraction, pickerPosFraction.z, pickerPosFraction.w);
                            pickedColour = GetWorkingSpaceColour(colourModel, workingSpace, arrangement);
                            if (Colour.IsInsideGamut(pickedColour, limitingSpace))
                                pickerPixels[yy + x] = (Color)Colour.To_RGB(pickedColour, workingSpace);
                            else
                                pickerPixels[yy + x] = Color.black;
                        }
                    }
                    if (sliderOutOfDate)
                    {
                        arrangement = GetPickerArrangement(sliderAxis, pickerPosFraction.x, pickerPosFraction.y, ((float)y) / textureResolution, pickerPosFraction.w);
                        pickedColour = GetWorkingSpaceColour(colourModel, workingSpace, arrangement);
                        if (Colour.IsInsideGamut(pickedColour, limitingSpace))
                            sliderPixels[y] = (Color)Colour.To_RGB(pickedColour, workingSpace);
                        else
                            sliderPixels[y] = Color.black;
                    }

                    for (int i = 0; i < altSliders - 1; ++i)
                    {
                        float value = ((float)y) / textureResolution;
                        arrangement = new Double4(pickerPosFraction.x, pickerPosFraction.y, pickerPosFraction.z, pickerPosFraction.w);
                        arrangement[i] = value;
                        pickedColour = GetWorkingSpaceColour(colourModel, workingSpace, arrangement);
                        if (Colour.IsInsideGamut(pickedColour, limitingSpace))
                            sliderGroupPixels[i][y] = (Color)Colour.To_RGB(pickedColour, workingSpace);
                        else
                            sliderGroupPixels[i][y] = Color.black;
                    }
                }
                if (pickerOutOfDate)
                {
                    pickerTexture.SetPixels(pickerPixels);
                    pickerTexture.Apply(false);
                }
                if (sliderOutOfDate)
                {
                    sliderTexture.SetPixels(sliderPixels);
                    sliderTexture.Apply(false);
                }
                for (int i = 0; i < altSliders - 1; ++i)
                {
                    sliderGroupTexture[i].SetPixels(sliderGroupPixels[i]);
                    sliderGroupTexture[i].Apply();
                }
            }
        }
        private Double4 GetPickerArrangement(SliderAxis currentAxis, double x, double y, double z, double w)
        {
            Double4 arrangement = new Double4();
            arrangement.w = w;
            switch (currentAxis)
            {
                case SliderAxis.X:
                    arrangement.x = z;
                    arrangement.y = x;
                    arrangement.z = y;
                    break;

                case SliderAxis.Y:
                    arrangement.x = x;
                    arrangement.y = z;
                    arrangement.z = y;
                    break;

                case SliderAxis.Z:
                    arrangement.x = x;
                    arrangement.y = y;
                    arrangement.z = z;
                    break;
            }
            return arrangement;
        }
 private Double4 GetPickerArrangement(SliderAxis currentAxis, Double4 v)
 {
     return GetPickerArrangement(currentAxis, v.x, v.y, v.z, v.w);
 }
 private static Colour GetWorkingSpaceColour(Colour.Model originalModel, Colour.RGBSpace workingSpace, Double4 arrangement)
 {
     Colour workingSpaceColour = new Colour(Double3.zero);
     if (originalModel == Colour.Model.RGB)
         workingSpaceColour = Colour.From_RGB((Double3)arrangement, workingSpace);
     else if (originalModel == Colour.Model.xyY)
         workingSpaceColour = Colour.From_xyY((Double3)arrangement);
     else if (originalModel == Colour.Model.HSL)
         workingSpaceColour = Colour.From_HSL((Double3)arrangement, workingSpace);
     else if (originalModel == Colour.Model.HSV)
         workingSpaceColour = Colour.From_HSV((Double3)arrangement, workingSpace);
     else if (originalModel == Colour.Model.XYZ)
         workingSpaceColour = new Colour((Double3)arrangement);
     else if (originalModel == Colour.Model.Lab)
         workingSpaceColour = Colour.From_Lab((Double3)arrangement);
     //else if (originalModel == Colour.Model.LCH)
     //workingSpaceColour = Colour.From_LCH((Double3)arrangement);
     return workingSpaceColour;
 }