コード例 #1
0
ファイル: ColorTests.HSL.cs プロジェクト: punker76/spectrum
            public void ToRGBWithBlackReturnsCorrectValues()
            {
                var accent = new Color.HSL(0, 0, 0);
                var rgb    = accent.ToRGB();

                Assert.AreEqual(new Color.RGB(0, 0, 0), rgb);
            }
コード例 #2
0
ファイル: ColorTests.HSL.cs プロジェクト: punker76/spectrum
            public void ToRGBWithWhiteReturnsCorrectValues()
            {
                var accent = new Color.HSL(0, 0, 1);
                var rgb    = accent.ToRGB();

                Assert.AreEqual(new Color.RGB(255, 255, 255), rgb);
            }
コード例 #3
0
ファイル: ColorTests.HSL.cs プロジェクト: punker76/spectrum
            public void ToRGBWithAccentReturnsCorrectValues()
            {
                var accent = new Color.HSL(36.6, 0.928, 0.488);
                var rgb    = accent.ToRGB();

                Assert.AreEqual(new Color.RGB(240, 150, 9), rgb);
            }
コード例 #4
0
        private void UpdateColor()
        {
            var hsl = new Color.HSL(currentHue, currentSaturation, currentLuminosity);
            var rgb = hsl.ToRGB();

            InputPanel.Background = new SolidColorBrush(rgb.ToSystemColor(255));

            Description.Text       = rgb.ToHexString();
            Description.Foreground = new SolidColorBrush(hsl.L < 0.5d ? Windows.UI.Colors.White : Windows.UI.Colors.Black);
        }
コード例 #5
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var random = new Random();

            currentHue        = random.Next(0, 360);
            currentLuminosity = random.NextDouble();

            UpdateColor();

            Observable.FromEventPattern <PointerRoutedEventArgs>(InputPanel, "PointerPressed")
            .Subscribe(ev => Description.Visibility = Visibility.Collapsed);

            Observable.FromEventPattern <PointerRoutedEventArgs>(InputPanel, "PointerReleased")
            .Subscribe(ev => Description.Visibility = Visibility.Visible);

            Observable.FromEventPattern <PointerRoutedEventArgs>(InputPanel, "PointerMoved")
            .Where(ev => !ev.EventArgs.Handled)
            .Select(ev => ev.EventArgs.GetCurrentPoint(InputPanel))
            .Select(p => new
            {
                Width  = p.Position.X / InputPanel.ActualWidth,
                Height = p.Position.Y / InputPanel.ActualHeight
            })
            .Subscribe(p =>
            {
                currentHue        = p.Width * 360.0d;
                currentLuminosity = p.Height;

                UpdateColor();
            });

            Observable.FromEventPattern <RangeBaseValueChangedEventArgs>(SaturationSlider, "ValueChanged")
            .Select(ev => ev.EventArgs.NewValue)
            .Subscribe(s =>
            {
                currentSaturation = s;

                UpdateColor();
            });

            Observable.FromEventPattern <PointerRoutedEventArgs>(InputPanel, "PointerReleased")
            .Where(ev => ViewModel.Colors.Count < 5)
            .Subscribe(ev =>
            {
                var hsl = new Color.HSL(currentHue, currentSaturation, currentLuminosity);
                var rgb = hsl.ToRGB();

                ViewModel.Add(rgb.ToSystemColor(255));
            });
        }
コード例 #6
0
        protected SingleColorSchemeEditorViewModelBase(IWindowManager windowManager)
            : base(windowManager)
        {
            var random = new Random();

            var hue = random.Next(0, 360);

            var hsl = new Color.HSL(hue, 0.5d, 0.5d);

            CurrentColor = new ColourViewModel {
                Color = hsl.ToRGB().ToSystemColor(255)
            };

            CurrentHue        = hsl.H;
            CurrentSaturation = hsl.S;
            CurrentLuminosity = hsl.L;
        }
コード例 #7
0
 /// <summary>
 /// Convert Spectrum.Color.HSL to VulkanCore.ColorF4
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public static ColorF4 ToVulkanCore(this Color.HSL color)
 {
     return(color.ToRGB().ToVulkanCore());
 }