Пример #1
0
        public TrainLoadCalculator(TrainLoadInput trainLoadInput)
        {
            this.trainLoadInput = trainLoadInput;

            this.gradient      = new LinearGradient(this.trainLoadInput.MaxColor, this.trainLoadInput.MinColor, this.trainLoadInput.MiddleColor);
            this.femCalculator = new FEMCalculator(this.trainLoadInput);
            this.resultCreator = new ResultCreator(this.gradient, trainLoadInput.TimeSettings);
        }
Пример #2
0
        public AudioSpectrumEffect(SoundDataProcessor dataProcessor, IGradient gradient)
        {
            this._dataProcessor = dataProcessor;
            _audioSpectrumBrush = new AudioSpectrumBrush(gradient);

            // Give this effect a high Z-Index to keep it in the foreground
            ZIndex = 10;
        }
Пример #3
0
        /// <summary>
        /// Copies from another Function2D.
        /// </summary>
        public override void CopyFrom(Item src)
        {
            base.CopyFrom(src);
            Function2DItem f = (Function2DItem)src;

            Gradient = f.Gradient.Clone();
            Source   = f.Source;
            Compiler.Compile(this);
        }
Пример #4
0
 private void DrawGradientItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
 {
     e.DrawBackground();
     if (e.Index >= 0 && e.Index < Gradients.List.Count)
     {
         IGradient g = Gradients.List[e.Index];
         GradientPainter.FillRectangle(e.Graphics, g, e.Bounds, GradientPainter.Direction.Right);
     }
     e.DrawFocusRectangle();
 }
Пример #5
0
 public LabelRequestContext(Vector2 root, float radius, float speed, float angle, float timeToLive, IGradient color,
                            string text)
 {
     this.root       = root;
     this.radius     = radius;
     this.speed      = speed;
     this.angle      = angle;
     this.timeToLive = timeToLive;
     this.color      = color;
     this.text       = text;
 }
Пример #6
0
 public void Initialize(LabelRequestContext ctx)
 {
     text.sortingOrder = ++rendererPriority;
     velocity0         = ctx.speed * M.CosSinDeg(ctx.angle);
     tr.localPosition  = loc = ctx.root + ctx.radius * M.CosSinDeg(ctx.angle);
     this.ttl          = ctx.timeToLive;
     time      = 0;
     gradient  = ctx.color;
     text.text = ctx.text;
     SetColor();
 }
Пример #7
0
 //--------------------------------------------------------------------
 public SpanGradient(ISpanInterpolator inter,
                     IGradient gradient_function,
                     IColorFunction color_function,
                     double d1, double d2)
 {
     m_interpolator      = inter;
     m_gradient_function = gradient_function;
     m_color_function    = color_function;
     m_d1 = (Basics.Round(d1 * gradientSubpixelScale));
     m_d2 = (Basics.Round(d2 * gradientSubpixelScale));
 }
Пример #8
0
		//--------------------------------------------------------------------
		public span_gradient(ISpanInterpolator inter,
					  IGradient gradient_function,
					  IColorFunction color_function,
					  double d1, double d2)
		{
			m_interpolator = inter;
			m_gradient_function = gradient_function;
			m_color_function = color_function;
			m_d1 = (agg_basics.iround(d1 * gradient_subpixel_scale));
			m_d2 = (agg_basics.iround(d2 * gradient_subpixel_scale));
		}
Пример #9
0
 //--------------------------------------------------------------------
 public span_gradient(ISpanInterpolator inter,
                      IGradient gradient_function,
                      IColorFunction color_function,
                      double d1, double d2)
 {
     m_interpolator      = inter;
     m_gradient_function = gradient_function;
     m_color_function    = color_function;
     m_d1 = (agg_basics.iround(d1 * gradient_subpixel_scale));
     m_d2 = (agg_basics.iround(d2 * gradient_subpixel_scale));
 }
