Пример #1
0
        protected override void DispatchDraw(Canvas canvas)
        {
            LinearGradient gradient;

            if (stack.Orientation == StackOrientation.Horizontal)
            {
                gradient = new LinearGradient(
                    0, 0, Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);
            }
            else
            {
                gradient = new LinearGradient(
                    0, 0, Height, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);
            }


            var paint = new Paint {
                Dither = true
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);

            base.DispatchDraw(canvas);
        }
Пример #2
0
        protected override void OnPaintSurface(SKPaintSurfaceEventArgs e)
        {
            base.OnPaintSurface(e);

            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            if (StartColor != Color.Transparent || EndColor != Color.Transparent)
            {
                var     colors     = new SKColor[] { StartColor.ToSKColor(), EndColor.ToSKColor() };
                SKPoint startPoint = new SKPoint(0, 0);
                SKPoint endPoint   = Horizontal ? new SKPoint(info.Width, 0) : new SKPoint(0, info.Height);

                var shader = SKShader.CreateLinearGradient(startPoint, endPoint, colors, null, SKShaderTileMode.Clamp);

                SKPaint paint = new SKPaint
                {
                    Style  = SKPaintStyle.Fill,
                    Shader = shader
                };

                canvas.DrawRect(new SKRect(0, 0, info.Width, info.Height), paint);
            }
        }
Пример #3
0
 public void setShader()
 {
     if (!parameters.Directional)
     {
         shader.SetTechnique("Billboard");
     }
     else
     {
         shader.SetTechnique("DirectionalBillboard");
         shader.Effect.GetVariableByName("startPosition").AsVector().Set(parameters.position);
     }
     shader.Effect.GetVariableByName("world").AsMatrix().SetMatrix(Matrix.Identity);
     shader.Effect.GetVariableByName("viewProjection").AsMatrix().SetMatrix(Matrix.Identity);
     shader.Effect.GetVariableByName("viewInverse").AsMatrix().SetMatrix(Matrix.Identity);
     shader.Effect.GetVariableByName("txDiffuse").AsResource().SetResource(texturePool.LoadTexture(parameters.texture));
     shader.Effect.GetVariableByName("size").AsScalar().Set(parameters.size);
     //effect parameter
     shader.Effect.GetVariableByName("timeTexture").AsResource().SetResource(timeTextureRSV);
     shader.Effect.GetVariableByName("width").AsScalar().Set(parameters.particleWidth);
     shader.Effect.GetVariableByName("height").AsScalar().Set(parameters.particleHeight);
     shader.Effect.GetVariableByName("widthEnd").AsScalar().Set(parameters.particleWidthEnd);
     shader.Effect.GetVariableByName("heightEnd").AsScalar().Set(parameters.particleHeightEnd);
     shader.Effect.GetVariableByName("startColor").AsVector().Set(new Color4(StartColor.ToVector3() * parameters.darkScale));
     shader.Effect.GetVariableByName("endColor").AsVector().Set(new Color4(EndColor.ToVector3() * parameters.darkScale));
     shader.Effect.GetVariableByName("oneOverTotalLifeTime").AsScalar().Set(1 / (parameters.MaxLifeTime));
     shader.Effect.GetVariableByName("uvStart").AsVector().Set(parameters.UvStart);
     shader.Effect.GetVariableByName("uvSize").AsVector().Set(parameters.UvSize);
     shader.Apply();
 }
 protected override SKShader CreateGradientShader(SKImageInfo info)
 {
     return(SKShader.CreateLinearGradient(
                new SKPoint(0, info.Height / 2),
                new SKPoint(info.Width / 2, info.Height / 2),
                new SKColor[] { StartColor.ToSKColor(), EndColor.ToSKColor() },
                new float[] { 0, 0.5f },
                SKShaderTileMode.Mirror));
 }
