Ejemplo n.º 1
0
        protected override Node EditHsl(HslColor color, Number number)
        {
            WarnNotSupportedByLessJS("hue(color, number)");

            color.Hue += number.Value/360d;
            return color.ToRgbColor();
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var velocityThreshold2 = VelocityThreshold * VelocityThreshold;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var velocity2 = particle->Velocity.X * particle->Velocity.X +
                                particle->Velocity.Y * particle->Velocity.Y;
                var deltaColor = VelocityColor - StationaryColor;

                if (velocity2 >= velocityThreshold2)
                {
                    VelocityColor.CopyTo(out particle->Color);
                }
                else
                {
                    var t = (float)Math.Sqrt(velocity2) / VelocityThreshold;

                    particle->Color = new HslColor(
                        deltaColor.H * t + StationaryColor.H,
                        deltaColor.S * t + StationaryColor.S,
                        deltaColor.L * t + StationaryColor.L);
                }
            }
        }
Ejemplo n.º 3
0
        public static BitmapSource CreateThemedBitmapSource(BitmapSource src, Color bgColor, bool isHighContrast)
        {
            unchecked {
                if (src.Format != PixelFormats.Bgra32)
                    src = new FormatConvertedBitmap(src, PixelFormats.Bgra32, null, 0.0);
                var pixels = new byte[src.PixelWidth * src.PixelHeight * 4];
                src.CopyPixels(pixels, src.PixelWidth * 4, 0);

                var bg = HslColor.FromColor(bgColor);
                int offs = 0;
                while (offs + 4 <= pixels.Length) {
                    var hslColor = HslColor.FromColor(Color.FromRgb(pixels[offs + 2], pixels[offs + 1], pixels[offs]));
                    double hue = hslColor.Hue;
                    double saturation = hslColor.Saturation;
                    double luminosity = hslColor.Luminosity;
                    double n1 = Math.Abs(0.96470588235294119 - luminosity);
                    double n2 = Math.Max(0.0, 1.0 - saturation * 4.0) * Math.Max(0.0, 1.0 - n1 * 4.0);
                    double n3 = Math.Max(0.0, 1.0 - saturation * 4.0);
                    luminosity = TransformLuminosity(hue, saturation, luminosity, bg.Luminosity);
                    hue = hue * (1.0 - n3) + bg.Hue * n3;
                    saturation = saturation * (1.0 - n2) + bg.Saturation * n2;
                    if (isHighContrast)
                        luminosity = ((luminosity <= 0.3) ? 0.0 : ((luminosity >= 0.7) ? 1.0 : ((luminosity - 0.3) / 0.4))) * (1.0 - saturation) + luminosity * saturation;
                    var color = new HslColor(hue, saturation, luminosity, 1.0).ToColor();
                    pixels[offs + 2] = color.R;
                    pixels[offs + 1] = color.G;
                    pixels[offs] = color.B;
                    offs += 4;
                }

                BitmapSource newImage = BitmapSource.Create(src.PixelWidth, src.PixelHeight, src.DpiX, src.DpiY, PixelFormats.Bgra32, src.Palette, pixels, src.PixelWidth * 4);
                newImage.Freeze();
                return newImage;
            }
        }
Ejemplo n.º 4
0
        protected override Node EvalHsl(HslColor color)
        {
            WarnNotSupportedByLessJS("complement(color)");

            color.Hue += 0.5;
            return color.ToRgbColor();
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double hotttnesss = System.Convert.ToDouble(value);

            HslColor c = new HslColor(Colors.Red);
            c.Hue = hotttnesss*255;

            Color color = (Color) c;
            return new SolidColorBrush(Lerp(Colors.Black, color, (float)hotttnesss));
        }
Ejemplo n.º 6
0
        private static void AssertHslToRgb(double hue, double saturation, double lightness, double red, double green, double blue)
        {
            var hsl = new HslColor(hue / 360, saturation / 100, lightness / 100);
            var color = hsl.ToRgbColor();

            Assert.That(color.R, Is.EqualTo(red).Within(0.49));

            Assert.That(color.G, Is.EqualTo(green).Within(0.49));

            Assert.That(color.B, Is.EqualTo(blue).Within(0.49));
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = FinalHue - InitialHue;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Color = new HslColor(
                    delta * particle->Age + InitialHue,
                    particle->Color.S,
                    particle->Color.L);
            }
        }
        public unsafe void Update(float elapsedseconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = new HslColor(FinalColor.H - InitialColor.H,
                                   FinalColor.S - InitialColor.S,
                                   FinalColor.L - InitialColor.L);

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Color = new HslColor(
                    InitialColor.H + delta.H * particle->Age,
                    InitialColor.S + delta.S * particle->Age,
                    InitialColor.L + delta.L * particle->Age);
            }
        }
Ejemplo n.º 9
0
            public static HslColor FromRgb(byte R, byte G, byte B)
            {
                HslColor c = new HslColor();
                c.A = 1;
                double r = ByteToPct(R);
                double g = ByteToPct(G);
                double b = ByteToPct(B);
                double max = Math.Max(b, Math.Max(r, g));
                double min = Math.Min(b, Math.Min(r, g));
                if (max == min)
                {
                    c.H = 0;
                }
                else if (max == r && g >= b)
                {
                    c.H = 60 * ((g - b) / (max - min));
                }
                else if (max == r && g < b)
                {
                    c.H = 60 * ((g - b) / (max - min)) + 360;
                }
                else if (max == g)
                {
                    c.H = 60 * ((b - r) / (max - min)) + 120;
                }
                else if (max == b)
                {
                    c.H = 60 * ((r - g) / (max - min)) + 240;
                }

                c.L = .5 * (max + min);
                if (max == min)
                {
                    c.S = 0;
                }
                else if (c.L <= .5)
                {
                    c.S = (max - min) / (2 * c.L);
                }
                else if (c.L > .5)
                {
                    c.S = (max - min) / (2 - 2 * c.L);
                }
                return c;
            }
Ejemplo n.º 10
0
        public override INode Evaluate()
        {
            Guard.ExpectArguments(4, Arguments.Length, this);
            Guard.ExpectAllNodes<Number>(Arguments, this);

            var args = Arguments
              .Cast<Number>()
              .Select(n => n.Value)
              .ToArray();

            var hue = args[0] / 360d;
            var saturation = args[1] / 100d;
            var lightness = args[2] / 100d;
            var alpha = args[3];

            var hsl = new HslColor(hue, saturation, lightness, alpha);

            return hsl.ToRgbColor();
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var velocityThreshold2 = VelocityThreshold * VelocityThreshold;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var velocity2 = particle->Velocity.LengthSquared();

                float h;
                if (velocity2 >= velocityThreshold2)
                {
                    h = VelocityHue;
                }
                else
                {
                    var t = (float)Math.Sqrt(velocity2) / VelocityThreshold;
                    h = MathHelper.Lerp(StationaryHue, VelocityHue, t);
                }
                particle->Color = new HslColor(h, particle->Color.S, particle->Color.L);
            }
        }
Ejemplo n.º 12
0
 protected override Node EvalHsl(HslColor color)
 {
     return(color.GetLightness());
 }
Ejemplo n.º 13
0
 public ColorWheel_t(byte h, byte s, byte l)
 {
     HSL = new HslColor(h, s, l);
 }
Ejemplo n.º 14
0
 protected abstract Node EditHsl(HslColor color, Number number);
Ejemplo n.º 15
0
 protected override Node EvalHsl(HslColor color)
 {
     return color.GetSaturation();
 }
Ejemplo n.º 16
0
 internal static Color ToXamlColor(this HslColor hslColor)
 {
     return(hslColor.ToRgbColor().ToXamlColor());
 }
Ejemplo n.º 17
0
 internal static Cairo.Color ReduceLight(Cairo.Color color, double factor)
 {
     var c = new HslColor (color);
     c.L *= factor;
     return c;
 }
Ejemplo n.º 18
0
        protected override Node EditHsl(HslColor color, Number number)
        {
            WarnNotSupportedByLessJS("saturation(color, number)", "saturate(color, number) or its opposite desaturate(color, number),");

            return(base.EditHsl(color, number));
        }
Ejemplo n.º 19
0
 protected abstract Node EvalHsl(HslColor color);