Пример #10
0
        private static XElementBuilder BuildGradientElement(IGradient gradient)
        {
            if (gradient is LinearGradient linearGradient)
            {
                return(BuildLinearGradientElement(linearGradient));
            }
            if (gradient is RadialGradient radialGradient)
            {
                return(BuildRadialGradient(radialGradient));
            }

            throw new GradientNotSupportedException(gradient.GetType());
        }
        private SKShader GetShader(IGradient gradient, DrawContext context)
        {
            if (gradient is ILinearGradient linear)
            {
                return(_linearPainter.CreateShader(linear, context));
            }

            if (gradient is IRadialGradient radial)
            {
                return(_radialPainter.CreateShader(radial, context));
            }

            throw new ArgumentException("Type not supported");
        }
        private Paint GetPaint(IGradient gradient, DrawContext context)
        {
            if (gradient is ILinearGradient linear)
            {
                return(CreateLinearPaint(linear, context));
            }

            if (gradient is IRadialGradient radial)
            {
                return(CreateRadialPaint(radial, context));
            }

            return(new SolidPaint(Colors.Black));
        }
Пример #13
0
        private void LowerClick(object sender, EventArgs e)
        {
            IGradient g = gradientChooser.SelectedGradient;

            if (g is LinearGradient)
            {
                LinearGradient lg = (LinearGradient)g;
                colorDialog.ShowDialog();
                lg.UpperColor        = colorDialog.Color;
                lowerColor.BackColor = colorDialog.Color;
                Gradients.LinearGradient.LowerColor = colorDialog.Color;
                gradientChooser.Refresh();
            }
        }
Пример #14
0
 public void Reset()
 {
     if (oldItem == null)
     {
         dimensions   = Dimensions.One;
         fSource.Text = "return 0;";
     }
     else
     {
         if (oldItem is Function1DItem)
         {
             SetDimensions(Dimensions.One);
         }
         else if (oldItem is Function2DItem)
         {
             SetDimensions(Dimensions.Two);
         }
         else if (oldItem is FunctionColorItem)
         {
             SetDimensions(Dimensions.TwoColor);
         }
         else
         {
             throw new System.ApplicationException("invalid item-type");
         }
         name.Text = oldItem.Name;
         this.Text = oldItem.Name;
         if (oldItem is Function1DItem)
         {
             Function1DItem f1 = (Function1DItem)oldItem;
             fSource.Text    = f1.Source;
             style.Color     = f1.Color;
             style.LineWidth = f1.LineWidth;
             style.LineStyle = f1.LineStyle;
         }
         else if (oldItem is Function2DItem)
         {
             Function2DItem f1 = (Function2DItem)oldItem;
             fSource.Text = f1.Source;
             Gradient     = f1.Gradient;
         }
         else if (oldItem is FunctionColorItem)
         {
             FunctionColorItem f1 = (FunctionColorItem)oldItem;
             fSource.Text = f1.Source;
         }
     }
 }
Пример #15
0
 private void StyleClick(object sender, EventArgs e)
 {
     if (dimensions == Dimensions.One)
     {
         style.Name = name.Text;
         FunctionLineStyleForm.New(Model, style);
     }
     else if (dimensions == Dimensions.Two)
     {
         Gradient = GradientForm.ShowDialog();
         Model.Items.Update(f);
     }
     else
     {
         Debug.Fail("No Style for Color function");
     }
 }
        protected PaintGradientStop[] GetRenderStops(IGradient gradient)
        {
            var stops = gradient.GetStops();

            if (stops.Count == 1)
            {
                return(new[]
                {
                    new PaintGradientStop(0, stops[0].Color),
                    new PaintGradientStop(1, stops[0].Color)
                });
            }

            return(stops
                   .OrderBy(x => x.RenderOffset)
                   .Select(x => new PaintGradientStop(x.RenderOffset, x.Color))
                   .ToArray());
        }
Пример #17
0
        public void FillRectangle(RectangleF rectangle, IGradient gradient)
        {
            Contract.Requires <ArgumentException>(!rectangle.IsEmpty);
            Contract.Requires <ArgumentException>(gradient != null);

            float[] widthSegments;
            float[] heightSegments;

            switch (gradient.Type)
            {
            default:
            case GradientType.Uniform:
                widthSegments  = new float[] { 0, 1 };
                heightSegments = new float[] { 0, 1 };
                break;

            case GradientType.LinearVerticalGradient:
                widthSegments = (from gs in gradient.GradientStops
                                 select gs.Offset).ToArray();
                heightSegments = new float[] { 0, 1 };
                break;
            }

            ushort[]  indices;
            Vector4[] vertices = CreateRectangleMesh(rectangle, widthSegments, heightSegments, out indices);
            Color4[]  colors   = new Color4[vertices.Length];
            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = Color.BlueViolet;
            }

            VertexPositionColor[] vertexArray = (from vertex in vertices
                                                 from color in colors
                                                 select new VertexPositionColor()
            {
                Position = vertex, Color = color
            }).ToArray();

            shapes.Add(new ShapeMeshDescription()
            {
                Vertices = vertexArray, Indices = indices
            });
        }
        protected IGradientStop[] GetRenderStops(IGradient gradient)
        {
            var stops = gradient.GetStops();

            if (stops.Count == 1)
            {
                return(new[]
                {
                    new GradientStop {
                        RenderOffset = 0, Color = stops[0].Color
                    },
                    new GradientStop {
                        RenderOffset = 1, Color = stops[0].Color
                    }
                });
            }

            return(stops.OrderBy(x => x.RenderOffset).ToArray());
        }