Пример #5
0
            public void Draw(GraphicsHandler graphics, bool stroke, FillMode fillMode, bool clip)
            {
                var outerRadius = Radius.Width;
                var yscale      = Radius.Height / Radius.Width;
                var center      = Center;
                var origin      = GradientOrigin;
                var scale       = 1f;
                var rect        = graphics.Control.GetPathBoundingBox().ToEto();

                if (stroke)
                {
                    graphics.Control.ReplacePathWithStrokedPath();
                }
                if (clip)
                {
                    graphics.Clip(fillMode);
                }

                if (wrap != GradientWrapMode.Pad)
                {
                    // use eto's transformrectangle as it'll make the rect encompass the resulting transformed area
                    var boundRect = transform.Invert().ToEto().TransformRectangle(rect);

                    // find max number of iterations we need to fill the bounding rectangle
                    scale = GradientHelper.GetRadialScale(Center, Radius, GradientOrigin, boundRect);
                }

                if (Gradient == null || scale > lastScale)
                {
                    var stops = GradientHelper.GetGradientStops(StartColor.ToCG(), EndColor.ToCG(), scale, wrap).ToList();
                    lastScale = scale;
                    Gradient  = new CGGradient(CGColorSpace.CreateDeviceRGB(), stops.Select(r => r.Item2).ToArray(), stops.Select(r => (nfloat)r.Item1).ToArray());
                }
                else
                {
                    scale = lastScale;
                }

                var scaledRect = new RectangleF(GradientOrigin - (GradientOrigin - Center + Radius) * scale, GradientOrigin + (Center + Radius - GradientOrigin) * scale);

                center       = scaledRect.Center;
                outerRadius *= scale;

                // adjust center based on ellipse scale from gradient origin
                center.Y = origin.Y - (origin.Y - center.Y) / yscale;

                // scale to draw elliptical gradient
                var t = new CGAffineTransform(1, 0f, 0f, yscale, 0, origin.Y - origin.Y * yscale);

                t.Multiply(transform);

                graphics.Control.SaveState();
                graphics.Control.ConcatCTM(t);
                graphics.Control.DrawRadialGradient(Gradient, origin.ToNS(), 0, center.ToNS(), outerRadius, CGGradientDrawingOptions.DrawsAfterEndLocation | CGGradientDrawingOptions.DrawsBeforeStartLocation);
                graphics.Control.RestoreState();
            }