Ejemplo n.º 20
0
        void ResultTextDataFunc(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            if (TreeIter.Zero.Equals(iter))
            {
                return;
            }
            var textRenderer = (CellRendererText)cell;
            var searchResult = (SearchResult)store.GetValue(iter, SearchResultColumn);

            if (searchResult == null || searchResult.Offset < 0)
            {
                textRenderer.Markup = "Invalid search result";
                return;
            }
            string textMarkup = markupCache.FirstOrDefault(t => t.Item1 == searchResult)?.Item2;
            bool   isSelected = treeviewSearchResults.Selection.IterIsSelected(iter);

            if (isSelected)
            {
                textMarkup = null;
            }
            if (textMarkup == null)
            {
                var doc = GetDocument(searchResult);
                if (doc == null)
                {
                    textMarkup = "Can't create document for:" + searchResult.FileName;
                    goto end;
                }
                int lineNumber, startIndex = 0, endIndex = 0;
                try {
                    lineNumber = doc.OffsetToLineNumber(searchResult.Offset);
                } catch (ArgumentOutOfRangeException) {
                    lineNumber = -1;
                    textMarkup = "Invalid search result offset";
                    goto end;
                }

                var line = doc.GetLine(lineNumber);
                if (line == null)
                {
                    textMarkup = "Invalid line number " + lineNumber + " from offset: " + searchResult.Offset;
                    goto end;
                }
                int indent   = line.GetIndentation(doc).Length;
                var lineText = doc.GetTextAt(line.Offset + indent, line.Length - indent);
                int col      = searchResult.Offset - line.Offset - indent;
                // search result contained part of the indent.
                if (col + searchResult.Length < lineText.Length)
                {
                    lineText = doc.GetTextAt(line.Offset, line.Length);
                }

                string markup;
                if (isSelected)
                {
                    markup = Ambience.EscapeText(doc.GetTextAt(line.Offset + indent, line.Length - indent));
                }
                else
                {
                    markup = doc.GetMarkup(line.Offset + indent, line.Length - indent, new MarkupOptions(MarkupFormat.Pango));
                    markup = AdjustColors(markup);
                }

                if (col >= 0)
                {
                    uint start;
                    uint end;
                    try {
                        start = (uint)TranslateIndexToUTF8(lineText, col);
                        end   = (uint)TranslateIndexToUTF8(lineText, Math.Min(lineText.Length, col + searchResult.Length));
                    } catch (Exception e) {
                        LoggingService.LogError("Exception while translating index to utf8 (column was:" + col + " search result length:" + searchResult.Length + " line text:" + lineText + ")", e);
                        return;
                    }
                    startIndex = (int)start;
                    endIndex   = (int)end;
                }

                try {
                    textMarkup = markup;

                    if (!isSelected)
                    {
                        var    searchColor = searchResult.GetBackgroundMarkerColor(highlightStyle);
                        double b1          = HslColor.Brightness(searchColor);

                        double b2    = HslColor.Brightness(AdjustColor(Style.Base(StateType.Normal), SyntaxHighlightingService.GetColor(highlightStyle, EditorThemeColors.Foreground)));
                        double delta = Math.Abs(b1 - b2);
                        if (delta < 0.1)
                        {
                            var color1 = SyntaxHighlightingService.GetColor(highlightStyle, EditorThemeColors.FindHighlight);
                            if (color1.L + 0.5 > 1.0)
                            {
                                color1.L -= 0.5;
                            }
                            else
                            {
                                color1.L += 0.5;
                            }
                            searchColor = color1;
                        }
                        if (startIndex != endIndex)
                        {
                            textMarkup = PangoHelper.ColorMarkupBackground(textMarkup, (int)startIndex, (int)endIndex, searchColor);
                        }
                    }
                    else
                    {
                        var searchColor = this.treeviewSearchResults.Style.Base(StateType.Selected);
                        searchColor = searchColor.AddLight(-0.2);
                        textMarkup  = PangoHelper.ColorMarkupBackground(textMarkup, (int)startIndex, (int)endIndex, searchColor);
                    }
                } catch (Exception e) {
                    LoggingService.LogError("Error whil setting the text renderer markup to: " + markup, e);
                }
end:
                textMarkup = textMarkup.Replace("\t", new string (' ', doc.Options.TabSize));
                if (!isSelected)
                {
                    markupCache.Add(Tuple.Create(searchResult, textMarkup));
                    if (markupCache.Count > 100)
                    {
                        markupCache.RemoveAt(0);
                    }
                }
            }
            textRenderer.Markup = textMarkup;
        }
Ejemplo n.º 21
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     return(base.EditHsl(color, -number));
 }
Ejemplo n.º 22
0
        static Cairo.Color[,,,,] CreateColorMatrix(TextEditor editor, bool isError)
        {
            string typeString = isError ? "error" : "warning";

            Cairo.Color[,,,,] colorMatrix = new Cairo.Color[2, 2, 3, 2, 2];

            Style style = editor.ColorStyle;

            if (style == null)
            {
                style = new DefaultStyle(editor.Style);
            }

            colorMatrix [0, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble." + typeString + ".light.color1").Color);
            colorMatrix [0, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble." + typeString + ".light.color2").Color);

            colorMatrix [0, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble." + typeString + ".dark.color1").Color);
            colorMatrix [0, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble." + typeString + ".dark.color2").Color);

            colorMatrix [0, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble." + typeString + ".line.top").Color);
            colorMatrix [0, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble." + typeString + ".line.bottom").Color);

            colorMatrix [1, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble.inactive." + typeString + ".light.color1").Color);
            colorMatrix [1, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble.inactive." + typeString + ".light.color2").Color);

            colorMatrix [1, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble.inactive." + typeString + ".dark.color1").Color);
            colorMatrix [1, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble.inactive." + typeString + ".dark.color2").Color);

            colorMatrix [1, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble.inactive." + typeString + ".line.top").Color);
            colorMatrix [1, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(style.GetChunkStyle("bubble.inactive." + typeString + ".line.bottom").Color);

            double factor = 1.03;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        HslColor color = colorMatrix [i, j, k, 0, 0];
                        color.L *= factor;
                        colorMatrix [i, j, k, 1, 0] = color;
                    }
                }
            }
            var selectionColor = Style.ToCairoColor(style.Selection.BackgroundColor);

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        for (int l = 0; l < 2; l++)
                        {
                            var color = colorMatrix [i, j, k, l, 0];
                            colorMatrix [i, j, k, l, 1] = new Cairo.Color((color.R + selectionColor.R * 1.5) / 2.5, (color.G + selectionColor.G * 1.5) / 2.5, (color.B + selectionColor.B * 1.5) / 2.5);
                        }
                    }
                }
            }
            return(colorMatrix);
        }
        void EnsureLayoutCreated(TextEditor editor)
        {
            if (editor.ColorStyle != null && gc == null)
            {
                bool isError = errors.Any(e => e.IsError);

                string typeString = isError ? "error" : "warning";

                gc            = new Gdk.GC(editor.GdkWindow);
                gc.RgbFgColor = editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".text").Color;

                gcSelected            = new Gdk.GC(editor.GdkWindow);
                gcSelected.RgbFgColor = editor.ColorStyle.Selection.Color;

                gcLight            = new Gdk.GC(editor.GdkWindow);
                gcLight.RgbFgColor = new Gdk.Color(255, 255, 255);


                colorMatrix[0, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".light.color1").Color);
                colorMatrix[0, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".light.color2").Color);

                colorMatrix[0, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".dark.color1").Color);
                colorMatrix[0, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".dark.color2").Color);

                colorMatrix[0, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".line.top").Color);
                colorMatrix[0, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".line.bottom").Color);

                colorMatrix[1, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".light.color1").Color);
                colorMatrix[1, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".light.color2").Color);

                colorMatrix[1, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".dark.color1").Color);
                colorMatrix[1, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".dark.color2").Color);

                colorMatrix[1, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".line.top").Color);
                colorMatrix[1, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".line.bottom").Color);

                double factor = 1.03;
                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 2; j++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            HslColor color = colorMatrix[i, j, k, 0, 0];
                            color.L *= factor;
                            colorMatrix[i, j, k, 1, 0] = color;
                        }
                    }
                }
                var selectionColor = Style.ToCairoColor(editor.ColorStyle.Selection.BackgroundColor);
                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 2; j++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            for (int l = 0; l < 2; l++)
                            {
                                var color = colorMatrix[i, j, k, l, 0];
                                colorMatrix[i, j, k, l, 1] = new Cairo.Color((color.R + selectionColor.R * 1.5) / 2.5, (color.G + selectionColor.G * 1.5) / 2.5, (color.B + selectionColor.B * 1.5) / 2.5);
                            }
                        }
                    }
                }
            }

            if (layouts != null)
            {
                return;
            }

            layouts         = new List <LayoutDescriptor> ();
            fontDescription = Pango.FontDescription.FromString(editor.Options.FontName);
            var label = new Gtk.Label("");

            fontDescription.Family = label.Style.FontDescription.Family;
            label.Destroy();
            fontDescription.Size = (int)(fontDescription.Size * 0.9f * editor.Options.Zoom);
            foreach (ErrorText errorText in errors)
            {
                Pango.Layout layout = new Pango.Layout(editor.PangoContext);
                layout.FontDescription = fontDescription;
                layout.SetText(errorText.ErrorMessage);

                KeyValuePair <int, int> textSize;
                if (!textWidthDictionary.TryGetValue(errorText.ErrorMessage, out textSize))
                {
                    int w, h;
                    layout.GetPixelSize(out w, out h);
                    textSize = new KeyValuePair <int, int> (w, h);
                    textWidthDictionary[errorText.ErrorMessage] = textSize;
                }
                layouts.Add(new LayoutDescriptor(layout, textSize.Key, textSize.Value));
            }

            if (errorCountLayout == null && errors.Count > 1)
            {
                errorCountLayout = new Pango.Layout(editor.PangoContext);
                errorCountLayout.FontDescription = fontDescription;
                errorCountLayout.SetText(errors.Count.ToString());
            }
        }