Пример #19
0
 public void SetControlledObject(object item)
 {
     try
     {
         if (item != null && item is IGradient)
         {
             m_Item = (IGradient)item;
             FillControls();
             if (item is IChangeNotify)
             {
                 ((IChangeNotify)item).ItemChanged += External_ItemChanged;
             }
             this.Enabled = true;
         }
         else
         {
             ClearControls();
             this.Enabled = false;
         }
     }
     catch (System.Exception) { }
 }
Пример #20
0
        public static void GradientHelpers()
        {
            IGradient g = EvenlySpaced(Color.red, Color.blue);

            ColorEq(g.Evaluate(0f), Color.red);
            ColorEq(g.Evaluate(1f), Color.blue);
            var gr = g.Reverse();

            ColorEq(gr.Evaluate(0f), Color.blue);
            ColorEq(gr.Evaluate(1f), Color.red);
            var gsr = gr.RemapTime(0.2f, 0.7f);

            ColorEq(gsr.Evaluate(0), Color.Lerp(Color.blue, Color.red, 0.2f));
            ColorEq(gsr.Evaluate(1), Color.Lerp(Color.blue, Color.red, 0.7f));
            ColorEq(gsr.Evaluate(0.5f), Color.Lerp(Color.blue, Color.red, 0.45f));
            Assert.IsTrue(gsr is DGradient);
            var red0 = new Color(1f, 0, 0, 0);

            g = EvenlySpaced(red0, Color.blue);
            //Alpha in color DOES matter as fallback
            ColorEq(g.Evaluate(0f), Color.red.WithA(0f));
            ColorEq(g.Evaluate(1f), Color.blue);
            g = FromKeys(new[] { new GradientColorKey(Color.red, 0f), new GradientColorKey(Color.blue, 1f) },
                         new[] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 1f) });
            ColorEq(g.Evaluate(0f), red0);
            ColorEq(g.Evaluate(1f), Color.blue);
            g = g.RemapTime(0.2f, 0.7f);
            ColorEq(g.Evaluate(0), Color.Lerp(red0, Color.blue, 0.2f));
            ColorEq(g.Evaluate(1), Color.Lerp(red0, Color.blue, 0.7f));
            ColorEq(g.Evaluate(0.5f), Color.Lerp(red0, Color.blue, 0.45f));
            g = g.RemapTime(0f, 2f);
            ColorEq(g.Evaluate(0), Color.Lerp(red0, Color.blue, 0.2f));
            ColorEq(g.Evaluate(1), Color.Lerp(red0, Color.blue, 0.7f));
            ColorEq(g.Evaluate(0.5f), Color.Lerp(red0, Color.blue, 0.7f));
            Assert.IsTrue(g is DGradient);
        }
Пример #21
0
		public gradient_reflect_adaptor(IGradient gradient)
		{
			m_gradient = gradient;
		}
Пример #22
0
 public GradientReflectAdaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #23
0
 public GradientClampAdaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #24
0
		public gradient_clamp_adaptor(IGradient gradient)
		{
			m_gradient = gradient;
		}
Пример #25
0
 public GradientRepeatAdaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConicalGradientBrush"/> class.
 /// </summary>
 /// <param name="center">The center point (as percentage in the range [0..1]).</param>
 /// <param name="origin">The origin (radian-angle) the brush is drawn to.</param>
 /// <param name="gradient">The gradient drawn by the brush.</param>
 public ConicalGradientBrush(PointF center, float origin, IGradient gradient)
 {
     this.Center   = center;
     this.Origin   = origin;
     this.Gradient = gradient;
 }