Пример #6
0
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
        {
            global::Android.Graphics.LinearGradient gradient;

            var colors = new int[]
            {
                StartColor.ToAndroid().ToArgb(),
                EndColor.ToAndroid().ToArgb()
            };

            switch (Direction)
            {
            default:
            case GradientDirection.ToRight:
                gradient = new global::Android.Graphics.LinearGradient(0, 0, Width, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToLeft:
                gradient = new global::Android.Graphics.LinearGradient(Width, 0, 0, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToTop:
                gradient = new global::Android.Graphics.LinearGradient(0, Height, 0, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToBottom:
                gradient = new global::Android.Graphics.LinearGradient(0, 0, 0, Height, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToTopLeft:
                gradient = new global::Android.Graphics.LinearGradient(Width, Height, 0, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToTopRight:
                gradient = new global::Android.Graphics.LinearGradient(0, Height, Width, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToBottomLeft:
                gradient = new global::Android.Graphics.LinearGradient(Width, 0, 0, Height, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToBottomRight:
                gradient = new global::Android.Graphics.LinearGradient(0, 0, Width, Height, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;
            }

            var paint = new global::Android.Graphics.Paint()
            {
                Dither = true,
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);

            base.DispatchDraw(canvas);
        }
Пример #7
0
        protected override void DispatchDraw(Canvas canvas)
        {
            // Для вертикального: LinearGradien(0, 0, 0, Height, ...)
            var gradient = new LinearGradient(0, 0, Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);

            var paint = new Paint();

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Пример #8
0
 /// <summary>
 /// Gets a hash-code for this object based on current values.
 /// </summary>
 public override int GetHashCode()
 {
     return
         ((StartColor != null ? StartColor.GetHashCode() : 0) ^
          (EndColor != null ? EndColor.GetHashCode() : 0) ^
          (Texture != null ? Texture.GetHashCode() : 0) ^
          Angle.GetHashCode() ^
          Scale.GetHashCode() ^
          WrapMode.GetHashCode() ^
          BrushType.GetHashCode());
 }
Пример #9
0
        public override void Draw(CGRect rect)
        {
            CAGradientLayer gradient = new CAGradientLayer();

            gradient.Frame = NativeView.Bounds;
            gradient.NeedsDisplayOnBoundsChange = true;
            gradient.MasksToBounds = true;
            gradient.Colors        = new CGColor[] { StartColor.ToCGColor(), EndColor.ToCGColor() };
            NativeView.Layer.InsertSublayer(gradient, 0);
            base.Draw(rect);
        }
Пример #10
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            var newGradient = new ColorGradient(2);

            newGradient.ColorKeys[0] = new GradientColorKey(StartColor.GetFirstValue(mutable), 0);
            newGradient.ColorKeys[1] = new GradientColorKey(EndColor.GetFirstValue(mutable), 1);

            GradientTarget.SetValue(newGradient, mutable);

            return(mutable);
        }
Пример #11
0
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
        {
            var gradient = new Android.Graphics.LinearGradient(0, 0, this.Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Repeat);
            var paint    = new Android.Graphics.Paint()
            {
                Dither = true
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Пример #12
0
        public override void StartKinetic(VisualPayload payload, Func <float, float> translateTime)
        {
            var startColor = StartColor.GetFirstValue(payload.Data);
            var endColor   = EndColor.GetFirstValue(payload.Data);

            var transitionTimeInverse = 1f / TransitionTime.GetFirstValue(payload.Data);
            var startTime             = Time.time;


            var colorSatellite =
                payload.VisualData.Bound.gameObject.AddComponent <BoundMovementSatellite>();

            var newPayload = new VisualPayload(payload.Data, new VisualDescription(payload.VisualData.Bound));

            var materialsList =
                payload.VisualData.Bound.GetComponentsInChildren <Renderer>().Select(rend => rend.material).ToList();

            colorSatellite.MovementFunc = (trans) =>
            {
                float proportion = (Time.time - startTime) * transitionTimeInverse;

                if (proportion >= 1f)
                {
                    foreach (var mat in materialsList)
                    {
                        mat.color = endColor;
                    }

                    colorSatellite.Cleanup();
                    return;
                }

                proportion = translateTime(proportion);

                var toColor = Color.Lerp(startColor, endColor, proportion);

                foreach (var mat in materialsList)
                {
                    mat.color = toColor;
                }
            };

            colorSatellite.CleanupFunc = (trans) =>
            {
                JobManager.Instance.StartJob(
                    Finished.Transmit(newPayload), jobName: "Kinetic Finished", startImmediately: true,
                    maxExecutionsPerFrame: 1);
            };

            // execute first step immediately to set initial position
            colorSatellite.MovementFunc(colorSatellite.transform);
        }
Пример #13
0
        protected override void DispatchDraw(Canvas canvas)
        {
            Button button   = new Button();
            var    gradient = new LinearGradient(0, 0, Width, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);
            var    paint    = new Paint()
            {
                Dither = true,
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
        public void SetStartColor(Color color)
        {
            if (Application.isPlaying == false)
            {
                return;
            }

            if (this.startColor.minMaxState == MinMaxState.MaxColor)
            {
                var _color = this.ApplyColor(this.startColor.maxColor, color);
                this.particleSystem.startColor = _color;
                this.SetColor_PARTICLES(_color);
            }
        }
Пример #15
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            StartLifetime.Read(reader);
            StartSpeed.Read(reader);
            StartColor.Read(reader);
            StartSize.Read(reader);
            if (IsReadSizeAxes(reader.Version))
            {
                StartSizeY.Read(reader);
                StartSizeZ.Read(reader);
            }
            if (IsReadRotationAxes(reader.Version))
            {
                StartRotationX.Read(reader);
                StartRotationY.Read(reader);
            }
            StartRotation.Read(reader);

            if (IsReadRandomizeRotationDirection(reader.Version))
            {
                RandomizeRotationDirection = reader.ReadSingle();
            }
            if (IsReadGravityModifierSingle(reader.Version))
            {
                float gravityModifier = reader.ReadSingle();
                GravityModifier = new MinMaxCurve(gravityModifier);
            }
            if (IsReadInheritVelocity(reader.Version))
            {
                InheritVelocity = reader.ReadSingle();
            }
            MaxNumParticles = reader.ReadInt32();
            if (IsReadSize3D(reader.Version))
            {
                Size3D = reader.ReadBoolean();
            }
            if (IsReadRotation3D(reader.Version))
            {
                Rotation3D = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);
            }

            if (!IsReadGravityModifierSingle(reader.Version))
            {
                GravityModifier.Read(reader);
            }
        }
Пример #16
0
        public override void Read(AssetStream stream)
        {
            base.Read(stream);

            StartLifetime.Read(stream);
            StartSpeed.Read(stream);
            StartColor.Read(stream);
            StartSize.Read(stream);
            if (IsReadSizeAxes(stream.Version))
            {
                StartSizeY.Read(stream);
                StartSizeZ.Read(stream);
            }
            if (IsReadRotationAxes(stream.Version))
            {
                StartRotationX.Read(stream);
                StartRotationY.Read(stream);
            }
            StartRotation.Read(stream);

            if (IsReadRandomizeRotationDirection(stream.Version))
            {
                RandomizeRotationDirection = stream.ReadSingle();
            }
            if (IsReadGravityModifierSingle(stream.Version))
            {
                GravityModifierSingle = stream.ReadSingle();
            }
            if (IsReadInheritVelocity(stream.Version))
            {
                InheritVelocity = stream.ReadSingle();
            }
            MaxNumParticles = stream.ReadInt32();
            if (IsReadSize3D(stream.Version))
            {
                Size3D = stream.ReadBoolean();
            }
            if (IsReadRotation3D(stream.Version))
            {
                Rotation3D = stream.ReadBoolean();
                stream.AlignStream(AlignType.Align4);
            }

            if (!IsReadGravityModifierSingle(stream.Version))
            {
                GravityModifier.Read(stream);
            }
        }
Пример #17
0
        protected override void DispatchDraw(Android.Graphics.Canvas canvas)
        {
            var gradient = new Android.Graphics.LinearGradient(0, 0, 0, Height,
                                                               StartColor.ToAndroid(),
                                                               EndColor.ToAndroid(),
                                                               Android.Graphics.Shader.TileMode.Mirror);

            var paint = new Android.Graphics.Paint()
            {
                Dither = true,
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Пример #18
0
            public sd2.PathGradientBrush GetBrush(RectangleF rect)
            {
                var scale  = 1f;
                var bounds = rect;

                if (Matrix != null)
                {
                    bounds = Matrix.Inverse().TransformRectangle(bounds);
                }

                scale = GradientHelper.GetRadialScale(Center, Radius, GradientOrigin, bounds);

                if (brush == null || lastScale != scale)
                {
                    lastScale = scale;

                    var scaledRect = new RectangleF(GradientOrigin - (GradientOrigin - Center + Radius) * scale, GradientOrigin + (Center + Radius - GradientOrigin) * scale);

                    var path = new sd2.GraphicsPath();
                    path.AddEllipse(scaledRect.ToSD());

                    brush                = new sd2.PathGradientBrush(path);
                    brush.CenterColor    = StartColor.ToSD();
                    brush.CenterPoint    = GradientOrigin.ToSD();
                    brush.WrapMode       = wrapMode.ToSD();
                    brush.SurroundColors = new[] { EndColor.ToSD() };

                    if (Matrix != null)
                    {
                        brush.MultiplyTransform(Matrix.ToSD());
                    }

                    if (scale > 1f)
                    {
                        var paths = GradientHelper.GetGradientStops(StartColor.ToSD(), EndColor.ToSD(), scale, wrapMode);

                        brush.InterpolationColors = new sd2.ColorBlend
                        {
                            Positions = paths.Reverse().Select(r => 1f - r.Item1).ToArray(),
                            Colors    = paths.Reverse().Select(r => r.Item2).ToArray()
                        };
                    }
                }

                return(brush);
            }
        public void SetStartColor(Color minColor, Color maxColor)
        {
            if (Application.isPlaying == false)
            {
                return;
            }

            if (this.startColor.minMaxState == MinMaxState.MinMaxColor)
            {
                var _minColor = this.ApplyColor(this.startColor.minColor, minColor);
                var _maxColor = this.ApplyColor(this.startColor.maxColor, maxColor);

                this.SetColor_REFLECTION(this.particleSystem, "minColor", _minColor);
                this.particleSystem.startColor = _maxColor;
                this.SetColor_PARTICLES(Color.Lerp(_minColor, _maxColor, 0.5f));
            }
        }
Пример #20
0
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)

        {
            #region for Horizontal Gradient

            LinearGradient gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0,

                                                                          #endregion



                                                                          StartColor.ToAndroid(),

                                                                          EndColor.ToAndroid(),

                                                                          Android.Graphics.Shader.TileMode.Mirror);



            Paint paint = new Android.Graphics.Paint()

            {
                Dither = true,
            };

            float rx = _context.ToPixels(_cornerRadius);

            float ry = _context.ToPixels(_cornerRadius);

            RectF rect = new RectF(0, 0, Width, Height);

            Path path = new Path();

            path.AddRoundRect(rect, rx, ry, Path.Direction.Cw);



            paint.StrokeWidth = 5f;  //set outline stroke

            paint.SetShader(gradient);

            canvas.DrawPath(path, paint);

            base.DispatchDraw(canvas);
        }
Пример #21
0
        private void SetGradientBackground()
        {
            if (NavigationController != null)
            {
                var gradientLayer = new CAGradientLayer();
                gradientLayer.Bounds     = NavigationController.NavigationBar.Bounds;
                gradientLayer.Colors     = new CGColor[] { StartColor.ToCGColor(), EndColor.ToCGColor() };
                gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);

                UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
                gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
                UIImage image = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();

                NavigationController.NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
            }
        }
 void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
 {
     SKImageInfo info = args.Info;
     SKSurface surface = args.Surface;
     SKCanvas canvas = surface.Canvas;
     canvas.Clear();
     var colors = new SKColor[] { StartColor.ToSKColor(), EndColor.ToSKColor()};
     SKPoint startPoint = new SKPoint(0,0);
     SKPoint endPoint = Horizontal ? new SKPoint(info.Width, 0) : new SKPoint(0, info.Height);
     var shader = SKShader.CreateLinearGradient(startPoint, endPoint, colors, null, SKShaderTileMode.Clamp);
     SKPaint paint = new SKPaint
     {
         Style = SKPaintStyle.Fill,
         Shader = shader
     };
     
     canvas.DrawRect(new SKRect(0, 0, info.Width, info.Height), paint);
 }
Пример #23
0
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            var colors = new SKColor[] { StartColor.ToSKColor(), EndColor.ToSKColor() };

            using (SKPaint paint = new SKPaint())
            {
                // Createrectangle
                SKRect rect = new SKRect(0, 0, info.Width, info.Height);


                paint.Shader = SKShader.CreateLinearGradient(
                    new SKPoint(rect.Left, rect.Top),
                    new SKPoint(rect.Right, rect.Bottom),
                    colors,
                    null,
                    SKShaderTileMode.Clamp);

                // Draw the gradient on the rectangle
                canvas.DrawRect(rect, paint);
            }


            // Create linear gradient from upper-left to lower-right


            /*SKPoint startPoint = new SKPoint(0, 0);
             * SKPoint endPoint = Horizontal ? new SKPoint(info.Width, 0) : new SKPoint(0, info.Height);
             *
             * var shader = SKShader.CreateLinearGradient(startPoint, endPoint, colors, null, SKShaderTileMode.Clamp);
             *
             * SKPaint paint = new SKPaint
             * {
             *  Style = SKPaintStyle.Fill,
             *  Shader = shader
             * };
             *
             * canvas.DrawRect(new SKRect(0, 0, info.Width, info.Height), paint);*/
        }
Пример #24
0
 /// <summary>
 /// Create the gradient color for the border path
 /// If only start or end color is set no gradient will be used.
 /// </summary>
 private void CreateShader()
 {
     if (!GradientColor)
     {
         _paint.Color = StartColor.ToSKColor();
     }
     else
     {
         _paint.Shader = SKShader.CreateLinearGradient(
             start: new SKPoint(0, 0),
             end: new SKPoint(SkCanvasView.CanvasSize.Width, SkCanvasView.CanvasSize.Height),
             colors: new SKColor[] {
             ((Color)StartColor).ToSKColor(),
             ((Color)EndColor).ToSKColor()
         },
             colorPos: new float[] { 0, 1 },
             mode: SKShaderTileMode.Clamp);
     }
 }
Пример #25
0
        public void SetStartColor(Color color)
        {
            if (Application.isPlaying == false)
            {
                return;
            }

            if (this.startColor.minMaxState == MinMaxState.MaxColor)
            {
                var _color = this.ApplyColor(ref this.startColor.maxColor, color);
                                #if PARTICLESYSTEM_LEGACY
                this.particleSystem.startColor = _color;
                                #else
                var main = this.particleSystem.main;
                main.startColor = new ParticleSystem.MinMaxGradient(_color);
                                #endif
                this.SetColor_PARTICLES(_color);
            }
        }
Пример #26
0
 protected override sd.Brush Create(sd.RenderTarget target)
 {
     return(new sd.LinearGradientBrush(
                target,
                new sd.LinearGradientBrushProperties
     {
         StartPoint = StartPoint.ToDx(),
         EndPoint = EndPoint.ToDx()
     },
                new sd.GradientStopCollection(GraphicsHandler.CurrentRenderTarget, new[] {
         new sd.GradientStop {
             Color = StartColor.ToDx(), Position = 0f
         },
         new sd.GradientStop {
             Color = EndColor.ToDx(), Position = 1f
         }
     }, WrapMode.ToDx())
                ));
 }
        protected override void DispatchDraw(Android.Graphics.Canvas canvas)
        {
            var gradient =
                Direction == GredientBoxViewDirection.TopToBottom ?
                new Android.Graphics.LinearGradient(0, 0, 0, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                Direction == GredientBoxViewDirection.LeftToRight ?
                new Android.Graphics.LinearGradient(0, 0, Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                Direction == GredientBoxViewDirection.TopLeftToBottomRight ?
                new Android.Graphics.LinearGradient(0, 0, Width, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                Direction == GredientBoxViewDirection.TopRightToBottomLeft ?
                new Android.Graphics.LinearGradient(0, Width, 0, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                null;
            var paint = new Android.Graphics.Paint {
                Dither = true
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Пример #28
0
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
        {
            #region for Vertical Gradient
            var gradient = new Android.Graphics.LinearGradient(0, 0, 0, Height,
                                                               #endregion
                                                               #region for Horizontal Gradient
                                                               //Android.Graphics.LinearGradient gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0,
                                                               #endregion
                                                               StartColor.ToAndroid(),
                                                               EndColor.ToAndroid(),
                                                               Android.Graphics.Shader.TileMode.Mirror);

            Android.Graphics.Paint paint = new Android.Graphics.Paint()
            {
                Dither = true,
            };
            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Пример #29
0
        private void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            try
            {
                SKImageInfo info    = args.Info;
                SKSurface   surface = args.Surface;
                SKCanvas    canvas  = surface.Canvas;

                canvas.Clear();

                var startPoint = new SKPoint(0, 0);
                var endPoint   = new SKPoint(info.Width, info.Height);

                SKColor[] colors;
                SKShader  shader;

                if (HasGradientStartInset)
                {
                    colors = new SKColor[] { StartColor.ToSKColor(), StartColor.ToSKColor(), EndColor.ToSKColor() };
                    shader = SKShader.CreateLinearGradient(startPoint, endPoint, colors, new float[] { 0, GradientStartInsetPercent, 1 }, SKShaderTileMode.Clamp);
                }
                else
                {
                    colors = new SKColor[] { StartColor.ToSKColor(), EndColor.ToSKColor() };
                    shader = SKShader.CreateLinearGradient(startPoint, endPoint, colors, null, SKShaderTileMode.Clamp);
                }

                var mainPaint = new SKPaint
                {
                    Style  = SKPaintStyle.Fill,
                    Shader = shader
                };

                canvas.DrawRect(new SKRect(startPoint.X, startPoint.Y, endPoint.X, endPoint.Y), mainPaint);
            }
            catch (Exception ex)
            {
                // Don't crash for a pretty effect
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
Пример #30
0
        public override YAMLNode ExportYAML(IAssetsExporter exporter)
        {
#warning TODO: values acording to read version (current 2017.3.0f3)
            YAMLMappingNode node = (YAMLMappingNode)base.ExportYAML(exporter);
            node.InsertSerializedVersion(GetSerializedVersion(exporter.Version));
            node.Add("startLifetime", StartLifetime.ExportYAML(exporter));
            node.Add("startSpeed", StartSpeed.ExportYAML(exporter));
            node.Add("startColor", StartColor.ExportYAML(exporter));
            node.Add("startSize", StartSize.ExportYAML(exporter));
            node.Add("startSizeY", StartSizeY.ExportYAML(exporter));
            node.Add("startSizeZ", StartSizeZ.ExportYAML(exporter));
            node.Add("startRotationX", StartRotationX.ExportYAML(exporter));
            node.Add("startRotationY", StartRotationY.ExportYAML(exporter));
            node.Add("startRotation", StartRotation.ExportYAML(exporter));
            node.Add("randomizeRotationDirection", RandomizeRotationDirection);
            node.Add("maxNumParticles", MaxNumParticles);
            node.Add("size3D", Size3D);
            node.Add("rotation3D", Rotation3D);
            node.Add("gravityModifier", GravityModifier.ExportYAML(exporter));
            return(node);
        }
		public void SetStartColor(Color color) {

			if (Application.isPlaying == false) return;

			if (this.startColor.minMaxState == MinMaxState.MaxColor) {

				var _color = this.ApplyColor(ref this.startColor.maxColor, color);
                this.particleSystem.startColor = _color;
				this.SetColor_PARTICLES(_color);

			}

		}
		public void SetStartColor(Color minColor, Color maxColor) {

			if (Application.isPlaying == false) return;

			if (this.startColor.minMaxState == MinMaxState.MinMaxColor) {

				var _minColor = this.ApplyColor(ref this.startColor.minColor, minColor);
				var _maxColor = this.ApplyColor(ref this.startColor.maxColor, maxColor);

				this.SetColor_REFLECTION(this.particleSystem, "minColor", _minColor);
				this.particleSystem.startColor = _maxColor;
				this.SetColor_PARTICLES(Color.Lerp(_minColor, _maxColor, 0.5f));

			}

		}