Ejemplo n.º 24
0
        public ParticlesEffect(bool IsEmitterParameters,
                               string ProfileName, IGraphicsDeviceService graphics, Vector2 Position,
                               string DefinitionsTextureRegion, int DefinitionsCapacity, float LifeSpanFromMilliseconds,
                               float BoxFillWidth, float BoxFillHeight,
                               float BoxWidth, float BoxHeight,
                               float BoxUniformWidth, float BoxUniformHeight,
                               float CircleRadius, string CircleRadiate,
                               float LineAxisX, float LineAxisY, float LineLength,
                               bool PointIsPoint,
                               float RingRadius, string RingRadiate,
                               float SprayDirectionX, float SprayDirectionY, float SpraySpread,
                               Microsoft.Xna.Framework.Color ParametersColorMin, float ParametersMassMin, float ParametersOpacityMin, int ParametersQuantityMin, float ParametersRotationMin, float ParametersScaleMin, float ParametersSpeedMin,
                               float ParametersMassMax, float ParametersOpacityMax, int ParametersQuantityMax, float ParametersRotationMax, float ParametersScaleMax, float ParametersSpeedMax,
                               string ContainerModifierSelectedName,
                               bool IsContainerModifierSelected, bool CircleContainerModifierInside, float CircleContainerModifierRadius, float CircleContainerModifierRestitutionCoefficient,
                               int RectangleContainerModifierWidth, int RectangleContainerModifierHeight, float RectangleContainerModifierRestitutionCoefficient,
                               int RectangleLoopContainerModifierWidth, int RectangleLoopContainerModifierHeight,
                               string ModifiersInterpolatorsSelectedName,
                               Microsoft.Xna.Framework.Color AgeModifierColorInterpolatorStartValue, Microsoft.Xna.Framework.Color AgeModifierColorInterpolatorEndValue,
                               float AgeModifierHueInterpolatorStartValue, float AgeModifierHueInterpolatorEndValue,
                               float AgeModifierOpacityInterpolatorStartValue, float AgeModifierOpacityInterpolatorEndValue,
                               float AgeModifierRotationInterpolatorStartValue, float AgeModifierRotationInterpolatorEndValue,
                               float AgeModifierScaleInterpolatorStartValueX, float AgeModifierScaleInterpolatorStartValueY, float AgeModifierScaleInterpolatorEndValueX, float AgeModifierScaleInterpolatorEndValueY,
                               Microsoft.Xna.Framework.Color VelocityModifierColorInterpolatorStartValue, Microsoft.Xna.Framework.Color VelocityModifierColorInterpolatorEndValue,
                               float VelocityModifierHueInterpolatorStartValue, float VelocityModifierHueInterpolatorEndValue,
                               float VelocityModifierOpacityInterpolatorStartValue, float VelocityModifierOpacityInterpolatorEndValue,
                               float VelocityModifierRotationInterpolatorStartValue, float VelocityModifierRotationInterpolatorEndValue,
                               float VelocityModifierScaleInterpolatorStartValueX, float VelocityModifierScaleInterpolatorStartValueY, float VelocityModifierScaleInterpolatorEndValueX, float VelocityModifierScaleInterpolatorEndValueY,
                               bool IsDragModifierSelected, float DragModifierDragCoefficient, float DragModifierDensity,
                               bool IsLinearGravityModifierSelected, float LinearGravityModifierDirectionX, float LinearGravityModifierDirectionY, float LinearGravityModifierStrength, int LinearGravityModifierControlSizeBuffer, float LinearGravityModifierControlDuration,
                               bool IsOpacityFastFadeModifierSelected, float OpacityFastFadeModifierControlDuration, int OpacityFastFadeModifierControlSizeBuffer,
                               bool IsRotationModifierRotationRate, float RotationModifierRotationRate,
                               bool IsVelocityColorModifierSelected, Microsoft.Xna.Framework.Color VelocityColorModifierVelocityColor, Microsoft.Xna.Framework.Color VelocityColorModifierStationaryColor,
                               bool IsVelocityModifierInterpolatorSelected, float VelocityColorModifierVelocityThreshold, float VelocityModifierVelocityThreshold, string VelocityModifiersInterpolatorsSelectedName,
                               bool IsVortexModifierSelected, float VortexModifierMass, float VortexModifierMaxSpeed, float VortexModifierPositionX, float VortexModifierPositionY,
                               Texture2D TextBoxTextureRegionDefinitions, int TextBoxCapacityDefinitions, float TextBoxLifeSpanDefinitions)
        {
            positionParticle      = Position;
            this.BoxWidth         = BoxWidth;
            this.BoxHeight        = BoxHeight;
            this.BoxFillWidth     = BoxFillWidth;
            this.BoxFillHeight    = BoxFillHeight;
            this.BoxUniformWidth  = BoxUniformWidth;
            this.BoxUniformHeight = BoxUniformHeight;
            this.CircleRadius     = CircleRadius;
            this.LineAxisX        = LineAxisX;
            this.LineAxisY        = LineAxisY;
            this.LineLength       = LineLength;
            this.RingRadius       = RingRadius;
            this.SpraySpread      = SpraySpread;
            this.SprayDirectionX  = SprayDirectionX;
            this.SprayDirectionY  = SprayDirectionY;
            this.CircleRadiate    = CircleRadiate;
            this.RingRadiate      = RingRadiate;

            if (texture != null)
            {
                texture.Dispose();
            }

            if (string.IsNullOrEmpty(DefinitionsTextureRegion))
            {
                texture = CreateTexture(graphics.GraphicsDevice, 5, 5, pixel => Color.White);
            }
            else
            {
                texture = Texture2D.FromStream(graphics.GraphicsDevice, new FileStream(DefinitionsTextureRegion, FileMode.Open, FileAccess.Read, FileShare.Read));
            }

            textureRegion = new TextureRegion2D(texture);

            if (LifeSpanFromMilliseconds == 1)
            {
                this.lifeSpan = 5;
            }
            else
            {
                this.lifeSpan = LifeSpanFromMilliseconds;
            }

            particle          = new ParticleEffect();
            particle.Position = Position;

            particle.Emitters = new List <ParticleEmitter>();

            File.WriteAllText(@"D:\GameDevelop\HomeParticlesSoftware\HomeParticlesSoftware\traceText\test.txt", String.Empty);
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\GameDevelop\HomeParticlesSoftware\HomeParticlesSoftware\traceText\test.txt", true))
            {
                file.WriteLine("ProfileUsed : " + GetProfile(ProfileName).ToString());

                file.WriteLine("ProfileName : " + ProfileName);
                file.WriteLine("Position : " + Position);
                file.WriteLine("DefinitionsTextureRegion : " + DefinitionsTextureRegion);

                file.WriteLine("DefinitionsCapacity : " + DefinitionsCapacity);
                file.WriteLine("LifeSpanFromMilliseconds : " + LifeSpanFromMilliseconds);
                file.WriteLine("BoxFillWidth : " + BoxFillWidth);
                file.WriteLine("BoxFillHeight : " + BoxFillHeight);

                file.WriteLine("BoxWidth : " + BoxWidth);
                file.WriteLine("BoxHeight : " + BoxHeight);
                file.WriteLine("BoxUniformWidth : " + BoxUniformWidth);
                file.WriteLine("BoxUniformHeight : " + BoxUniformHeight);

                file.WriteLine("CircleRadius : " + CircleRadius);
                file.WriteLine("CircleRadiate : " + CircleRadiate);
                file.WriteLine("LineAxisX : " + LineAxisX);
                file.WriteLine("LineAxisY : " + LineAxisY);

                file.WriteLine("LineLength : " + LineLength);
                file.WriteLine("PointIsPoint : " + PointIsPoint);
                file.WriteLine("RingRadius : " + RingRadius);
                file.WriteLine("RingRadiate : " + RingRadiate);

                file.WriteLine("SprayDirectionX : " + SprayDirectionX);
                file.WriteLine("SprayDirectionY : " + SprayDirectionY);
                file.WriteLine("SpraySpread : " + SpraySpread);
                file.WriteLine("ParametersColorMin : " + ParametersColorMin);

                file.WriteLine("ParametersMassMin : " + ParametersMassMin);
                file.WriteLine("ParametersOpacityMin : " + ParametersOpacityMin);
                file.WriteLine("ParametersQuantityMin : " + ParametersQuantityMin);
                file.WriteLine("ParametersRotationMin : " + ParametersRotationMin);

                file.WriteLine("ParametersScaleMin : " + ParametersScaleMin);
                file.WriteLine("ParametersSpeedMin : " + ParametersSpeedMin);

                file.WriteLine("ParametersMassMax : " + ParametersMassMax);

                file.WriteLine("ParametersOpacityMax : " + ParametersOpacityMax);
                file.WriteLine("ParametersQuantityMax : " + ParametersQuantityMax);
                file.WriteLine("ParametersRotationMax : " + ParametersRotationMax);
                file.WriteLine("ParametersScaleMax : " + ParametersScaleMax);

                file.WriteLine("ParametersSpeedMax : " + ParametersSpeedMax);
                file.WriteLine("CircleContainerModifierInside : " + CircleContainerModifierInside);
                file.WriteLine("CircleContainerModifierRadius : " + CircleContainerModifierRadius);
                file.WriteLine("CircleContainerModifierRestitutionCoefficient : " + CircleContainerModifierRestitutionCoefficient);

                file.WriteLine("RectangleContainerModifierWidth : " + RectangleContainerModifierWidth);
                file.WriteLine("RectangleContainerModifierHeight : " + RectangleContainerModifierHeight);
                file.WriteLine("RectangleContainerModifierRestitutionCoefficient : " + RectangleContainerModifierRestitutionCoefficient);
                file.WriteLine("RectangleLoopContainerModifierWidth : " + RectangleLoopContainerModifierWidth);
                file.WriteLine("RectangleLoopContainerModifierHeight : " + RectangleLoopContainerModifierHeight);

                file.WriteLine("ModifiersInterpolatorsSelectedName : " + ModifiersInterpolatorsSelectedName);
                file.WriteLine("AgeModifierColorInterpolatorStartValue : " + AgeModifierColorInterpolatorStartValue);
                file.WriteLine("AgeModifierColorInterpolatorEndValue : " + AgeModifierColorInterpolatorEndValue);
                file.WriteLine("AgeModifierHueInterpolatorStartValue : " + AgeModifierHueInterpolatorStartValue);
                file.WriteLine("AgeModifierHueInterpolatorEndValue : " + AgeModifierHueInterpolatorEndValue);
                file.WriteLine("AgeModifierOpacityInterpolatorStartValue : " + AgeModifierOpacityInterpolatorStartValue);
                file.WriteLine("AgeModifierOpacityInterpolatorEndValue : " + AgeModifierOpacityInterpolatorEndValue);
                file.WriteLine("AgeModifierRotationInterpolatorStartValue : " + AgeModifierRotationInterpolatorStartValue);
                file.WriteLine("AgeModifierRotationInterpolatorEndValue : " + AgeModifierRotationInterpolatorEndValue);
                file.WriteLine("AgeModifierScaleInterpolatorStartValueX : " + AgeModifierScaleInterpolatorStartValueX);
                file.WriteLine("AgeModifierScaleInterpolatorStartValueY : " + AgeModifierScaleInterpolatorStartValueY);
                file.WriteLine("AgeModifierScaleInterpolatorEndValueX : " + AgeModifierScaleInterpolatorEndValueX);
                file.WriteLine("AgeModifierScaleInterpolatorEndValueY : " + AgeModifierScaleInterpolatorEndValueY);

                file.WriteLine("VelocityModifiersInterpolatorsSelectedName : " + VelocityModifiersInterpolatorsSelectedName);
                file.WriteLine("VelocityModifierColorInterpolatorStartValue : " + VelocityModifierColorInterpolatorStartValue);
                file.WriteLine("VelocityModifierColorInterpolatorEndValue : " + VelocityModifierColorInterpolatorEndValue);
                file.WriteLine("VelocityModifierHueInterpolatorStartValue : " + VelocityModifierHueInterpolatorStartValue);
                file.WriteLine("VelocityModifierHueInterpolatorEndValue : " + VelocityModifierHueInterpolatorEndValue);
                file.WriteLine("VelocityModifierOpacityInterpolatorStartValue : " + VelocityModifierOpacityInterpolatorStartValue);
                file.WriteLine("VelocityModifierOpacityInterpolatorEndValue : " + VelocityModifierOpacityInterpolatorEndValue);
                file.WriteLine("VelocityModifierRotationInterpolatorStartValue : " + VelocityModifierRotationInterpolatorStartValue);
                file.WriteLine("VelocityModifierRotationInterpolatorEndValue : " + VelocityModifierRotationInterpolatorEndValue);
                file.WriteLine("VelocityModifierScaleInterpolatorStartValueX : " + VelocityModifierScaleInterpolatorStartValueX);
                file.WriteLine("VelocityModifierScaleInterpolatorStartValueY : " + VelocityModifierScaleInterpolatorStartValueY);
                file.WriteLine("VelocityModifierScaleInterpolatorEndValueX : " + VelocityModifierScaleInterpolatorEndValueX);
                file.WriteLine("VelocityModifierScaleInterpolatorEndValueY : " + VelocityModifierScaleInterpolatorEndValueY);

                file.WriteLine("DragModifierDragCoefficient : " + DragModifierDragCoefficient);
                file.WriteLine("DragModifierDensity : " + DragModifierDensity);

                file.WriteLine("IsLinearGravityModifierSelected : " + IsLinearGravityModifierSelected.ToString());
                file.WriteLine("LinearGravityModifierDirectionX : " + LinearGravityModifierDirectionX);
                file.WriteLine("LinearGravityModifierDirectionY : " + LinearGravityModifierDirectionY);
                file.WriteLine("LinearGravityModifierStrength : " + LinearGravityModifierStrength);
                file.WriteLine("LinearGravityModifierControlSizeBuffer : " + LinearGravityModifierControlSizeBuffer);
                file.WriteLine("LinearGravityModifierControlDuration : " + LinearGravityModifierControlDuration);

                file.WriteLine("IsOpacityFastFadeModifierSelected : " + IsOpacityFastFadeModifierSelected.ToString());
                file.WriteLine("OpacityFastFadeModifierControlSizeBuffer : " + OpacityFastFadeModifierControlSizeBuffer);
                file.WriteLine("OpacityFastFadeModifierControlDuration : " + OpacityFastFadeModifierControlDuration);

                file.WriteLine("IsRotationModifierRotationRate : " + IsRotationModifierRotationRate.ToString());
                file.WriteLine("RotationModifierRotationRate : " + RotationModifierRotationRate);

                file.WriteLine("VelocityColorModifierVelocityColor : " + VelocityColorModifierVelocityColor);
                file.WriteLine("VelocityColorModifierStationaryColor : " + VelocityColorModifierStationaryColor);
                file.WriteLine("VelocityColorModifierVelocityThreshold : " + VelocityColorModifierVelocityThreshold);

                file.WriteLine("IsVelocityModifierInterpolatorSelected : " + IsVelocityModifierInterpolatorSelected);
                file.WriteLine("VelocityModifiersInterpolatorsSelectedName : " + VelocityModifiersInterpolatorsSelectedName);
                file.WriteLine("VelocityModifierColorInterpolatorStartValue : " + VelocityModifierColorInterpolatorStartValue);
                file.WriteLine("VelocityModifierColorInterpolatorEndValue : " + VelocityModifierColorInterpolatorEndValue);
                file.WriteLine("VelocityModifierHueInterpolatorStartValue : " + VelocityModifierHueInterpolatorStartValue);
                file.WriteLine("VelocityModifierHueInterpolatorEndValue : " + VelocityModifierHueInterpolatorEndValue);
                file.WriteLine("VelocityModifierOpacityInterpolatorStartValue : " + VelocityModifierOpacityInterpolatorStartValue);
                file.WriteLine("VelocityModifierOpacityInterpolatorEndValue : " + VelocityModifierOpacityInterpolatorEndValue);
                file.WriteLine("VelocityModifierRotationInterpolatorStartValue : " + VelocityModifierRotationInterpolatorStartValue);
                file.WriteLine("VelocityModifierRotationInterpolatorEndValue : " + VelocityModifierRotationInterpolatorEndValue);
                file.WriteLine("VelocityModifierScaleInterpolatorStartValueX : " + VelocityModifierScaleInterpolatorStartValueX);
                file.WriteLine("VelocityModifierScaleInterpolatorStartValueY : " + VelocityModifierScaleInterpolatorStartValueY);
                file.WriteLine("VelocityModifierScaleInterpolatorEndValueX : " + VelocityModifierScaleInterpolatorEndValueX);
                file.WriteLine("VelocityModifierScaleInterpolatorEndValueY : " + VelocityModifierScaleInterpolatorEndValueY);
                file.WriteLine("VelocityModifierVelocityThreshold : " + VelocityModifierVelocityThreshold);

                file.WriteLine("VortexModifierMass : " + VortexModifierMass);
                file.WriteLine("VortexModifierMaxSpeed : " + VortexModifierMaxSpeed);
                file.WriteLine("VortexModifierPositionX : " + VortexModifierPositionX);
                file.WriteLine("VortexModifierPositionY : " + VortexModifierPositionY);
                file.WriteLine("TextBoxTextureRegionDefinitions : " + TextBoxTextureRegionDefinitions);

                file.WriteLine("TextBoxCapacityDefinitions : " + TextBoxCapacityDefinitions);
                file.WriteLine("TextBoxLifeSpanDefinitions : " + TextBoxLifeSpanDefinitions);
            }

            #region ParticleEmitter
            ParticleEmitter particleEmitter = new ParticleEmitter("", textureRegion, DefinitionsCapacity, TimeSpan.FromSeconds(lifeSpan), GetProfile(ProfileName));

            isEmit = IsEmitterParameters;

            if (IsEmitterParameters)
            {
                particleEmitter.Parameters = new ParticleReleaseParameters();
                if (ParametersSpeedMin <= ParametersSpeedMax && ParametersSpeedMax > 0)
                {
                    particleEmitter.Parameters.Speed = new Range <float>(ParametersSpeedMin, ParametersSpeedMax);
                }
                if (ParametersQuantityMin <= ParametersQuantityMax && ParametersQuantityMax > 0)
                {
                    particleEmitter.Parameters.Quantity = new Range <int>(ParametersQuantityMin, ParametersQuantityMax);
                }
                if (ParametersRotationMin <= ParametersRotationMax && ParametersRotationMax > 0)
                {
                    particleEmitter.Parameters.Rotation = new Range <float>(ParametersRotationMin, ParametersRotationMax);
                }
                if (ParametersScaleMin <= ParametersScaleMax && ParametersScaleMax > 0)
                {
                    particleEmitter.Parameters.Scale = new Range <float>(ParametersScaleMin, ParametersScaleMax);
                }
                if (ParametersOpacityMin <= ParametersOpacityMax && ParametersOpacityMax > 0)
                {
                    particleEmitter.Parameters.Opacity = new Range <float>(ParametersOpacityMin, ParametersOpacityMax);
                }
                if (ParametersMassMin <= ParametersMassMax && ParametersMassMax > 0)
                {
                    particleEmitter.Parameters.Mass = new Range <float>(ParametersMassMin, ParametersMassMax);
                }
                if (ParametersColorMin.R > 0 || ParametersColorMin.G > 0 || ParametersColorMin.B > 0)
                {
                    particleEmitter.Parameters.Color = HslColor.FromRgb(ParametersColorMin);
                }
            }
            #endregion

            #region Modifiers Containers
            if (IsContainerModifierSelected)
            {
                if (ContainerModifierSelectedName == "CircleContainerModifier")
                {
                    CircleContainerModifier circleContainerModifier = new CircleContainerModifier();
                    circleContainerModifier.Inside = CircleContainerModifierInside;
                    circleContainerModifier.Radius = CircleContainerModifierRadius;
                    circleContainerModifier.RestitutionCoefficient = CircleContainerModifierRestitutionCoefficient;
                    particleEmitter.Modifiers.Add(circleContainerModifier);
                }
                if (ContainerModifierSelectedName == "RectangleContainerModifier")
                {
                    RectangleContainerModifier rectangleContainerModifier = new RectangleContainerModifier();
                    rectangleContainerModifier.Width  = RectangleContainerModifierWidth;
                    rectangleContainerModifier.Height = RectangleContainerModifierHeight;
                    rectangleContainerModifier.RestitutionCoefficient = RectangleContainerModifierRestitutionCoefficient;
                    particleEmitter.Modifiers.Add(rectangleContainerModifier);
                }
                if (ContainerModifierSelectedName == "RectangleLoopContainerModifier")
                {
                    RectangleLoopContainerModifier rectangleLoopContainerModifier = new RectangleLoopContainerModifier();
                    rectangleLoopContainerModifier.Width  = RectangleLoopContainerModifierWidth;
                    rectangleLoopContainerModifier.Height = RectangleLoopContainerModifierHeight;
                    particleEmitter.Modifiers.Add(rectangleLoopContainerModifier);
                }
            }

            #endregion

            #region AgeModifier Interpolator
            AgeModifier ageModifierColor    = new AgeModifier();
            AgeModifier ageModifierHue      = new AgeModifier();
            AgeModifier ageModifierOpacity  = new AgeModifier();
            AgeModifier ageModifierRotation = new AgeModifier();
            AgeModifier ageModifierScale    = new AgeModifier();

            if (ModifiersInterpolatorsSelectedName == "ColorInterpolator")
            {
                ColorInterpolator ageModifiercolorInterpolator = new ColorInterpolator();
                ageModifiercolorInterpolator.StartValue = HslColor.FromRgb(AgeModifierColorInterpolatorStartValue);
                ageModifierColor.Interpolators.Add(ageModifiercolorInterpolator);
            }

            else if (ModifiersInterpolatorsSelectedName == "HueInterpolator")
            {
                HueInterpolator ageModifierhueInterpolator = new HueInterpolator();
                ageModifierhueInterpolator.StartValue = AgeModifierHueInterpolatorStartValue;
                ageModifierhueInterpolator.EndValue   = AgeModifierHueInterpolatorEndValue;
                ageModifierHue.Interpolators.Add(ageModifierhueInterpolator);
            }
            else if (ModifiersInterpolatorsSelectedName == "OpacityInterpolator")
            {
                OpacityInterpolator ageModifierOpacityInterpolator = new OpacityInterpolator();
                ageModifierOpacityInterpolator.StartValue = AgeModifierOpacityInterpolatorStartValue;
                ageModifierOpacityInterpolator.EndValue   = AgeModifierOpacityInterpolatorEndValue;
                ageModifierOpacity.Interpolators.Add(ageModifierOpacityInterpolator);
            }

            else if (ModifiersInterpolatorsSelectedName == "RotationInterpolator")
            {
                RotationInterpolator ageModifierRotationInterpolator = new RotationInterpolator();
                ageModifierRotationInterpolator.StartValue = AgeModifierRotationInterpolatorStartValue;
                ageModifierRotationInterpolator.EndValue   = AgeModifierRotationInterpolatorEndValue;
                ageModifierRotation.Interpolators.Add(ageModifierRotationInterpolator);
            }

            else if (ModifiersInterpolatorsSelectedName == "ScaleInterpolator")
            {
                ScaleInterpolator ageModifierScaleInterpolator = new ScaleInterpolator();
                ageModifierScaleInterpolator.StartValue = new Vector2(AgeModifierScaleInterpolatorStartValueX, AgeModifierScaleInterpolatorStartValueY);
                ageModifierScaleInterpolator.EndValue   = new Vector2(AgeModifierScaleInterpolatorEndValueX, AgeModifierScaleInterpolatorEndValueY);
                ageModifierScale.Interpolators.Add(ageModifierScaleInterpolator);
            }

            particleEmitter.Modifiers.Add(ageModifierColor);
            particleEmitter.Modifiers.Add(ageModifierHue);
            particleEmitter.Modifiers.Add(ageModifierOpacity);
            particleEmitter.Modifiers.Add(ageModifierRotation);
            particleEmitter.Modifiers.Add(ageModifierScale);
            #endregion

            #region DragModifier Interpolator
            if (IsDragModifierSelected && DragModifierDensity > 0f && DragModifierDragCoefficient > 0f)
            {
                DragModifier dragModifier = new DragModifier();
                dragModifier.Density         = DragModifierDensity;
                dragModifier.DragCoefficient = DragModifierDragCoefficient;
                particleEmitter.Modifiers.Add(dragModifier);
            }
            #endregion

            #region LinearGravityModifier Interpolator
            if (IsLinearGravityModifierSelected)
            {
                LinearGravityModifier linearGravityModifier = new LinearGravityModifier();
                linearGravityModifier.Direction = new Vector2(LinearGravityModifierDirectionX, LinearGravityModifierDirectionY);
                linearGravityModifier.Strength  = LinearGravityModifierStrength;

                if (LinearGravityModifierControlSizeBuffer > 0 && LinearGravityModifierControlDuration > 0)
                {
                    ParticleBuffer particle1 = new ParticleBuffer(LinearGravityModifierControlSizeBuffer);
                    linearGravityModifier.Update(LinearGravityModifierControlDuration, particle1.Iterator);
                }
                particleEmitter.Modifiers.Add(linearGravityModifier);
            }
            #endregion

            #region OpacityFastFadeModifier Interpolator

            if (IsOpacityFastFadeModifierSelected)
            {
                OpacityFastFadeModifier opacityFastFadeModifier = new OpacityFastFadeModifier();
                if (OpacityFastFadeModifierControlSizeBuffer > 0 && OpacityFastFadeModifierControlDuration > 0)
                {
                    ParticleBuffer particle1 = new ParticleBuffer(OpacityFastFadeModifierControlSizeBuffer);
                    opacityFastFadeModifier.Update(OpacityFastFadeModifierControlDuration, particle1.Iterator);
                }
                particleEmitter.Modifiers.Add(opacityFastFadeModifier);
            }
            #endregion

            #region RotationModifier Interpolator
            if (IsRotationModifierRotationRate)
            {
                RotationModifier rotationModifier = new RotationModifier();
                rotationModifier.RotationRate = RotationModifierRotationRate;
                particleEmitter.Modifiers.Add(rotationModifier);
            }
            #endregion

            #region VelocityColorModifier Interpolator
            if (IsVelocityColorModifierSelected)
            {
                VelocityColorModifier velocityColorModifier = new VelocityColorModifier();
                velocityColorModifier.StationaryColor   = HslColor.FromRgb(VelocityColorModifierVelocityColor);
                velocityColorModifier.VelocityColor     = HslColor.FromRgb(VelocityColorModifierStationaryColor);
                velocityColorModifier.VelocityThreshold = VelocityColorModifierVelocityThreshold;
                particleEmitter.Modifiers.Add(velocityColorModifier);
            }
            #endregion

            #region VelocityModifier Interpolator
            if (IsVelocityModifierInterpolatorSelected)
            {
                VelocityModifier velocityModifierColor    = new VelocityModifier();
                VelocityModifier velocityModifierHue      = new VelocityModifier();
                VelocityModifier velocityModifierOpacity  = new VelocityModifier();
                VelocityModifier velocityModifierRotation = new VelocityModifier();
                VelocityModifier velocityModifierScale    = new VelocityModifier();

                if (VelocityModifiersInterpolatorsSelectedName == "ColorInterpolator")
                {
                    ColorInterpolator velocityModifiercolorInterpolator = new ColorInterpolator();
                    velocityModifiercolorInterpolator.StartValue = HslColor.FromRgb(VelocityModifierColorInterpolatorStartValue);
                    velocityModifiercolorInterpolator.EndValue   = HslColor.FromRgb(VelocityModifierColorInterpolatorEndValue);
                    velocityModifierColor.Interpolators.Add(velocityModifiercolorInterpolator);
                }

                else if (VelocityModifiersInterpolatorsSelectedName == "HueInterpolator")
                {
                    HueInterpolator velocityModifierhueInterpolator = new HueInterpolator();
                    velocityModifierhueInterpolator.StartValue = VelocityModifierHueInterpolatorStartValue;
                    velocityModifierhueInterpolator.EndValue   = VelocityModifierHueInterpolatorEndValue;
                    velocityModifierHue.Interpolators.Add(velocityModifierhueInterpolator);
                }
                else if (VelocityModifiersInterpolatorsSelectedName == "OpacityInterpolator")
                {
                    OpacityInterpolator velocityModifierOpacityInterpolator = new OpacityInterpolator();
                    velocityModifierOpacityInterpolator.StartValue = VelocityModifierOpacityInterpolatorStartValue;
                    velocityModifierOpacityInterpolator.EndValue   = VelocityModifierOpacityInterpolatorEndValue;
                    velocityModifierOpacity.Interpolators.Add(velocityModifierOpacityInterpolator);
                }

                else if (VelocityModifiersInterpolatorsSelectedName == "RotationInterpolator")
                {
                    RotationInterpolator velocityModifierRotationInterpolator = new RotationInterpolator();
                    velocityModifierRotationInterpolator.StartValue = VelocityModifierRotationInterpolatorStartValue;
                    velocityModifierRotationInterpolator.EndValue   = VelocityModifierRotationInterpolatorEndValue;
                    velocityModifierRotation.Interpolators.Add(velocityModifierRotationInterpolator);
                }

                else if (VelocityModifiersInterpolatorsSelectedName == "ScaleInterpolator")
                {
                    ScaleInterpolator velocityModifierScaleInterpolator = new ScaleInterpolator();
                    velocityModifierScaleInterpolator.StartValue = new Vector2(VelocityModifierScaleInterpolatorStartValueX, VelocityModifierScaleInterpolatorStartValueY);
                    velocityModifierScaleInterpolator.EndValue   = new Vector2(VelocityModifierScaleInterpolatorEndValueX, VelocityModifierScaleInterpolatorEndValueY);
                    velocityModifierScale.Interpolators.Add(velocityModifierScaleInterpolator);
                }

                particleEmitter.Modifiers.Add(velocityModifierColor);
                particleEmitter.Modifiers.Add(velocityModifierHue);
                particleEmitter.Modifiers.Add(velocityModifierOpacity);
                particleEmitter.Modifiers.Add(velocityModifierRotation);
                particleEmitter.Modifiers.Add(velocityModifierScale);
            }
            #endregion

            #region VortexModifier Interpolator
            if (IsVortexModifierSelected)
            {
                VortexModifier vortexModifier = new VortexModifier();
                vortexModifier.Mass     = VortexModifierMass;
                vortexModifier.MaxSpeed = VortexModifierMaxSpeed;
                vortexModifier.Position = new Vector2(VortexModifierPositionX, VortexModifierPositionY);
                particleEmitter.Modifiers.Add(vortexModifier);
            }
            #endregion

            particle.Emitters.Add(particleEmitter);
        }
