Exemple #1
0
        public void SetRadialGradientPaint(APaint platformPaint, RadialGradientPaint radialGradientPaint)
        {
            var   center  = radialGradientPaint.Center;
            float centerX = (float)center.X;
            float centerY = (float)center.Y;
            float radius  = (float)radialGradientPaint.Radius;

            var gradientData       = GetGradientPaintData(radialGradientPaint);
            var radialGradientData = new RadialGradientData(gradientData.Colors, gradientData.Offsets, centerX, centerY, radius);

            if (_width == 0 && _height == 0)
            {
                return;
            }

            if (radialGradientData.Colors == null || radialGradientData.Colors.Length < 2)
            {
                return;
            }

            var radialGradient = new RadialGradient(
                _width * radialGradientData.CenterX,
                _height * radialGradientData.CenterY,
                Math.Max(_height, _width) * radialGradientData.Radius,
                radialGradientData.Colors,
                radialGradientData.Offsets,
                Shader.TileMode.Clamp !);

            platformPaint.SetShader(radialGradient);
        }
        public void SetPaint(RadialGradientPaint radialGradientPaint)
        {
            var   center  = radialGradientPaint.Center;
            float centerX = (float)center.X;
            float centerY = (float)center.Y;
            float radius  = (float)radialGradientPaint.Radius;

            var data   = GetGradientPaintData(radialGradientPaint);
            var shader = new RadialGradientData(data.Colors, data.Offsets, centerX, centerY, radius);

            _backgroundColor = null;
            SetShaderFactory(new RadialGradientShaderFactory(shader));
        }
		internal static RadialGradientShaderFactory GetRadialGradientShaderFactory(RadialGradientPaint radialGradientPaint, float alpha = 1.0f)
		{
			var center = radialGradientPaint.Center;
			float centerX = (float)center.X;
			float centerY = (float)center.Y;
			float radius = (float)radialGradientPaint.Radius;

			var data = GetGradientPaintData(radialGradientPaint, alpha);
			var shader = new RadialGradientData(data.Colors, data.Offsets, centerX, centerY, radius);

			var radialGradientShaderFactory = new RadialGradientShaderFactory(shader);
			return radialGradientShaderFactory;
		}
        internal static RadialGradientShaderFactory GetRadialGradientShaderFactory(RadialGradientPaint radialGradientPaint)
        {
            var   center  = radialGradientPaint.Center;
            float centerX = (float)center.X;
            float centerY = (float)center.Y;
            float radius  = (float)radialGradientPaint.Radius;

            var data   = PaintExtensions.GetGradientPaintData(radialGradientPaint);
            var shader = new RadialGradientData(data.Colors, data.Offsets, centerX, centerY, radius);

            var radialGradientShaderFactory = new RadialGradientShaderFactory(shader);

            return(radialGradientShaderFactory);
        }
 public RadialGradientShaderFactory(RadialGradientData data)
 {
     _data = data;
 }