Inheritance: Pinta.Core.UserBlendOp
Exemplo n.º 1
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            base.OnMouseMove (o, args, point);
            if (tracking) {

                UserBlendOps.NormalBlendOp normalBlendOp = new UserBlendOps.NormalBlendOp();
                GradientRenderer gr = null;
                switch (GradientType) {
                    case eGradientType.Linear:
                        gr = new GradientRenderers.LinearClamped (GradientColorMode  == eGradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.LinearReflected:
                        gr = new GradientRenderers.LinearReflected (GradientColorMode  == eGradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Radial:
                        gr = new GradientRenderers.Radial (GradientColorMode  == eGradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Diamond:
                        gr = new GradientRenderers.LinearDiamond (GradientColorMode  == eGradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Conical:
                        gr = new GradientRenderers.Conical (GradientColorMode  == eGradientColorMode.Transparency, normalBlendOp);
                    break;
                }
                if (button == 3) {//right
                    gr.StartColor = PintaCore.Palette.SecondaryColor.ToColorBgra ();
                    gr.EndColor = PintaCore.Palette.PrimaryColor.ToColorBgra ();
                }
                else {//1 left
                    gr.StartColor = PintaCore.Palette.PrimaryColor.ToColorBgra ();
                    gr.EndColor = PintaCore.Palette.SecondaryColor.ToColorBgra ();
                }

                gr.StartPoint = startpoint;
                gr.EndPoint = point;
                gr.AlphaBlending = UseAlphaBlending;

                gr.BeforeRender ();
                gr.Render (PintaCore.Layers.CurrentLayer.Surface, new Gdk.Rectangle[] {PintaCore.Layers.SelectionPath.GetBounds ()});
                PintaCore.Workspace.Invalidate ();
            }
        }
Exemplo n.º 2
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            base.OnMouseMove (o, args, point);
            if (tracking) {

                UserBlendOps.NormalBlendOp normalBlendOp = new UserBlendOps.NormalBlendOp();
                GradientRenderer gr = null;
                switch (GradientType) {
                    case eGradientType.Linear:
                        gr = new GradientRenderers.LinearClamped (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.LinearReflected:
                        gr = new GradientRenderers.LinearReflected (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Radial:
                        gr = new GradientRenderers.Radial (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Diamond:
                        gr = new GradientRenderers.LinearDiamond (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Conical:
                        gr = new GradientRenderers.Conical (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                }
                if (button == 3) {//right
                    gr.StartColor = PintaCore.Palette.SecondaryColor.ToColorBgra ();
                    gr.EndColor = PintaCore.Palette.PrimaryColor.ToColorBgra ();
                }
                else {//1 left
                    gr.StartColor = PintaCore.Palette.PrimaryColor.ToColorBgra ();
                    gr.EndColor = PintaCore.Palette.SecondaryColor.ToColorBgra ();
                }

                gr.StartPoint = startpoint;
                gr.EndPoint = point;
                gr.AlphaBlending = UseAlphaBlending;

                gr.BeforeRender ();

                Gdk.Rectangle selection_bounds = PintaCore.Layers.SelectionPath.GetBounds ();
                ImageSurface scratch_layer = PintaCore.Layers.ToolLayer.Surface;

                gr.Render (scratch_layer, new Gdk.Rectangle[] { selection_bounds });

                using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
                    g.AppendPath (PintaCore.Layers.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.Clip ();

                    g.SetSource (scratch_layer);
                    g.Paint ();
                }

                selection_bounds.Inflate (5, 5);
                PintaCore.Workspace.Invalidate (selection_bounds);
            }
        }
Exemplo n.º 3
0
        private GradientRenderer CreateGradientRenderer()
        {
            var normalBlendOp = new UserBlendOps.NormalBlendOp ();
            bool alpha_only = SelectedGradientColorMode == GradientColorMode.Transparency;

            switch (SelectedGradientType) {
                case GradientType.Linear:
                    return new GradientRenderers.LinearClamped (alpha_only, normalBlendOp);
                case GradientType.LinearReflected:
                    return new GradientRenderers.LinearReflected (alpha_only, normalBlendOp);
                case GradientType.Radial:
                    return new GradientRenderers.Radial (alpha_only, normalBlendOp);
                case GradientType.Diamond:
                    return new GradientRenderers.LinearDiamond (alpha_only, normalBlendOp);
                case GradientType.Conical:
                    return new GradientRenderers.Conical (alpha_only, normalBlendOp);
            }

            throw new ArgumentOutOfRangeException ("Unknown gradient type.");
        }