Ejemplo n.º 25
0
 protected override Node EvalHsl(HslColor color)
 {
     return color.GetLightness();
 }
Ejemplo n.º 26
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     color.Hue += number.Value / 360d;
     return(color.ToRgbColor());
 }
Ejemplo n.º 27
0
 protected abstract Node EditHsl(HslColor color, Number number);
Ejemplo n.º 28
0
 protected override Node EvalHsl(HslColor color)
 {
     return(color.GetHueInDegrees());
 }
Ejemplo n.º 29
0
        async Task <string> CreateMarkupAsync(SearchResultWidget widget, TextEditor doc, Editor.IDocumentLine line)
        {
            int startIndex = 0, endIndex = 0;

            int    indent = line.GetIndentation(doc).Length;
            string lineText;
            int    col = Offset - line.Offset;
            int    markupStartOffset = 0;
            bool   trimStart = false, trimEnd = false;
            int    length;

            if (col < indent)
            {
                trimEnd = line.Length > maximumMarkupLength;
                length  = Math.Min(maximumMarkupLength, line.Length);
                // search result contained part of the indent.
                lineText = doc.GetTextAt(line.Offset, length);
            }
            else
            {
                // if not crop the indent
                length = line.Length - indent;
                if (length > maximumMarkupLength)
                {
                    markupStartOffset = Math.Min(Math.Max(0, col - indent - maximumMarkupLength / 2), line.Length - maximumMarkupLength);
                    trimEnd           = markupStartOffset + maximumMarkupLength < line.Length;
                    trimStart         = markupStartOffset > 0;
                    length            = maximumMarkupLength;
                }
                lineText = doc.GetTextAt(line.Offset + markupStartOffset + indent, length);
                col     -= indent;
            }
            if (col >= 0)
            {
                uint start;
                uint end;
                try {
                    start = (uint)TranslateIndexToUTF8(lineText, col - markupStartOffset);
                    end   = (uint)TranslateIndexToUTF8(lineText, Math.Min(lineText.Length, col - markupStartOffset + Length));
                } catch (Exception e) {
                    LoggingService.LogError("Exception while translating index to utf8 (column was:" + col + " search result length:" + Length + " line text:" + lineText + ")", e);
                    return("");
                }
                startIndex = (int)start;
                endIndex   = (int)end;
            }

            var tabSize = doc.Options.TabSize;

            this.markup = this.selectedMarkup = markup = Ambience.EscapeText(lineText);

            var searchColor = GetBackgroundMarkerColor(widget.HighlightStyle);

            var selectedSearchColor = widget.Style.Base(Gtk.StateType.Selected);

            selectedSearchColor = searchColor.AddLight(-0.2);
            double b1 = HslColor.Brightness(searchColor);
            double b2 = HslColor.Brightness(SearchResultWidget.AdjustColor(widget.Style.Base(Gtk.StateType.Normal), SyntaxHighlightingService.GetColor(widget.HighlightStyle, EditorThemeColors.Foreground)));

            // selected
            markup         = FormatMarkup(PangoHelper.ColorMarkupBackground(selectedMarkup, (int)startIndex, (int)endIndex, searchColor), trimStart, trimEnd, tabSize);
            selectedMarkup = FormatMarkup(PangoHelper.ColorMarkupBackground(selectedMarkup, (int)startIndex, (int)endIndex, selectedSearchColor), trimStart, trimEnd, tabSize);

            var markupTimeoutSource = new CancellationTokenSource(150);
            var newMarkup           = await doc.GetMarkupAsync(line.Offset + markupStartOffset + indent, length, new MarkupOptions (MarkupFormat.Pango), markupTimeoutSource.Token).ConfigureAwait(false);

            newMarkup = widget.AdjustColors(newMarkup);

            try {
                double delta = Math.Abs(b1 - b2);
                if (delta < 0.1)
                {
                    var color1 = SyntaxHighlightingService.GetColor(widget.HighlightStyle, EditorThemeColors.FindHighlight);
                    if (color1.L + 0.5 > 1.0)
                    {
                        color1.L -= 0.5;
                    }
                    else
                    {
                        color1.L += 0.5;
                    }
                    searchColor = color1;
                }
                if (startIndex != endIndex)
                {
                    newMarkup = PangoHelper.ColorMarkupBackground(newMarkup, (int)startIndex, (int)endIndex, searchColor);
                }
            } catch (Exception e) {
                LoggingService.LogError("Error while setting the text renderer markup to: " + newMarkup, e);
            }

            return(FormatMarkup(newMarkup, trimStart, trimEnd, tabSize));
        }
