コード例 #1
0
ファイル: RectangleBrushes.cs プロジェクト: drmason789/nplot
            /// <summary>
            /// Gets a brush according to the supplied rectangle.
            /// </summary>
            /// <param name="rectangle">the rectangle used to construct the brush</param>
            /// <returns>The vertical center fade brush</returns>
            public IBrush Get(Rectangle rectangle)
            {
                ILinearGradientBrush brush = Factory.Instance.CreateLinearGradientBrush(rectangle, c1_, c2_, LinearGradientMode.Vertical);

                float[] relativeIntensities = { 0.0f, 0.9f, 1.0f, 0.9f, 0.0f };
                float[] relativePositions   = { 0.0f, 0.4f, 0.5f, 0.6f, 1.0f };
                IBlend  blend = Factory.Instance.CreateBlend();

                blend.Factors   = relativeIntensities;
                blend.Positions = relativePositions;
                brush.Blend     = blend;
                return(brush);
            }
コード例 #2
0
        public LinearGradientBrushImpl(ILinearGradientBrush brush, Size destinationSize)
        {
            var start = brush.StartPoint.ToPixels(destinationSize);
            var end   = brush.EndPoint.ToPixels(destinationSize);

            this.PlatformBrush = new LinearGradient(start.X, start.Y, end.X, end.Y);

            foreach (var stop in brush.GradientStops)
            {
                ((LinearGradient)this.PlatformBrush).AddColorStop(stop.Offset, stop.Color.ToCairo());
            }

            ((LinearGradient)this.PlatformBrush).Extend = Extend.Pad;
        }
コード例 #3
0
        public LinearGradientBrushImpl(
            ILinearGradientBrush brush,
            SharpDX.Direct2D1.RenderTarget target,
            Rect destinationRect)
        {
            if (brush.GradientStops.Count == 0)
            {
                return;
            }

            var gradientStops = brush.GradientStops.Select(s => new SharpDX.Direct2D1.GradientStop
            {
                Color    = s.Color.ToDirect2D(),
                Position = (float)s.Offset
            }).ToArray();

            var position   = destinationRect.Position;
            var startPoint = position + brush.StartPoint.ToPixels(destinationRect.Size);
            var endPoint   = position + brush.EndPoint.ToPixels(destinationRect.Size);

            using (var stops = new SharpDX.Direct2D1.GradientStopCollection(
                       target,
                       gradientStops,
                       brush.SpreadMethod.ToDirect2D()))
            {
                PlatformBrush = new SharpDX.Direct2D1.LinearGradientBrush(
                    target,
                    new SharpDX.Direct2D1.LinearGradientBrushProperties
                {
                    StartPoint = startPoint.ToSharpDX(),
                    EndPoint   = endPoint.ToSharpDX()
                },
                    new SharpDX.Direct2D1.BrushProperties
                {
                    Opacity   = (float)brush.Opacity,
                    Transform = PrimitiveExtensions.Matrix3x2Identity,
                },
                    stops);
            }
        }
コード例 #4
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class with a given <paramref name="rectangle"/> and <paramref name="angle"/>
		/// </summary>
		/// <param name="rectangle">Rectangle to define the area of the gradient</param>
		/// <param name="startColor">Start color for the gradient</param>
		/// <param name="endColor">End color for the gradient</param>
		/// <param name="angle">Angle of the gradient</param>
		/// <param name="generator">Generator to create the brush, or null to use the current generator</param>
		public LinearGradientBrush (RectangleF rectangle, Color startColor, Color endColor, float angle, Generator generator = null)
		{
			handler = generator.CreateShared<ILinearGradientBrush> ();
			ControlObject = handler.Create (rectangle, startColor, endColor, angle);
		}
コード例 #5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class between two points
		/// </summary>
		/// <param name="startColor">Start color for the gradient</param>
		/// <param name="endColor">End color for the gradient</param>
		/// <param name="startPoint">Start point for the gradient</param>
		/// <param name="endPoint">End point for the gradient</param>
		/// <param name="generator">Generator to create the brush, or null to use the current generator</param>
		public LinearGradientBrush (Color startColor, Color endColor, PointF startPoint, PointF endPoint, Generator generator = null)
		{
			handler = generator.CreateShared<ILinearGradientBrush> ();
			ControlObject = handler.Create (startColor, endColor, startPoint, endPoint);
		}
コード例 #6
0
		LinearGradientBrush (ILinearGradientBrush handler, object control)
		{
			this.handler = handler;
			ControlObject = control;
		}
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableLinearGradientBrush"/> class.
 /// </summary>
 /// <param name="source">The brush from which this brush's properties should be copied.</param>
 public ImmutableLinearGradientBrush(ILinearGradientBrush source)
     : base(source)
 {
     StartPoint = source.StartPoint;
     EndPoint   = source.EndPoint;
 }
コード例 #8
0
ファイル: LinearGradientBrush.cs プロジェクト: sami1971/Eto
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class with a given <paramref name="rectangle"/> and <paramref name="angle"/>
 /// </summary>
 /// <param name="rectangle">Rectangle to define the area of the gradient</param>
 /// <param name="startColor">Start color for the gradient</param>
 /// <param name="endColor">End color for the gradient</param>
 /// <param name="angle">Angle of the gradient</param>
 /// <param name="generator">Generator to create the brush, or null to use the current generator</param>
 public LinearGradientBrush(RectangleF rectangle, Color startColor, Color endColor, float angle, Generator generator = null)
 {
     handler       = generator.CreateShared <ILinearGradientBrush> ();
     ControlObject = handler.Create(rectangle, startColor, endColor, angle);
 }
コード例 #9
0
ファイル: LinearGradientBrush.cs プロジェクト: sami1971/Eto
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class between two points
 /// </summary>
 /// <param name="startColor">Start color for the gradient</param>
 /// <param name="endColor">End color for the gradient</param>
 /// <param name="startPoint">Start point for the gradient</param>
 /// <param name="endPoint">End point for the gradient</param>
 /// <param name="generator">Generator to create the brush, or null to use the current generator</param>
 public LinearGradientBrush(Color startColor, Color endColor, PointF startPoint, PointF endPoint, Generator generator = null)
 {
     handler       = generator.CreateShared <ILinearGradientBrush> ();
     ControlObject = handler.Create(startColor, endColor, startPoint, endPoint);
 }
コード例 #10
0
ファイル: LinearGradientBrush.cs プロジェクト: sami1971/Eto
 LinearGradientBrush(ILinearGradientBrush handler, object control)
 {
     this.handler  = handler;
     ControlObject = control;
 }
コード例 #11
0
 public static ILinearGradientBrush CreateRef(this ILinearGradientBrush objectRef) =>
 ((ILinearGradientBrush)objectRef.CreateRef(typeof(ILinearGradientBrush)));