Пример #27
0
		public void gradient_function(IGradient gf)
		{
			m_gradient_function = gf;
		}
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
 /// </summary>
 /// <param name="center">The center point (as percentage in the range [0..1]).</param>
 /// <param name="gradient">The gradient drawn by the brush.</param>
 public RadialGradientBrush(PointF center, IGradient gradient)
 {
     this.Center = center;
     this.Gradient = gradient;
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConicalGradientBrush"/> class.
 /// </summary>
 /// <param name="center">The center point (as percentage in the range [0..1]).</param>
 /// <param name="gradient">The gradient drawn by the brush.</param>
 public ConicalGradientBrush(PointF center, IGradient gradient)
 {
     this.Center   = center;
     this.Gradient = gradient;
 }
Пример #30
0
 // default values for start/end are fine
 public AudioSpectrumBrush(IGradient gradient)
     : base(gradient)
 { }
Пример #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RadialGradientBrush"/> class.
 /// </summary>
 /// <param name="gradient">The gradient drawn by the brush.</param>
 public RadialGradientBrush(IGradient gradient)
 {
     this.Gradient = gradient;
 }
Пример #32
0
 public gradient_clamp_adaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #33
0
 public gradient_repeat_adaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #34
0
 public LinearGradientBrush(IGradient gradient)
 {
     this.Gradient = gradient;
 }
Пример #35
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new instance of the <see cref="T:RGB.NET.Brushes.LinearGradientBrush" /> class.
 /// </summary>
 /// <param name="startPoint">The start <see cref="T:RGB.NET.Core.Point" /> (as percentage in the range [0..1]).</param>
 /// <param name="endPoint">The end <see cref="T:RGB.NET.Core.Point" /> (as percentage in the range [0..1]).</param>
 /// <param name="gradient">The <see cref="T:RGB.NET.Brushes.Gradients.IGradient" /> drawn by this <see cref="T:RGB.NET.Brushes.LinearGradientBrush" />.</param>
 public LinearGradientBrush(Point startPoint, Point endPoint, IGradient gradient)
 {
     this.StartPoint = startPoint;
     this.EndPoint   = endPoint;
     this.Gradient   = gradient;
 }
Пример #36
0
 public void gradient_function(IGradient gf)
 {
     m_gradient_function = gf;
 }
Пример #37
0
 public gradient_reflect_adaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #38
0
 //--------------------------------------------------------------------
 public SpanGradient(ISpanInterpolator inter,
               IGradient gradient_function,
               IColorFunction color_function,
               double d1, double d2)
 {
     m_interpolator = inter;
     m_gradient_function = gradient_function;
     m_color_function = color_function;
     m_d1 = (Basics.Round(d1 * gradientSubpixelScale));
     m_d2 = (Basics.Round(d2 * gradientSubpixelScale));
 }
Пример #39
0
 public GradientClampAdaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #40
0
		public gradient_repeat_adaptor(IGradient gradient)
		{
			m_gradient = gradient;
		}
Пример #41
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new instance of the <see cref="T:RGB.NET.Brushes.LinearGradientBrush" /> class.
 /// </summary>
 /// <param name="gradient">The <see cref="T:RGB.NET.Brushes.Gradients.IGradient" /> drawn by this <see cref="T:RGB.NET.Brushes.LinearGradientBrush" />.</param>
 public LinearGradientBrush(IGradient gradient)
 {
     this.Gradient = gradient;
 }
Пример #42
0
 public GradientReflectAdaptor(IGradient gradient)
 {
     m_gradient = gradient;
 }
Пример #43
0
 public ColorProvider(IGradient gradient, double max, double min)
 {
     this.gradient = gradient;
     this.max      = max;
     this.min      = min;
 }
Пример #44
0
 public GradientRepeatAdaptor(IGradient gradient)
 {
     m_gradient= gradient;
 }
Пример #45
0
 public LinearGradientBrush(PointF startPoint, PointF endPoint, IGradient gradient)
 {
     this.StartPoint = startPoint;
     this.EndPoint = endPoint;
     this.Gradient = gradient;
 }
Пример #46
0
 // default values for start/end are fine
 public AudioSpectrumBrush(SoundDataProcessor soundDataProcessor, IGradient gradient)
     : base(gradient)
 {
     this._soundDataProcessor = soundDataProcessor;
 }