Ejemplo n.º 30
0
 public static void NextColor(out HslColor color, ColorRange range)
 {
     var maxH = range.Max.H >= range.Min.H
         ? range.Max.H
         : range.Max.H + 360;
     color = new HslColor(NextSingle(range.Min.H, maxH),
                          NextSingle(range.Min.S, range.Max.S),
                          NextSingle(range.Min.L, range.Max.L));
 }
Ejemplo n.º 31
0
        protected override Node Eval(Color color)
        {
            var hsl = HslColor.FromRgbColor(color);

            return(EvalHsl(hsl));
        }
Ejemplo n.º 32
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     return base.EditHsl(color, -number);
 }
Ejemplo n.º 33
0
 public HslColor Lighten(double pct)
 {
     HslColor c = new HslColor();
     c.A = this.A;
     c.H = this.H;
     c.S = this.S;
     c.L = Math.Min(Math.Max(this.L + pct, 0), 1);
     return c;
 }
Ejemplo n.º 34
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     color.Hue += number.Value/360d;
     return color.ToRgbColor();
 }
Ejemplo n.º 35
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     color.Saturation += number.Value/100;
     return color.ToRgbColor();
 }
Ejemplo n.º 36
0
			protected override bool OnExposeEvent (Gdk.EventExpose evnt)
			{
				if (TabStrip.VisualStyle.TabStyle == DockTabStyle.Normal) {
					var alloc = Allocation;
					Gdk.GC gc = new Gdk.GC (GdkWindow);
					gc.RgbFgColor = TabStrip.VisualStyle.InactivePadBackgroundColor.Value;
					evnt.Window.DrawRectangle (gc, true, alloc);
					gc.Dispose ();
		
					Gdk.GC bgc = new Gdk.GC (GdkWindow);
					var c = new HslColor (TabStrip.VisualStyle.PadBackgroundColor.Value);
					c.L *= 0.7;
					bgc.RgbFgColor = c;
					evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
					bgc.Dispose ();
				}	
				return base.OnExposeEvent (evnt);
			}
Ejemplo n.º 37
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     color.Saturation += number.Value / 100;
     return(color.ToRgbColor());
 }
Ejemplo n.º 38
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     color.Lightness += number.Value / 100;
     return(color.ToRgbColor());
 }
Ejemplo n.º 39
0
        protected override Node EditHsl(HslColor color, Number number)
        {
            WarnNotSupportedByLessJS("lightness(color, number)", "lighten(color, number) or its opposite darken(color, number),");

            return base.EditHsl(color, number);
        }
Ejemplo n.º 40
0
 protected override Node EvalHsl(HslColor color)
 {
     return(color.GetSaturation());
 }
Ejemplo n.º 41
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            if (State == StateType.Prelight) {
                int w = Allocation.Width, h = Allocation.Height;
                double x=Allocation.Left, y=Allocation.Top, r=3;
                x += 0.5; y += 0.5; h -=1; w -= 1;

                using (Cairo.Context ctx = Gdk.CairoHelper.Create (GdkWindow)) {
                    HslColor c = new HslColor (Style.Background (Gtk.StateType.Normal));
                    HslColor c1 = c;
                    HslColor c2 = c;
                    if (State != StateType.Prelight) {
                        c1.L *= 0.8;
                        c2.L *= 0.95;
                    } else {
                        c1.L *= 1.1;
                        c2.L *= 1;
                    }
                    Cairo.Gradient pat;
                    switch (bar.Position) {
                        case PositionType.Top: pat = new Cairo.LinearGradient (x, y, x, y+h); break;
                        case PositionType.Bottom: pat = new Cairo.LinearGradient (x, y, x, y+h); break;
                        case PositionType.Left: pat = new Cairo.LinearGradient (x+w, y, x, y); break;
                        default: pat = new Cairo.LinearGradient (x, y, x+w, y); break;
                    }
                    pat.AddColorStop (0, c1);
                    pat.AddColorStop (1, c2);
                    ctx.NewPath ();
                    ctx.Arc (x+r, y+r, r, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
                    ctx.LineTo (x+w-r, y);
                    ctx.Arc (x+w-r, y+r, r, 270 * (Math.PI / 180), 360 * (Math.PI / 180));
                    ctx.LineTo (x+w, y+h);
                    ctx.LineTo (x, y+h);
                    ctx.ClosePath ();
                    ctx.Pattern = pat;
                    ctx.FillPreserve ();
                    c1 = c;
                    c1.L *= 0.7;
                    ctx.LineWidth = 1;
                    ctx.Color = c1;
                    ctx.Stroke ();

                    // Inner line
                    ctx.NewPath ();
                    ctx.Arc (x+r+1, y+r+1, r, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
                    ctx.LineTo (x+w-r-1, y+1);
                    ctx.Arc (x+w-r-1, y+r+1, r, 270 * (Math.PI / 180), 360 * (Math.PI / 180));
                    ctx.LineTo (x+w-1, y+h-1);
                    ctx.LineTo (x+1, y+h-1);
                    ctx.ClosePath ();
                    c1 = c;
                    //c1.L *= 0.9;
                    ctx.LineWidth = 1;
                    ctx.Color = c1;
                    ctx.Stroke ();
                }
            }

            bool res = base.OnExposeEvent (evnt);
            return res;
        }
Ejemplo n.º 42
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     return(null);
 }
Ejemplo n.º 43
0
 protected override Node EvalHsl(HslColor color)
 {
     return color.GetHueInDegrees();
 }
Ejemplo n.º 44
0
        public ColorBlendExtension(IPropertiesProvider parameterProvider, string parameterName, HslColor blendColor, Color currentColor, Color originalColor)
        {
            this.styleParameterSerivce = parameterProvider;
            this.themePropertyName     = parameterName;

            this.originalColor = originalColor;

            HslColor currentHslColor = HslColor.FromColor(currentColor);

            this.colorADiff = currentHslColor.A - blendColor.A;
            this.colorHDiff = currentHslColor.H - blendColor.H;
            this.colorSDiff = currentHslColor.S - blendColor.S;
            this.colorLDiff = currentHslColor.L - blendColor.L;
        }
Ejemplo n.º 45
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            if (data == null)
            {
                BuildData();
            }

            hostSpots.Clear();
            int ytop    = padding;
            int markerX = 3;
            int lx      = markerX + MarkerWidth + 1;
            int tx      = 250;
            int ty      = ytop;
            int maxx    = lx;
            int maxy    = 0;

            DateTime initialTime = mainValue.TimeStamp;

            Cairo.Context ctx = CairoHelper.Create(GdkWindow);

            using (Gdk.GC gc = new Gdk.GC(GdkWindow)) {
                gc.RgbFgColor = Style.White;
                GdkWindow.DrawRectangle(gc, true, 0, 0, Allocation.Width, Allocation.Height);

                // Draw full time marker

                ctx.NewPath();
                ctx.Rectangle(markerX, ytop + baseTime + 0.5, MarkerWidth / 2, ((mainValue.Duration.TotalMilliseconds * scale) / 1000));
                HslColor hsl = Style.Foreground(Gtk.StateType.Normal);
                hsl.L = 0.8;
                ctx.SetSourceColor(hsl);
                ctx.Fill();

                // Draw values

                foreach (CounterValueInfo val in data)
                {
                    DrawValue(ctx, gc, initialTime, ytop, lx, tx, ref ty, ref maxx, ref maxy, 0, val);
                }

                if (ty > maxy)
                {
                    maxy = ty;
                }

                int totalms = (int)mainValue.Duration.TotalMilliseconds;
                int marks   = (totalms / 1000) + 1;

                ctx.LineWidth = 1;
                gc.RgbFgColor = Style.Foreground(Gtk.StateType.Normal);

                for (int n = 0; n <= marks; n++)
                {
                    ctx.NewPath();
                    int y = ytop + (int)(n * scale) + baseTime;
                    ctx.MoveTo(markerX, y + 0.5);
                    ctx.LineTo(markerX + MarkerWidth, y + 0.5);
                    ctx.SetSourceColor(Style.Foreground(Gtk.StateType.Normal).ToCairoColor());
                    ctx.Stroke();

                    y += 2;
                    layout.SetText(n + "s");
                    GdkWindow.DrawLayout(gc, markerX + 1, y + 2, layout);

                    int tw, th;
                    layout.GetPixelSize(out tw, out th);
                    y += th;

                    if (y > maxy)
                    {
                        maxy = y;
                    }
                }
            }

            ((IDisposable)ctx).Dispose();

            maxy += padding;
            maxx += padding;

            if (lastHeight != maxy || lastWidth != maxx)
            {
                lastWidth  = maxx;
                lastHeight = maxy;
                SetSizeRequest(maxx, maxy);
            }

            return(true);
        }
Ejemplo n.º 46
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     return null;
 }
Ejemplo n.º 47
0
 protected override Node EditHsl(HslColor color, Number number)
 {
     color.Lightness += number.Value/100;
     return color.ToRgbColor();
 }
Ejemplo n.º 48
0
		void DrawAsBrowser (Gdk.EventExpose evnt)
		{
			var alloc = Allocation;

			Gdk.GC bgc = new Gdk.GC (GdkWindow);
			var c = new HslColor (VisualStyle.PadBackgroundColor.Value);
			c.L *= 0.7;
			bgc.RgbFgColor = c;
			bool first = true;
			bool last = true;
			TabStrip tabStrip = null;
			if (Parent is TabStrip.TabStripBox) {
				var tsb = (TabStrip.TabStripBox) Parent;
				var cts = tsb.Children;
				first = cts[0] == this;
				last = cts[cts.Length - 1] == this;
				tabStrip = tsb.TabStrip;
			}

			if (Active || (first && last)) {
				Gdk.GC gc = new Gdk.GC (GdkWindow);
				gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value;
				evnt.Window.DrawRectangle (gc, true, alloc);
				if (!first)
					evnt.Window.DrawLine (bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1);
				if (!(last && first) && !(tabStrip != null && tabStrip.VisualStyle.ExpandedTabs.Value && last))
					evnt.Window.DrawLine (bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
				gc.Dispose ();

			} else {
				Gdk.GC gc = new Gdk.GC (GdkWindow);
				gc.RgbFgColor = tabStrip != null ? tabStrip.VisualStyle.InactivePadBackgroundColor.Value : frame.DefaultVisualStyle.InactivePadBackgroundColor.Value;
				evnt.Window.DrawRectangle (gc, true, alloc);
				gc.Dispose ();
				evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
			}
			bgc.Dispose ();
		}
Ejemplo n.º 49
0
 protected abstract Node EvalHsl(HslColor color);
Ejemplo n.º 50
0
        //public ColorWheel_t(Unclassified.UI.ColorWheel colorWheelControl)
        //{
        //    Hue = colorWheelControl.Hue;
        //    Saturation = colorWheelControl.Saturation;
        //    Lightness = colorWheelControl.Lightness;
        //}

        public ColorWheel_t()
        {
            HSL = new HslColor(0, 255, 128);
        }
Ejemplo n.º 51
0
        void DrawValue(Cairo.Context ctx, Gdk.GC gc, DateTime initialTime, int ytop, int lx, int tx, ref int ty, ref int maxx, ref int maxy, int indent, CounterValueInfo val)
        {
            Gdk.Color color;
            if (val.Counter != null)
            {
                color = val.Counter.GetColor();
            }
            else
            {
                color = Style.Black;
            }

            // Draw text
            gc.RgbFgColor = color;

            double ms = (val.Time - initialTime).TotalMilliseconds;

            string txt = (ms / 1000).ToString("0.00000") + ": " + (val.Duration.TotalMilliseconds / 1000).ToString("0.00000") + " " + val.Trace;

            layout.SetText(txt);
            GdkWindow.DrawLayout(gc, tx + indent, ty, layout);
            int tw, th;

            layout.GetPixelSize(out tw, out th);
            if (tx + tw + indent > maxx)
            {
                maxx = tx + tw + indent;
            }

            HotSpot hp     = AddHotSpot(tx + indent, ty, tw, th);
            int     tempTy = ty;

            hp.Action = delegate {
                int ytm = ytop + (int)((ms * scale) / 1000);
                SetBaseTime((int)(tempTy + (th / 2) + 0.5) - ytm);
            };
            hp.OnMouseOver += delegate {
                overValue = val;
                QueueDraw();
            };
            hp.Action += delegate {
                focusedValue = val;
                QueueDraw();
            };

            // Draw time marker
            int ytime = ytop + (int)((ms * scale) / 1000) + baseTime;

            if (val == focusedValue || val == overValue)
            {
                ctx.NewPath();
                double dx = val == focusedValue ? 0 : 2;
                ctx.Rectangle(lx + 0.5 + dx - SelectedValuePadding, ytime + 0.5, LineEndWidth - dx * 2 + SelectedValuePadding, ((val.Duration.TotalMilliseconds * scale) / 1000));
                HslColor hsl = color;
                hsl.L = val == focusedValue ? 0.9 : 0.8;
                ctx.SetSourceColor(hsl);
                ctx.Fill();
            }

            ctx.NewPath();
            ctx.LineWidth = 1;
            ctx.MoveTo(lx + 0.5, ytime + 0.5);
            ctx.LineTo(lx + LineEndWidth + 0.5, ytime + 0.5);
            ctx.LineTo(tx - 3 - LineEndWidth + 0.5, ty + (th / 2) + 0.5);
            ctx.LineTo(tx + indent - 3 + 0.5, ty + (th / 2) + 0.5);
            ctx.SetSourceColor(color.ToCairoColor());
            ctx.Stroke();

            // Expander

            bool incLine = true;

            if (val.CanExpand)
            {
                double ex = tx + indent - 3 - ExpanderSize - 2 + 0.5;
                double ey = ty + (th / 2) - (ExpanderSize / 2) + 0.5;
                hp = AddHotSpot(ex, ey, ExpanderSize, ExpanderSize);
                DrawExpander(ctx, ex, ey, val.Expanded, false);
                hp.OnMouseOver = delegate {
                    using (Cairo.Context c = CairoHelper.Create(GdkWindow)) {
                        DrawExpander(c, ex, ey, val.Expanded, true);
                    }
                };
                hp.OnMouseLeave = delegate {
                    using (Cairo.Context c = CairoHelper.Create(GdkWindow)) {
                        DrawExpander(c, ex, ey, val.Expanded, false);
                    }
                };
                hp.Action = delegate {
                    ToggleExpand(val);
                };

                if (val.Expanded && val.ExpandedTimerTraces.Count > 0)
                {
                    ty += th + LineSpacing;
                    foreach (CounterValueInfo cv in val.ExpandedTimerTraces)
                    {
                        DrawValue(ctx, gc, initialTime, ytop, lx, tx, ref ty, ref maxx, ref maxy, indent + ChildIndent, cv);
                    }
                    incLine = false;
                }
            }
            if (incLine)
            {
                ty += th + LineSpacing;
            }

            if (ytime > maxy)
            {
                maxy = ytime;
            }
        }
Ejemplo n.º 52
0
        protected override Node EditColor(Color color, Number number)
        {
            var hsl = HslColor.FromRgbColor(color);

            return(EditHsl(hsl, number));
        }
Ejemplo n.º 53
0
 protected override Node EvalHsl(HslColor color)
 {
     color.Hue += 0.5;
     return color.ToRgbColor();
 }
Ejemplo n.º 54
0
        public static string ColorMarkupBackground(string textMarkup, int startIndex, int endIndex, HslColor searchColor)
        {
            var  markupBuilder = new StringBuilder();
            bool inMarkup = false, inEntity = false, closed = false;
            int  i = 0;

            for (int j = 0; j < textMarkup.Length; j++)
            {
                var ch = textMarkup [j];
                if (inEntity)
                {
                    if (ch == ';')
                    {
                        inEntity = false;
                        i++;
                    }
                    markupBuilder.Append(ch);
                    continue;
                }
                if (inMarkup)
                {
                    if (ch == '>')
                    {
                        inMarkup = false;
                        markupBuilder.Append(ch);
                        if (i > startIndex && markupBuilder.ToString().EndsWith("</span>"))
                        {
                            if (!closed)
                            {
                                markupBuilder.Append("</span>");
                            }
                            markupBuilder.Append(textMarkup.Substring(j + 1));
                            return(ColorMarkupBackground(markupBuilder.ToString(), i, endIndex, searchColor));
                        }
                        continue;
                    }
                    markupBuilder.Append(ch);
                    continue;
                }
                if (i == endIndex)
                {
                    markupBuilder.Append("</span>");
                    markupBuilder.Append(textMarkup.Substring(j));
                    closed = true;
                    break;
                }
                if (ch == '&')
                {
                    inEntity = true;
                    markupBuilder.Append(ch);
                    continue;
                }
                if (ch == '<')
                {
                    inMarkup = true;
                    markupBuilder.Append(ch);
                    continue;
                }
                if (i == startIndex)
                {
                    markupBuilder.Append("<span background=\"" + ColorToPangoMarkup(searchColor) + "\">");
                }
                markupBuilder.Append(ch);
                i++;
            }
            if (!closed)
            {
                markupBuilder.Append("</span>");
            }
            return(markupBuilder.ToString());
        }
Ejemplo n.º 55
0
		protected override void OnRealized ()
		{
			base.OnRealized ();
			HslColor cLight = new HslColor (Style.Background (Gtk.StateType.Normal));
			HslColor cDark = cLight;
			cLight.L *= 0.9;
			cDark.L *= 0.8;
		}
Ejemplo n.º 56
0
 public override object ConvertTo(
     ITypeDescriptorContext context,
     CultureInfo culture,
     object value,
     Type destinationType)
 {
     if ((object)destinationType == null)
     {
         throw new ArgumentNullException(nameof(destinationType));
     }
     if (value is HslColor)
     {
         if ((object)destinationType == (object)typeof(string))
         {
             HslColor hslColor = (HslColor)value;
             if (hslColor == HslColor.Empty)
             {
                 return((object)string.Empty);
             }
             if (culture == null)
             {
                 culture = CultureInfo.CurrentCulture;
             }
             string        separator = culture.TextInfo.ListSeparator + " ";
             TypeConverter converter = TypeDescriptor.GetConverter(typeof(double));
             int           num1      = 0;
             string[]      strArray1;
             if (hslColor.A < (int)byte.MaxValue)
             {
                 strArray1         = new string[4];
                 strArray1[num1++] = converter.ConvertToString(context, culture, (object)hslColor.A);
             }
             else
             {
                 strArray1 = new string[3];
             }
             string[] strArray2 = strArray1;
             int      index1    = num1;
             int      num2      = index1 + 1;
             string   str1      = converter.ConvertToString(context, culture, (object)hslColor.H);
             strArray2[index1] = str1;
             string[] strArray3 = strArray1;
             int      index2    = num2;
             int      num3      = index2 + 1;
             string   str2      = converter.ConvertToString(context, culture, (object)hslColor.S);
             strArray3[index2] = str2;
             string[] strArray4 = strArray1;
             int      index3    = num3;
             int      num4      = index3 + 1;
             string   str3      = converter.ConvertToString(context, culture, (object)hslColor.L);
             strArray4[index3] = str3;
             return((object)string.Join(separator, strArray1));
         }
         if ((object)destinationType == (object)typeof(InstanceDescriptor))
         {
             object[]   objArray = (object[])null;
             HslColor   hslColor = (HslColor)value;
             MemberInfo member;
             if (hslColor.IsEmpty)
             {
                 member = (MemberInfo)typeof(HslColor).GetField("Empty");
             }
             else if (hslColor.A != (int)byte.MaxValue)
             {
                 member = (MemberInfo)typeof(HslColor).GetMethod("FromAhsl", new Type[4]
                 {
                     typeof(int),
                     typeof(int),
                     typeof(int),
                     typeof(int)
                 });
                 objArray = new object[4]
                 {
                     (object)hslColor.A,
                     (object)hslColor.H,
                     (object)hslColor.S,
                     (object)hslColor.L
                 };
             }
             else
             {
                 member = (MemberInfo)typeof(HslColor).GetMethod("FromAhsl", new Type[3]
                 {
                     typeof(int),
                     typeof(int),
                     typeof(int)
                 });
                 objArray = new object[3]
                 {
                     (object)hslColor.H,
                     (object)hslColor.S,
                     (object)hslColor.L
                 };
             }
             return((object)new InstanceDescriptor(member, (ICollection)objArray));
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }