ClosePath() public method

public ClosePath ( ) : void
return void
Ejemplo n.º 1
0
        //system top
        public void SystemTop(Cairo.Context g, Int32 width)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(5, 5); p2 = new PointD(width, 5); s1 = new PointD(width + 2, 7); s2 = new PointD(width + 2, 28);
            p3 = new PointD(width, 30); p4 = new PointD(5, 30); s3 = new PointD(3, 28); s4 = new PointD(3, 7);

            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.MoveTo(p1); g.LineTo(p2);  g.LineTo(s1);  g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 60);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6));
            pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1));
            g.Pattern = pat;
            g.FillPreserve();

            g.SetFontSize(17);
            g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold);
            g.MoveTo(new PointD(12, 23));
            g.Color = new Color(1, 1, 1, 1);
            g.ShowText("General system information");

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Ejemplo n.º 2
0
    static void draw(Cairo.Context gr, int width, int height)
    {
        gr.Scale(width, height);
        gr.LineWidth = 0.04;

        gr.MoveTo(new PointD(0.5, 0.1));
        gr.LineTo(new PointD(0.9, 0.9));
        gr.RelLineTo(new Distance(-0.4, 0.0));
        gr.CurveTo(new PointD(0.2, 0.9),
                   new PointD(0.2, 0.5),
                   new PointD(0.5, 0.5)
                   );
        gr.ClosePath();

        gr.MoveTo(new PointD(0.25, 0.1));
        gr.RelLineTo(new Distance(0.2, 0.2));
        gr.RelLineTo(new Distance(-0.2, 0.2));
        gr.RelLineTo(new Distance(-0.2, -0.2));
        gr.ClosePath();

        gr.Color = new Color(0, 0, 1, 1);
        gr.FillPreserve();
        gr.Color = new Color(0, 0, 0, 1);
        gr.Stroke();
    }
Ejemplo n.º 3
0
        //intro top Welcome
        public void IntroTop(Cairo.Context g, Int32 width)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(10, 10); p2 = new PointD(width, 10); s1 = new PointD(width + 2, 12); s2 = new PointD(width + 2, 38);
            p3 = new PointD(width, 40); p4 = new PointD(10, 40); s3 = new PointD(8, 38); s4 = new PointD(8, 12);

            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2);  g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 80);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6));
            pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1));
            g.Pattern = pat; g.FillPreserve();

            g.SetFontSize(22);
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold);
            g.MoveTo(new PointD(22, 33));
            g.Color = new Color(1, 1, 1, 1);
            g.ShowText("Welcome to");

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Ejemplo n.º 4
0
        void DrawButtonTabs(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                cr.NewPath();
                double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5;
                cr.MoveTo(x, rectangle.Y + 0.5 + 2);
                cr.RelLineTo(0, rectangle.Height - 1 - 4);
                cr.ClosePath();
                cr.Color     = (HslColor)parent.Style.Dark(StateType.Normal);
                cr.LineWidth = 1;
                cr.Stroke();
                return;
            }

            int topPadding = 2;

            if (Active || HoverPosition.X >= 0)
            {
                cr.NewPath();
                cr.Rectangle(rectangle.X + 0.5, rectangle.Y + 0.5 + topPadding, rectangle.Width - 1, rectangle.Height - topPadding);
                cr.ClosePath();
                if (Active)
                {
                    cr.Color = (HslColor)parent.Style.Background(StateType.Prelight);
                }
                else if (HoverPosition.X >= 0)
                {
                    double rx = rectangle.X + HoverPosition.X;
                    double ry = rectangle.Y + HoverPosition.Y;
                    Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, rectangle.Height * 1.5,
                                                                             rx, ry, 2);
                    var color = (HslColor)parent.Style.Dark(StateType.Normal);
                    color.L *= 1.1;
                    gradient.AddColorStop(0, color);
                    color.L *= 1.1;
                    gradient.AddColorStop(1, color);
                    cr.Pattern = gradient;
                }
                if (!Active)
                {
                    cr.Fill();
                }
                else
                {
                    cr.FillPreserve();
                    cr.Color     = (HslColor)parent.Style.Dark(StateType.Normal);
                    cr.LineWidth = 1;
                    cr.Stroke();
                }
            }

            cr.Save();
            cr.Translate(rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2 + topPadding);
            cr.Color = (HslColor)parent.Style.Text(StateType.Normal);

            cr.ShowLayout(layout);

            cr.Restore();
        }
        protected void DrawSmallCovers(Cairo.Context context, float width, float height, double lwidth)
        {
            context.Save();

            double hlwidth = lwidth * 0.5;

            context.MoveTo(hlwidth, height - hlwidth);
            context.LineTo(hlwidth, 0.3 * (height - lwidth));
            context.LineTo((width - lwidth) * 0.65, hlwidth);
            context.LineTo((width - lwidth) * 0.65, 0.7 * (height - lwidth));
            context.ClosePath();
            context.LineWidth = lwidth;
            context.SetSourceRGBA(0.1, 0.1, 0.1, 1.0);
            context.FillPreserve();
            context.SetSourceRGBA(1.0, 1.0, 1.0, 0.7);
            context.Stroke();
            context.Translate((4 + hlwidth), 0);
            context.MoveTo(hlwidth, height - hlwidth);
            context.LineTo(hlwidth, 0.3 * (height - lwidth));
            context.LineTo((width - lwidth) * 0.65, hlwidth);
            context.LineTo((width - lwidth) * 0.65, 0.7 * (height - lwidth));
            context.ClosePath();
            context.SetSourceRGBA(0.1, 0.1, 0.1, 1.0);
            context.FillPreserve();
            context.SetSourceRGBA(1.0, 1.0, 1.0, 0.7);
            context.Stroke();
            context.Translate(-(4 + hlwidth), 0);

            context.Restore();
        }
Ejemplo n.º 6
0
        //intro bottom tips
        public void IntroBottom(Cairo.Context g)
        {
            PointD p1, p2, p3, p4, s1, s2, s3, s4;

            p1 = new PointD(30, 10); p2 = new PointD(420, 10); s1 = new PointD(422, 12); s2 = new PointD(422, 88);
            p3 = new PointD(420, 90); p4 = new PointD(30, 90); s3 = new PointD(28, 88); s4 = new PointD(28, 12);

            g.Color = new Color(0.3, 0.4, 0.6, 0.8);
            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath(); g.LineWidth = 1; g.Stroke();

            g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1);
            g.ClosePath();

            Cairo.Gradient pat = new Cairo.LinearGradient(80, 20, 80, 80);
            pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0));
            pat.AddColorStop(1, new Cairo.Color(0.3, 0.4, 0.6, 0.3));
            g.Pattern = pat;
            g.FillPreserve();


            g.Color = new Color(0, 0, 0, 0.8);
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold);
            g.SetFontSize(18);
            g.MoveTo(new PointD(88, 28));
            g.ShowText(".");
            g.MoveTo(new PointD(88, 58));
            g.ShowText(".");
            g.SelectFontFace("", FontSlant.Italic, FontWeight.Normal);
            g.SetFontSize(10);
            g.MoveTo(new PointD(98, 30));
            g.ShowText("Use the navigation on the left to choose different categories");
            g.MoveTo(new PointD(98, 42));
            g.ShowText("of your computer and system information to display.");
            g.MoveTo(new PointD(98, 60));
            g.ShowText("When you click on a category in the navigation, the dynamic");
            g.MoveTo(new PointD(98, 72));
            g.ShowText("information is automatically refreshed.");

            g.MoveTo(new PointD(38, 35));
            g.Color = new Color(0.3, 0.4, 0.6, 1);
            g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(18);
            g.ShowText("Tips");

            g.NewPath();

            /*
             * g.Color = new Color (0.3, 0.4, 0.6, 0.8);
             * g.Scale (34, 34);
             * g.LineWidth = 0.06;
             * g.Arc (1.0, 1.0, 0.6, 0, 360);
             * g.Stroke ();*/

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Ejemplo n.º 7
0
    //http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/cookbook/
    private static void drawRoundedRectangle(double x, double y, double width, double height,
                                             double radius, Cairo.Context g, Cairo.Color color)
    {
        g.Save();

        if ((radius > height / 2) || (radius > width / 2))
        {
            radius = min(height / 2, width / 2);
        }

        g.MoveTo(x, y + radius);
        g.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
        g.LineTo(x + width - radius, y);
        g.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
        g.LineTo(x + width, y + height - radius);
        g.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
        g.LineTo(x + radius, y + height);
        g.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
        g.ClosePath();
        g.Restore();

        g.SetSourceRGB(color.R, color.G, color.B);
        g.FillPreserve();
        g.SetSourceRGB(0, 0, 0);
        g.LineWidth = 2;
        g.Stroke();
    }
Ejemplo n.º 8
0
        protected void UpdateTexture ()
        {
            text.SetSurfaceSize ((uint) (Width+MarginX),(uint) (Height+MarginY));
            text.Clear ();
            Cairo.Context context = text.Create ();

            double lwidth = 1;
            double hlwidth = lwidth*0.5;
            double width = Width - lwidth;
            double height = Height - lwidth;
            double radius = Math.Min(marginX, marginY)*0.75;

            if ((radius > height / 2) || (radius > width / 2))
                radius = Math.Min(height / 2, width / 2);

            context.MoveTo (hlwidth, hlwidth + radius);
            context.Arc (hlwidth + radius, hlwidth + radius, radius, Math.PI, -Math.PI / 2);
            context.LineTo (hlwidth + width - radius, hlwidth);
            context.Arc (hlwidth + width - radius, hlwidth + radius, radius, -Math.PI / 2, 0);
            context.LineTo (hlwidth + width, hlwidth + height - radius);
            context.Arc (hlwidth + width - radius, hlwidth + height - radius, radius, 0, Math.PI / 2);
            context.LineTo (hlwidth + radius, hlwidth + height);
            context.Arc (hlwidth + radius, hlwidth + height - radius, radius, Math.PI / 2, Math.PI);
            context.ClosePath ();

            context.LineWidth = lwidth;
            context.SetSourceRGB (1.0,1.0,1.0);
            context.Stroke ();

            ((IDisposable) context.Target).Dispose ();
            ((IDisposable) context).Dispose ();
        }
        protected override void CreatePassiveTexture(Clutter.CairoTexture texture, int with_state)
        {
            texture.Clear();
            Cairo.Context context = texture.Create();

            double lwidth  = 1;
            double hlwidth = lwidth * 0.5;

            //Draw outline rectangles:
            DrawSmallCovers(context, texture.Width, texture.Height, lwidth);

            //Draw play icon:
            context.MoveTo((texture.Width - lwidth) * 0.5, 0.3 * (texture.Height - lwidth));
            context.LineTo((texture.Width - lwidth) * 0.5, texture.Height - hlwidth);
            context.LineTo(texture.Width - hlwidth, 0.65 * (texture.Height - lwidth));
            context.ClosePath();
            context.LineWidth = lwidth;
            double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8));

            context.SetSourceRGBA(sat, sat, sat, 1.0);
            context.FillPreserve();
            context.SetSourceRGB(1.0, 1.0, 1.0);
            context.Stroke();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
Ejemplo n.º 10
0
        public void Draw(Gdk.Drawable d)
        {
            if (!Visible)
            {
                return;
            }

            Gdk.GC        gc = new Gdk.GC(d);
            Cairo.Context g  = Gdk.CairoHelper.Create(d);

            d.DrawPixbuf(gc, _background, 0, 0, _x, _y, _w, _h, Gdk.RgbDither.None, 0, 0);

            int x0 = _x, x1 = _x + _w;
            int y0 = _y, y1 = _y + _h;

            g.MoveTo(x0 + 3, y0);
            g.LineTo(x1 - 3, y0);
            g.LineTo(x1, y0 + 3);
            g.LineTo(x1, y1 - 3);
            g.LineTo(x1 - 3, y1);
            g.LineTo(x0 + 3, y1);
            g.LineTo(x0, y1 - 3);
            g.LineTo(x0, y0 + 3);
            g.LineTo(x0 + 3, y0);
            g.ClosePath();
            g.LineWidth = 6;
            g.Color     = new Color(0.8, 0.8, 0.8, _opaque ? 1 : 0.6);
            g.Stroke();

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();

            DrawContents(d);
        }
Ejemplo n.º 11
0
        private void DrawGrid(Cairo.Context g)
        {
            if (daysInMonth < 28 && daysInMonth > 32)
            {
                return;
            }

            g.SetSourceRGB(0, 0, 0);
            for (int i = 0; i <= totalColums; i++)
            {
                PointD pTop = new PointD(cellWidth * i, 0);
                PointD pBot = new PointD(cellWidth * i, tableHeight);

                g.MoveTo(pTop);
                g.LineTo(pBot);
            }
            for (int i = 0; i <= totalRows; i++)
            {
                PointD pTop = new PointD(0, cellHeight * i);
                PointD pBot = new PointD(tableWidth, cellHeight * i);

                g.MoveTo(pTop);
                g.LineTo(pBot);
            }
            g.ClosePath();
            g.Stroke();
        }
Ejemplo n.º 12
0
        private void DrawShape(Cairo.Context g, int width, int height)
        {
            int inner_x = radius + border + inner;
            int cx      = Center.X;
            int cy      = Center.Y;

            g.Operator = Operator.Source;
            g.Source   = new SolidPattern(new Cairo.Color(0, 0, 0, 0));
            g.Rectangle(0, 0, width, height);
            g.Paint();

            g.NewPath();
            g.Translate(cx, cy);
            g.Rotate(angle);

            g.Source   = new SolidPattern(new Cairo.Color(0.2, 0.2, 0.2, .6));
            g.Operator = Operator.Over;
            g.Rectangle(0, -(border + inner), inner_x, 2 * (border + inner));
            g.Arc(inner_x, 0, inner + border, 0, 2 * Math.PI);
            g.Arc(0, 0, radius + border, 0, 2 * Math.PI);
            g.Fill();

            g.Source   = new SolidPattern(new Cairo.Color(0, 0, 0, 1.0));
            g.Operator = Operator.DestOut;
            g.Arc(inner_x, 0, inner, 0, 2 * Math.PI);
#if true
            g.Fill();
#else
            g.FillPreserve();

            g.Operator = Operator.Over;
            RadialGradient rg = new RadialGradient(inner_x - (inner * 0.3), inner * 0.3, inner * 0.1, inner_x, 0, inner);
            rg.AddColorStop(0, new Cairo.Color(0.0, 0.2, .8, 0.5));
            rg.AddColorStop(0.7, new Cairo.Color(0.0, 0.2, .8, 0.1));
            rg.AddColorStop(1.0, new Cairo.Color(0.0, 0.0, 0.0, 0.0));
            g.Source = rg;
            g.Fill();
            rg.Destroy();
#endif
            g.Operator = Operator.Over;
            g.Matrix   = new Matrix();
            g.Translate(cx, cy);
            if (source != null)
            {
                SetSourcePixbuf(g, source, -source.Width / 2, -source.Height / 2);
            }

            g.Arc(0, 0, radius, 0, 2 * Math.PI);
            g.Fill();

            if (overlay != null)
            {
                SetSourcePixbuf(g, overlay, -overlay.Width / 2, -overlay.Height / 2);
                g.Arc(0, 0, radius, angle, angle + Math.PI);
                g.ClosePath();
                g.FillPreserve();
                g.Source = new SolidPattern(new Cairo.Color(1.0, 1.0, 1.0, 1.0));
                g.Stroke();
            }
        }
Ejemplo n.º 13
0
    //http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/cookbook/
    private static void drawRoundedRectangle(double x, double y, double width, double height,
                                             double radius, Cairo.Context g, Cairo.Color color)
    {
        g.Save();

        //manage negative widths
        if (width < 0)
        {
            x     += width;         //it will shift to the left (width is negative)
            width *= -1;
        }

        if ((radius > height / 2) || (radius > width / 2))
        {
            radius = min(height / 2, width / 2);
        }

        g.MoveTo(x, y + radius);
        g.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
        g.LineTo(x + width - radius, y);
        g.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
        g.LineTo(x + width, y + height - radius);
        g.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
        g.LineTo(x + radius, y + height);
        g.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
        g.ClosePath();
        g.Restore();

        g.SetSourceRGB(color.R, color.G, color.B);
        g.FillPreserve();
        g.SetSourceRGB(0, 0, 0);
        g.LineWidth = 2;
        g.Stroke();
    }
Ejemplo n.º 14
0
        public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y,
                                                double width, double height, double radius,
                                                Cairo.Color color, Cairo.Color borderColor)
        {
            gr.Save();

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            gr.MoveTo(x, y + radius);
            gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo(x + width - radius, y);
            gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo(x + width, y + height - radius);
            gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo(x + radius, y + height);
            gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath();
            gr.Restore();

            gr.LineJoin = LineJoin.Round;
            gr.Color    = borderColor;
            gr.StrokePreserve();
            gr.Color = color;
            gr.Fill();
        }
Ejemplo n.º 15
0
 private void Image_Loaded(object sender, RoutedEventArgs e)
 {
     Image image = (Image)sender;
     using (ImageSurface surface = new ImageSurface(Format.Argb32, (int)image.Width, (int)image.Height))
     {
         using (Context context = new Context(surface))
         {
             PointD p = new PointD(10.0, 10.0);
             PointD p2 = new PointD(100.0, 10.0);
             PointD p3 = new PointD(100.0, 100.0);
             PointD p4 = new PointD(10.0, 100.0);
             context.MoveTo(p);
             context.LineTo(p2);
             context.LineTo(p3);
             context.LineTo(p4);
             context.LineTo(p);
             context.ClosePath();
             context.Fill();
             context.MoveTo(140.0, 110.0);
             context.SetFontSize(32.0);
             context.SetSourceColor(new Color(0.0, 0.0, 0.8, 1.0));
             context.ShowText("Hello Cairo!");
             surface.Flush();
             RgbaBitmapSource source = new RgbaBitmapSource(surface.Data, surface.Width);
             image.Source = source;
         }
     }
 }
Ejemplo n.º 16
0
        public void Draw(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                cr.NewPath();
                double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5;
                cr.MoveTo(x, rectangle.Y + 0.5 + 2);
                cr.RelLineTo(0, rectangle.Height - 1 - 4);
                cr.ClosePath();
                cr.SetSourceColor(parent.Style.Dark(StateType.Normal).ToCairoColor());
                cr.LineWidth = 1;
                cr.Stroke();
                return;
            }

            if (Active || HoverPosition.X >= 0)
            {
                if (Active)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    using (var gr = new LinearGradient(rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
                        gr.AddColorStop(0, Tabstrip.ActiveGradientStart);
                        gr.AddColorStop(1, Tabstrip.ActiveGradientEnd);
                        cr.SetSource(gr);
                    }
                    cr.Fill();
                    cr.Rectangle(rectangle.X + 0.5, rectangle.Y + 0.5, rectangle.Width - 1, rectangle.Height - 1);
                    cr.SetSourceRGBA(1, 1, 1, 0.05);
                    cr.LineWidth = 1;
                    cr.Stroke();
                }
                else if (HoverPosition.X >= 0)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    using (var gr = new LinearGradient(rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
                        var c1 = Tabstrip.ActiveGradientStart;
                        var c2 = Tabstrip.ActiveGradientEnd;
                        c1.A = 0.2;
                        c2.A = 0.2;
                        gr.AddColorStop(0, c1);
                        gr.AddColorStop(1, c2);
                        cr.SetSource(gr);
                    }
                    cr.Fill();
                }
            }

            if (Active)
            {
                cr.SetSourceRGB(1, 1, 1);
            }
            else
            {
                cr.SetSourceColor(parent.Style.Text(StateType.Normal).ToCairoColor());
            }

            cr.MoveTo(rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2);
            Pango.CairoHelper.ShowLayout(cr, layout);
        }
 static void oval_path(Cairo.Context gr, double xc, double yc, double xr, double yr)
 {
     gr.Translate(xc, yc);
     gr.Scale(1.0, yr / xr);
     gr.MoveTo(new PointD(xr, 0.0));
     gr.Arc(0, 0, xr, 0, 2 * M_PI);
     gr.ClosePath();
 }
Ejemplo n.º 18
0
        void DrawCurveTabs(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                return;
            }

            cr.MoveTo(rectangle.X, rectangle.Y);

            double bottom = rectangle.Y + rectangle.Height - 1;

            cr.CurveTo(
                rectangle.X + SpacerWidth / 2, rectangle.Y,
                rectangle.X + SpacerWidth / 2, bottom,
                rectangle.X + SpacerWidth, bottom);

            cr.LineTo(rectangle.X + rectangle.Width - SpacerWidth, bottom);

            cr.CurveTo(
                rectangle.X + rectangle.Width - SpacerWidth / 2, bottom,
                rectangle.X + rectangle.Width - SpacerWidth / 2, rectangle.Y,
                rectangle.X + rectangle.Width, rectangle.Y);

            cr.Color = (HslColor)parent.Style.Dark(StateType.Normal);
            cr.StrokePreserve();
            cr.ClosePath();
            if (Active)
            {
                cr.Color = (HslColor)parent.Style.Background(StateType.Prelight);
            }
            else if (HoverPosition.X >= 0)
            {
                double rx = rectangle.X + HoverPosition.X;
                double ry = rectangle.Y + HoverPosition.Y;
                Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, rectangle.Height * 1.5,
                                                                         rx, ry, 2);
                var color = (HslColor)parent.Style.Mid(StateType.Normal);
                color.L *= 1.05;
                gradient.AddColorStop(0, color);
                color.L *= 1.07;
                gradient.AddColorStop(1, color);
                cr.Pattern = gradient;
            }
            else
            {
                cr.Color = (HslColor)parent.Style.Mid(StateType.Normal);
            }
            cr.Fill();

            cr.Save();
            cr.Translate(rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2);
            cr.Color = (HslColor)parent.Style.Text(StateType.Normal);

            cr.ShowLayout(layout);

            cr.Restore();
        }
Ejemplo n.º 19
0
        public override void RealRenderCairo(Cairo.Context context)
        {
            //if (Camera.IsRendererOutOfScreen (this))
            //	return;
            context.MoveTo(Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(points[len - 1])).ToPointD());
            for (int i = 0; i < len; i++)
            {
                context.LineTo(Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(points [i])).ToPointD());
            }
            context.ClosePath();
            if (surf == null)
            {
                context.SetSourceRGBA(ColorR, ColorG, ColorB, ColorA);
                context.Fill();
            }
            else
            {
                int     w = surf.Width;
                int     h = surf.Height;
                Vector2 screenMinBound = Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(minBound));
                Vector2 screenMaxBound = Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(maxBound));

                int myH = (int)(screenMinBound.y - screenMaxBound.y);


                int posY = (int)screenMaxBound.y;
                while (myH > 0)
                {
                    int posX = (int)screenMinBound.x;
                    int myW  = (int)(screenMaxBound.x - screenMinBound.x);
                    while (myW > 0)
                    {
                        if (Camera.IsPointOutOfScreen(new Vector2(posX, posY)) &&
                            Camera.IsPointOutOfScreen(new Vector2(posX, posY + h)) &&
                            Camera.IsPointOutOfScreen(new Vector2(posX + w, posY)) &&
                            Camera.IsPointOutOfScreen(new Vector2(posX + w, posY + h)))
                        {
                            myW  -= w;
                            posX += w;
                            continue;
                        }

                        context.SetSourceSurface(surf, posX, posY);
                        context.FillPreserve();
                        myW  -= w;
                        posX += w;
                    }
                    myH  -= h;
                    posY += h;
                }
                context.SetSourceRGBA(ColorR, ColorG, ColorB, ColorA);
                context.Stroke();
                //context.NewPath();
                context.GetSource().Dispose();
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Draws the lines.
 /// </summary>
 /// <param name="context">Context.</param>
 /// <param name="xStart">X start.</param>
 /// <param name="yStart">Y start.</param>
 /// <param name="xEnd">X end.</param>
 /// <param name="yEnd">Y end.</param>
 /// <param name="color">Color.</param>
 private static void DrawLines(Cairo.Context context, int xStart, int yStart, int xEnd, int yEnd, Cairo.Color color)
 {
     context.Save();
     context.SetSourceRGBA(color.R, color.G, color.B, color.A);
     context.MoveTo(xStart, yStart);
     context.LineTo(xEnd, yEnd);
     context.ClosePath();
     context.Restore();
     context.LineWidth = 1;
     context.Stroke();
 }
Ejemplo n.º 21
0
 public override void Draw(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
 {
     g.MoveTo(0, 0);
     g.LineTo(width, 0);
     g.LineTo(width, height);
     g.LineTo(0, height);
     g.LineTo(0, 0);
     g.ClosePath();
     g.Color = GetCurrentColor();
     g.Fill();
 }
Ejemplo n.º 22
0
        private void RoundedRect(Cairo.Context cr, Cairo.Rectangle rect, double r)
        {
            var rightAngle = Math.PI / 2.0;

            cr.NewPath();
            cr.Arc(rect.X + rect.Width - r, rect.Y + r, r, -rightAngle, 0);
            cr.Arc(rect.X + rect.Width - r, rect.Y + rect.Height - r, r, 0, rightAngle);
            cr.Arc(rect.X + r, rect.Y + rect.Height - r, r, rightAngle, rightAngle * 2);
            cr.Arc(rect.X + r, rect.Y + r, r, rightAngle * 2, rightAngle * 3);
            cr.ClosePath();
        }
Ejemplo n.º 23
0
 public static void DrawTriangle(Cairo.Context g, double x, double y,
                                 int width, int height, Cairo.Color color)
 {
     g.Color = color;
     g.MoveTo(x, y);
     g.LineTo(x + width / 2, y - height);
     g.LineTo(x - width / 2, y - height);
     g.ClosePath();
     g.Fill();
     g.Stroke();
 }
Ejemplo n.º 24
0
	void OvalPath (Context cr, double xc, double yc, double xr, double yr)
	{
		Matrix m = cr.Matrix;

		cr.Translate (xc, yc);
		cr.Scale (1.0, yr / xr);
		cr.MoveTo (xr, 0.0);
		cr.Arc (0, 0, xr, 0, 2 * Math.PI);
		cr.ClosePath ();

		cr.Matrix = m;
	}
        private void Render(Clutter.CairoTexture texture, int with_state, bool outwards)
        {
            texture.Clear();
            Cairo.Context context = texture.Create();

            double lwidth  = 1;
            double hlwidth = lwidth * 0.5;

            //Draw outline rectangles:
            context.Rectangle(hlwidth, hlwidth, texture.Width - lwidth, texture.Height - lwidth);
            context.SetSourceRGB(1.0, 1.0, 1.0);
            context.LineWidth = lwidth;
            context.StrokePreserve();
            double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8));

            context.SetSourceRGB(sat, sat, sat);
            context.Fill();

            double dim = 4;

            context.MoveTo(-dim, 0);
            context.LineTo(outwards ? 0 : -dim, outwards ? 0 : dim);
            context.LineTo(0, dim);
            context.MoveTo(-dim, dim);
            context.LineTo(0, 0);
            context.ClosePath();
            Cairo.Path arrow = context.CopyPath();
            context.NewPath();

            double margin = 2 + hlwidth;
            PointD center = new PointD(texture.Width * 0.5, texture.Height * 0.5);
            PointD transl = new PointD(center.X - margin, -(center.Y - margin));

            context.LineWidth = lwidth;
            sat = (with_state == 1 ? 0.0 : 1.0);
            context.SetSourceRGB(sat, sat, sat);

            context.Translate(center.X, center.Y);
            for (int i = 0; i < 4; i++)
            {
                context.Rotate(Math.PI * 0.5 * i);
                context.Translate(transl.X, transl.Y);
                context.AppendPath(arrow);
                context.Stroke();
                context.Translate(-transl.X, -transl.Y);
            }

            ((IDisposable)arrow).Dispose();
            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
Ejemplo n.º 26
0
    private static void plotArc(int centerx, int centery, int radius, double start, double end,
                                Cairo.Context g, Cairo.Color color)
    {
        //pie chart
        g.MoveTo(centerx, centery);
        g.Arc(centerx, centery, radius, start * Math.PI, end * Math.PI);
        g.ClosePath();
        g.SetSourceRGB(color.R, color.G, color.B);
        g.FillPreserve();

        g.SetSourceRGB(0, 0, 0);
        g.LineWidth = 2;
        g.Stroke();
    }
Ejemplo n.º 27
0
 internal static void StrokeRectangle(this Cairo.Context g,
                                      Rect rect,
                                      Color color)
 {
     g.NewPath();
     g.MoveTo(rect.TopLeft.X, rect.TopLeft.Y);
     g.SetSourceColor(color);
     g.LineTo(rect.TopRight.X, rect.TopRight.Y);       //Top
     g.LineTo(rect.BottomRight.X, rect.BottomRight.Y); //Right
     g.LineTo(rect.BottomLeft.X, rect.BottomLeft.Y);   //Bottom
     g.LineTo(rect.TopLeft.X, rect.TopLeft.Y);         //Left
     g.ClosePath();
     g.Stroke();
 }
Ejemplo n.º 28
0
 internal static void FillRectangle(this Cairo.Context g,
                                    Rect rect,
                                    Color color)
 {
     g.NewPath();
     g.MoveTo(rect.TopLeft.X, rect.TopLeft.Y);
     g.SetSourceColor(color);
     g.LineTo(rect.TopRight.X, rect.TopRight.Y);
     g.LineTo(rect.BottomRight.X, rect.BottomRight.Y);
     g.LineTo(rect.BottomLeft.X, rect.BottomLeft.Y);
     g.LineTo(rect.TopLeft.X, rect.TopLeft.Y);
     g.ClosePath();
     g.Fill();
 }
Ejemplo n.º 29
0
        public void Draw(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                cr.NewPath();
                double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5;
                cr.MoveTo(x, rectangle.Y + 0.5 + 2);
                cr.RelLineTo(0, rectangle.Height - 1 - 4);
                cr.ClosePath();
                cr.SetSourceColor(Styles.SubTabBarSeparatorColor.ToCairoColor());
                cr.LineWidth = 1;
                cr.Stroke();
                return;
            }

            if (Active || HoverPosition.X >= 0)
            {
                if (Active)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    cr.SetSourceColor(Styles.SubTabBarActiveBackgroundColor.ToCairoColor());
                    cr.Fill();
                }
                else if (HoverPosition.X >= 0)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    cr.SetSourceColor(Styles.SubTabBarHoverBackgroundColor.ToCairoColor());
                    cr.Fill();
                }
            }

            if (Active)
            {
                cr.SetSourceColor(Styles.SubTabBarActiveTextColor.ToCairoColor());
                layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11, Pango.Weight.Bold);
            }
            else
            {
                cr.SetSourceColor(Styles.SubTabBarTextColor.ToCairoColor());
                layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11);
            }

            layout.Width = (int)rectangle.Width;

            cr.MoveTo(rectangle.X + (int)(rectangle.Width / 2), (rectangle.Height - h) / 2 - 1);
            Pango.CairoHelper.ShowLayout(cr, layout);
        }
Ejemplo n.º 30
0
        protected override void CreateTexture(Clutter.CairoTexture texture, int with_state)
        {
            texture.Clear();
            Cairo.Context context = texture.Create();

            context.Translate(texture.Width * 0.5, texture.Height * 0.5);
            context.Arc(0, 0, (texture.Height - 1) * 0.5, 0, 2 * Math.PI);
            context.ClosePath();
            context.SetSourceRGBA(1.0, 1.0, 1.0, with_state == 0 ? 0.3 : (with_state == 1 ? 0.5 : 0.7));
            context.FillPreserve();
            context.SetSourceRGB(1.0, 1.0, 1.0);
            context.LineWidth = 1;
            context.Stroke();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
Ejemplo n.º 31
0
        private void triangulo(Cairo.Context cr, Boid b, double rot)
        {
            reset(cr);

            cr.Save();

            r.Rotate(rot);
            t.Translate(b.Location.X, Logica.mapeo(b.Location.Y));

            r.TransformPoint(ref Ax, ref Ay);
            t.TransformPoint(ref Ax, ref Ay);

            r.TransformPoint(ref Bx, ref By);
            t.TransformPoint(ref Bx, ref By);

            r.TransformPoint(ref Cx, ref Cy);
            t.TransformPoint(ref Cx, ref Cy);

            //			System.Diagnostics.Debug.WriteLine (Ax+", "+Ay);

            cr.MoveTo(Ax, Ay);
            cr.LineTo(Bx, By);
            cr.LineTo(Cx, Cy);

            cr.LineWidth = 2;

            if (b.criterio == 0)
            {
                cr.SetSourceRGBA(0.5, 0, 0, 0.5);                  //cercano
            }
            else if (b.criterio == 1)
            {
                cr.SetSourceRGBA(0, 0.5, 0, 0.5);                  //menos concurrido
            }
            else
            {
                cr.SetSourceRGBA(0, 0, 0.5, 0.5);                  //random
            }
            cr.ClosePath();
            cr.FillPreserve();
            cr.Stroke();

            cr.Restore();
        }
Ejemplo n.º 32
0
		public void Execute(Context ctx)
		{
			PointD point;
			var first = true;

			using (var mpath = ctx.CopyPath())
			{
				var path = mpath.GetPath();

				for (var i = 0; i < path.num_data; )
				{
					var hdr = path.GetPathHeader(i); //hdr.Dump();

					switch (hdr.type)
					{
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_MOVE_TO:
							if (first)
							{
								ctx.NewPath();
								first = false;
							}
							point = path.GetPathPoint(i + 1);
							ctx.MoveTo(WarpPoint(point));
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_LINE_TO:
							point = path.GetPathPoint(i + 1);
							ctx.LineTo(WarpPoint(point));
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_CURVE_TO:
							var p1 = WarpPoint(path.GetPathPoint(i + 1));
							var p2 = WarpPoint(path.GetPathPoint(i + 2));
							var p3 = WarpPoint(path.GetPathPoint(i + 3));
							ctx.CurveTo(p1, p2, p3);
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_CLOSE_PATH:
							ctx.ClosePath();
							break;
					}

					i += hdr.length;
				}
			}
		}
Ejemplo n.º 33
0
		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			int line_width = (int)g.LineWidth;
			int size;

			// we want a minimum size of 2 for the splatter (except for when the brush width is 1), since a splatter of size 1 is very small
			if (line_width == 1)
			{
				size = 1;
			}
			else
			{
				size = Random.Next (2, line_width);
			}

			Rectangle r = new Rectangle (x - Random.Next (-15, 15), y - Random.Next (-15, 15), size, size);

			double rx = r.Width / 2;
			double ry = r.Height / 2;
			double cx = r.X + rx;
			double cy = r.Y + ry;
			double c1 = 0.552285;

			g.Save ();

			g.MoveTo (cx + rx, cy);

			g.CurveTo (cx + rx, cy - c1 * ry, cx + c1 * rx, cy - ry, cx, cy - ry);
			g.CurveTo (cx - c1 * rx, cy - ry, cx - rx, cy - c1 * ry, cx - rx, cy);
			g.CurveTo (cx - rx, cy + c1 * ry, cx - c1 * rx, cy + ry, cx, cy + ry);
			g.CurveTo (cx + c1 * rx, cy + ry, cx + rx, cy + c1 * ry, cx + rx, cy);

			g.ClosePath ();

			Rectangle dirty = g.FixedStrokeExtents ();

			g.Fill ();
			g.Restore ();

			return dirty.ToGdkRectangle ();
		}
Ejemplo n.º 34
0
        public static void AngleFrame(Cairo.Context c, RectangleD rect, double angleLeft, double angleTop, double angleRight, double angleBottom)
        {
            //adjust position of frame accordingly to current position of rectangle
            double xAdj = rect.X;
            double yAdj = rect.Y;

            double middleX = rect.Width / 2;
            double middleY = rect.Height / 2;

            // Bottom-left corner
            PointD bottomLeftCorner = new PointD(angleLeft + xAdj, rect.Height - angleBottom + yAdj);

            PointD leftCenter = new PointD(0 + xAdj, middleY + yAdj);

            PointD topLeftCorner = new PointD(angleLeft + xAdj, angleTop + yAdj);

            // Top-middle
            PointD topMiddle = new PointD(middleX + xAdj, 0 + yAdj);

            // Top-right corner
            PointD topRightCorner = new PointD(rect.Width - angleRight + xAdj, angleTop + yAdj);

            // Middle, right side
            PointD middleRight = new PointD(rect.Width + xAdj, middleY + yAdj);

            // Bottom right corner
            PointD bottomRightCorner = new PointD(rect.Width - angleRight + xAdj, rect.Height - angleBottom + yAdj);

            // Bottom middle
            PointD bottomMiddle = new PointD(middleX + xAdj, rect.Height - angleBottom + yAdj);

            c.MoveTo(bottomLeftCorner);
            c.LineTo(leftCenter);
            c.LineTo(topLeftCorner);
            c.LineTo(topMiddle);
            c.LineTo(topRightCorner);
            c.LineTo(middleRight);
            c.LineTo(bottomRightCorner);
            c.LineTo(bottomMiddle);
            c.LineTo(bottomLeftCorner);
            c.ClosePath();
        }
 private void paintNodes(Context ctx, int w, int h, IEnumerable<Node> nodes)
 {
     ctx.LineWidth = 2.0d;
     foreach(Node node in nodes) {
         PointD abs = new PointD(node.Item2.X*w, node.Item2.Y*h);
         ctx.Arc(abs.X, abs.Y, AlgorithmRadius, 0.0d, 2.0d*Math.PI);
         ctx.ClosePath();
         ctx.NewSubPath();
         ctx.Arc(abs.X, abs.Y, AlgorithmRadius-BlueprintStyle.Thickness, 0.0d, 2.0d*Math.PI);
         ctx.ClosePath();
         ctx.NewSubPath();
     }
     ctx.Pattern = BlueprintStyle.FillPattern;
     ctx.FillPreserve();
     ctx.Color = BlueprintStyle.HardWhite;
     ctx.Stroke();
     double r_2, dx, dy;
     this.nodeCenters.Clear();
     foreach(Node node in nodes) {
         PointD abs = new PointD(node.Item2.X*w, node.Item2.Y*h);
         this.nodeCenters.Add(abs);
         TextExtents te = ctx.TextExtents(node.Item1);
         r_2 = (AlgorithmRadius-BlueprintStyle.Thickness)/Math.Sqrt(te.Width*te.Width+te.Height*te.Height);
         ctx.Save();
         ctx.MoveTo(abs.X-r_2*te.Width, abs.Y+r_2*te.Height);
         ctx.Scale(2.0d*r_2, 2.0d*r_2);
         ctx.ShowText(node.Item1);
         ctx.Restore();
     }
 }
Ejemplo n.º 36
0
		public void fill_and_stroke2(Context cr, int width, int height)
		{
			Normalize (cr, width, height);

			cr.MoveTo(0.5, 0.1);
			cr.LineTo(0.9, 0.9);
			cr.RelLineTo(-0.4, 0.0);
			cr.CurveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
			cr.ClosePath();

			cr.MoveTo(0.25, 0.1);
			cr.RelLineTo(0.2, 0.2);
			cr.RelLineTo(-0.2, 0.2);
			cr.RelLineTo(-0.2, -0.2);
			cr.ClosePath();

			cr.Color = new Color (0, 0, 1);
			cr.FillPreserve();
			cr.Color = new Color (0, 0, 0);

			cr.Stroke();
		}
Ejemplo n.º 37
0
        public virtual void Render(Context cr, Gdk.Rectangle area, Color color, bool showEmptyStars, bool isHovering,
            int hoverValue, double fillOpacity, double hoverFillOpacity, double strokeOpacity)
        {
            if (Value == MinRating && !isHovering && !showEmptyStars) {
                return;
            }

            cr.Save ();

            Cairo.Color fill_color = color;
            fill_color.A = fillOpacity;
            Cairo.Color stroke_color = fill_color;
            stroke_color.A = strokeOpacity;
            Cairo.Color hover_fill_color = fill_color;
            hover_fill_color.A = hoverFillOpacity;

            double x, y;
            ComputePosition (area, out x, out y);

            cr.LineWidth = 1.0;
            cr.Translate (0.5, 0.5);

            for (int i = MinRating + 1, s = isHovering || showEmptyStars ? MaxRating : Value; i <= s; i++, x += Size) {
                bool fill = i <= Value && Value > MinRating;
                bool hover_fill = i <= hoverValue && hoverValue > MinRating;
                double scale = fill || hover_fill ? Size : Size - 2;
                double ofs = fill || hover_fill ? 0 : 1;

                for (int p = 0, n = star_plot.GetLength (0); p < n; p++) {
                    double px = x + ofs + star_plot[p, 0] * scale;
                    double py = y + ofs + star_plot[p, 1] * scale;
                    if (p == 0) {
                        cr.MoveTo (px, py);
                    } else {
                        cr.LineTo (px, py);
                    }
                }
                cr.ClosePath ();

                if (fill || hover_fill) {
                    if (!isHovering || hoverValue >= Value) {
                        cr.SetSourceColor (fill ? fill_color : hover_fill_color);
                    } else {
                        cr.SetSourceColor (hover_fill ? fill_color : hover_fill_color);
                    }
                    cr.Fill ();
                } else {
                    cr.SetSourceColor (stroke_color);
                    cr.Stroke ();
                }
            }
            cr.Restore ();
        }
Ejemplo n.º 38
0
        void LinePath(Context cr, double xs, double ys, double xe, double ye)
        {
            Matrix m = cr.Matrix;
            cr.Antialias = Antialias.Subpixel;
            cr.LineWidth = lineWitdth;
            cr.LineCap = LineCap.Round;
            cr.MoveTo(xs, ys);
            cr.LineTo(xe, ye);
            cr.Stroke();

            cr.ClosePath();

            cr.Matrix = m;
        }
Ejemplo n.º 39
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            base.OnMouseUp (canvas, args, point);

            ImageSurface surf = doc.SelectionLayer.Surface;

            using (Context g = new Context (surf)) {
                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                    path = null;
                }

                g.FillRule = FillRule.EvenOdd;
                g.ClosePath ();

                doc.Selection.DisposeSelectionPreserve();

                doc.Selection.SelectionPath = g.CopyPath ();
            }

            doc.Selection.SelectionPolygons.Add(lassoPolygon.ToList());
            lassoPolygon.Clear();

            doc.Workspace.Invalidate ();
        }
Ejemplo n.º 40
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if (!is_drawing)
                return;

            double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width - 1);
            double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height - 1);

            doc.ShowSelection = true;

            ImageSurface surf = doc.SelectionLayer.Surface;

            using (Context g = new Context (surf)) {
                g.Antialias = Antialias.Subpixel;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                } else {
                    g.MoveTo (x, y);
                }

                g.LineTo (x, y);
                lassoPolygon.Add(new IntPoint((long)x, (long)y));

                path = g.CopyPath ();

                g.FillRule = FillRule.EvenOdd;
                g.ClosePath ();

                doc.Selection.DisposeSelectionPreserve();

                doc.Selection.SelectionPath = g.CopyPath ();
            }

            doc.Workspace.Invalidate ();
        }
Ejemplo n.º 41
0
        private static void SetClip(Context ctx, Gdk.Rectangle area)
        {
            ctx.MoveTo (area.Left, area.Top);
            ctx.LineTo (area.Right, area.Top);
            ctx.LineTo (area.Right, area.Bottom);
            ctx.LineTo (area.Left, area.Bottom);

            ctx.ClosePath ();
            ctx.Clip ();
        }
Ejemplo n.º 42
0
        protected virtual void ShapeSurface(Context cr, Cairo.Color color)
        {
            cr.Operator = Operator.Source;
            Cairo.Pattern p = new Cairo.SolidPattern (new Cairo.Color (0, 0, 0, 0));
            cr.Source = p;
            p.Destroy ();
            cr.Paint ();
            cr.Operator = Operator.Over;

            Cairo.Pattern r = new SolidPattern (color);
            cr.Source = r;
            r.Destroy ();
            cr.MoveTo (round, 0);
            if (x_align == 1.0)
                cr.LineTo (Allocation.Width, 0);
            else
                cr.Arc (Allocation.Width - round, round, round, - Math.PI * 0.5, 0);
            if (x_align == 1.0 || y_align == 1.0)
                cr.LineTo (Allocation.Width, Allocation.Height);
            else
                cr.Arc (Allocation.Width - round, Allocation.Height - round, round, 0, Math.PI * 0.5);
            if (y_align == 1.0)
                cr.LineTo (0, Allocation.Height);
            else
                cr.Arc (round, Allocation.Height - round, round, Math.PI * 0.5, Math.PI);
            cr.Arc (round, round, round, Math.PI, Math.PI * 1.5);
            cr.ClosePath ();
            cr.Fill ();
        }
Ejemplo n.º 43
0
			protected override bool OnDrawn (Context ctx)
			{
				int w, h;
				this.GdkWindow.GetSize (out w, out h);
				var bounds = new Xwt.Rectangle (0.5, 0.5, w - 1, h - 1);
				var backgroundColor = Xwt.Drawing.Color.FromBytes (230, 230, 230, 230);
				var black = Xwt.Drawing.Color.FromBytes (60, 60, 60);

				// We clear the surface with a transparent color if possible
				if (supportAlpha)
					ctx.SetSourceRGBA (1.0, 1.0, 1.0, 0.0);
				else
					ctx.SetSourceRGB (1.0, 1.0, 1.0);
				ctx.Operator = Operator.Source;
				ctx.Paint ();
				
				var calibratedRect = RecalibrateChildRectangle (bounds);
				// Fill it with one round rectangle
				RoundRectangle (ctx, calibratedRect, radius);
				ctx.LineWidth = 1;
				ctx.SetSourceRGBA (black.Red, black.Green, black.Blue, black.Alpha);
				ctx.StrokePreserve ();
				ctx.SetSourceRGBA (backgroundColor.Red, backgroundColor.Green, backgroundColor.Blue, backgroundColor.Alpha);
				ctx.Fill ();
				
				// Triangle
				// We first begin by positionning ourselves at the top-center or bottom center of the previous rectangle
				var arrowX = bounds.Center.X;
				var arrowY = arrowPosition == Xwt.Popover.Position.Top ? calibratedRect.Top + ctx.LineWidth : calibratedRect.Bottom - ctx.LineWidth;
				ctx.NewPath ();
				ctx.MoveTo (arrowX, arrowY);
				// We draw the rectangle path
				DrawTriangle (ctx);
				// We use it
				ctx.SetSourceRGBA (black.Red, black.Green, black.Blue, black.Alpha);
				ctx.StrokePreserve ();
				ctx.ClosePath ();
				ctx.SetSourceRGBA (backgroundColor.Red, backgroundColor.Green, backgroundColor.Blue, backgroundColor.Alpha);
				ctx.Fill ();

				return base.OnDrawn (ctx);
			}
Ejemplo n.º 44
0
 public void CreateRoundedRectPath(Context gc, double x, double y, double width, double height, double radius)
 {
     double x1, y1;
     x1 = x + width;
     y1 = y + height;
     if (width / 2 < radius) {
         if (height / 2 < radius) {
             gc.MoveTo (x, (y + y1) / 2);
             gc.CurveTo (x ,y, x, y, (x + x1) / 2, y);
             gc.CurveTo (x1, y, x1, y, x1, (y + y1) / 2);
             gc.CurveTo (x1, y1, x1, y1, (x1 + x) / 2, y1);
             gc.CurveTo (x, y1, x, y1, x, (y + y1) / 2);
         } else {
             gc.MoveTo (x, y + radius);
             gc.CurveTo (x, y, x, y, (x + x1) / 2, y);
             gc.CurveTo (x1, y, x1, y, x1, y + radius);
             gc.LineTo (x1 , y1 - radius);
             gc.CurveTo (x1, y1, x1, y1, (x1 + x) / 2, y1);
             gc.CurveTo (x, y1, x, y1, x, y1 - radius);
         }
     } else {
         if (height / 2 < radius) {
             gc.MoveTo (x, (y + y1) / 2);
             gc.CurveTo (x , y, x, y, x + radius, y);
             gc.LineTo (x1 - radius, y);
             gc.CurveTo (x1, y, x1, y, x1, (y + y1) / 2);
             gc.CurveTo (x1, y1, x1, y1, x1 - radius, y1);
             gc.LineTo (x + radius, y1);
             gc.CurveTo (x, y1, x, y1, x, (y + y1) / 2);
         } else {
             gc.MoveTo (x, y + radius);
             gc.CurveTo (x , y, x , y, x + radius, y);
             gc.LineTo (x1 - radius, y);
             gc.CurveTo (x1, y, x1, y, x1, y + radius);
             gc.LineTo (x1, y1 - radius);
             gc.CurveTo (x1, y1, x1, y1, x1 - radius, y1);
             gc.LineTo (x + radius, y1);
             gc.CurveTo (x, y1, x, y1, x, y1 - radius);
         }
     }
     gc.ClosePath ();
 }
Ejemplo n.º 45
0
        private void CreatePath(Context context)
        {
            Rectangle alloc = base.Allocation;
            Point center = new Point (alloc.Width / 2, alloc.Height / 2);
            double radius = (Math.Min (alloc.Width, alloc.Height) - 10) / 2;
            double angle_in_radians = angle * (Math.PI / 180);

            context.Arc (center.X, center.Y, radius,
                -angle_in_radians + (-0.5 * Math.PI), -0.5 * Math.PI);
            context.LineTo (center.X, center.Y);
            context.ClosePath ();
        }
Ejemplo n.º 46
0
		public void curve_rectangle(Context cr, int width, int height)
		{
			// a custom shape, that could be wrapped in a function
			double x0	   = 0.1,   //< parameters like cairo_rectangle
			       y0	   = 0.1,
			       rect_width  = 0.8,
		    	   rect_height = 0.8,
				   radius = 0.4;   //< and an approximate curvature radius

			double x1,y1;

			Normalize(cr, width, height);

			x1=x0+rect_width;
			y1=y0+rect_height;

			if (rect_width/2<radius) {
				if (rect_height/2<radius) {
					cr.MoveTo(x0, (y0 + y1)/2);
					cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
					cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
				} else {
					cr.MoveTo(x0, y0 + radius);
					cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
					cr.LineTo(x1 , y1 - radius);
					cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
				}
			} else {
				if (rect_height/2<radius) {
					cr.MoveTo(x0, (y0 + y1)/2);
					cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
					cr.LineTo(x1 - radius, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
					cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
					cr.LineTo(x0 + radius, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
				} else {
					cr.MoveTo(x0, y0 + radius);
					cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
					cr.LineTo(x1 - radius, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
					cr.LineTo(x1 , y1 - radius);
					cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
					cr.LineTo(x0 + radius, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
				}
			}
			cr.ClosePath();

			// and fill/stroke it
			cr.Color = new Color (0.5, 0.5, 1);
			cr.FillPreserve();
			cr.Color = new Color (0.5, 0, 0, 0.5);
			cr.Stroke();
		}
Ejemplo n.º 47
0
        protected override bool OnExposed(Context cr, Rectangle area)
        {
            cr.Color = Color;
            if(rL > 0.0 && rR > 0.0 && rT > 0.0 && rB > 0.0)
            {
                double width = Allocation.Width;
                double height = Allocation.Height;
                double radL = rL * width;
                double radR = rR * width;
                double radT = rT * height;
                double radB = rB * height;

                Matrix m = cr.Matrix;
                cr.Translate(radL, radT);
                cr.Scale(radL, radT);
                cr.Arc(0.0, 0.0, 1.0, 1.0 * Math.PI, 1.5 * Math.PI);

                cr.Matrix = m;
                cr.Translate(width - radR, radT);
                cr.Scale(radR, radT);
                cr.Arc(0.0, 0.0, 1.0, 1.5 * Math.PI, 2.0 * Math.PI);

                cr.Matrix = m;
                cr.Translate(width - radR, height - radB);
                cr.Scale(radR, radB);
                cr.Arc(0.0, 0.0, 1.0, 0.0 * Math.PI, 0.5 * Math.PI);

                cr.Matrix = m;
                cr.Translate(radL, height - radB);
                cr.Scale(radL, radB);
                cr.Arc(0.0, 0.0, 1.0, 0.5 * Math.PI, 1.0 * Math.PI);

                cr.ClosePath();
            }
            else
                cr.Rectangle(area);
            cr.Fill();
            return true;
        }
Ejemplo n.º 48
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            doc.ToolLayer.Hidden = true;

            if (surface_modified)
                PintaCore.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, doc.CurrentUserLayerIndex));
            else if (undo_surface != null)
                (undo_surface as IDisposable).Dispose ();

            surface_modified = false;
            ImageSurface surf = doc.CurrentUserLayer.Surface;

            using (Context g = new Context (surf)) {
                g.AppendPath (doc.Selection.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                    path = null;
                }

                g.ClosePath ();
                g.LineWidth = BrushWidth;
                g.LineJoin = LineJoin.Round;
                g.LineCap = LineCap.Round;
                g.FillRule = FillRule.EvenOdd;

                if (FillShape && StrokeShape) {
                    g.Color = fill_color;
                    g.FillPreserve ();
                    g.Color = outline_color;
                    g.Stroke ();
                } else if (FillShape) {
                    g.Color = outline_color;
                    g.Fill ();
                } else {
                    g.Color = outline_color;
                    g.Stroke ();
                }
            }

            doc.Workspace.Invalidate ();
        }
Ejemplo n.º 49
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if ((args.Event.State & Gdk.ModifierType.Button1Mask) == Gdk.ModifierType.Button1Mask) {
                outline_color = PintaCore.Palette.PrimaryColor;
                fill_color = PintaCore.Palette.SecondaryColor;
            } else if ((args.Event.State & Gdk.ModifierType.Button3Mask) == Gdk.ModifierType.Button3Mask) {
                outline_color = PintaCore.Palette.SecondaryColor;
                fill_color = PintaCore.Palette.PrimaryColor;
            } else {
                last_point = point_empty;
                return;
            }

            int x = (int)point.X;
            int y = (int)point.Y;

            if (last_point.Equals (point_empty)) {
                last_point = new Point (x, y);
                return;
            }

            if (doc.Workspace.PointInCanvas (point))
                surface_modified = true;

            doc.ToolLayer.Clear ();
            ImageSurface surf = doc.ToolLayer.Surface;

            using (Context g = new Context (surf)) {
                doc.Selection.Clip(g);

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                } else {
                    g.MoveTo (x, y);
                }

                g.LineTo (x, y);

                path = g.CopyPath ();

                g.ClosePath ();
                g.LineWidth = BrushWidth;
                g.LineJoin = LineJoin.Round;
                g.LineCap = LineCap.Round;
                g.FillRule = FillRule.EvenOdd;

                if (FillShape && StrokeShape) {
                    g.Color = fill_color;
                    g.FillPreserve ();
                    g.Color = outline_color;
                    g.Stroke ();
                } else if (FillShape) {
                    g.Color = outline_color;
                    g.Fill ();
                } else {
                    g.Color = outline_color;
                    g.Stroke ();
                }
            }

            doc.Workspace.Invalidate ();

            last_point = new Point (x, y);
        }
Ejemplo n.º 50
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            if (!is_drawing)
                return;

            double x = Utility.Clamp (point.X, 0, PintaCore.Workspace.ImageSize.Width - 1);
            double y = Utility.Clamp (point.Y, 0, PintaCore.Workspace.ImageSize.Height - 1);

            PintaCore.Layers.ShowSelection = true;

            ImageSurface surf = PintaCore.Layers.ToolLayer.Surface;

            using (Context g = new Context (surf)) {
                g.Antialias = Antialias.Subpixel;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                }

                g.LineTo (x, y);

                path = g.CopyPath ();

                g.FillRule = FillRule.EvenOdd;
                g.ClosePath ();

                Path old = PintaCore.Layers.SelectionPath;

                PintaCore.Layers.SelectionPath = g.CopyPath ();
                (old as IDisposable).Dispose ();
            }

            PintaCore.Workspace.Invalidate ();
        }
Ejemplo n.º 51
0
        private static void SetClip(Context ctx, Region region)
        {
            foreach (Gdk.Rectangle area in region.GetRectangles ()) {
                ctx.MoveTo (area.Left, area.Top);
                ctx.LineTo (area.Right, area.Top);
                ctx.LineTo (area.Right, area.Bottom);
                ctx.LineTo (area.Left, area.Bottom);

                ctx.ClosePath ();
            }
            ctx.Clip ();
        }
Ejemplo n.º 52
0
        // trace un carré plein à liaisons
        private void traceLinkedFullSquare(Context grCxt, double cellWidth, Color fillColor, LayerType layerType)
        {
            double marginN, marginE, marginS, marginW;
            if (layers[(int)layerType].links[(int)CellLayer.Cardinals.N] != null)
                marginN = 0;
            else
                marginN = mgN;
            if (layers[(int)layerType].links[(int)CellLayer.Cardinals.E] != null)
                marginE = 0;
            else
                marginE = mgE;
            if (layers[(int)layerType].links[(int)CellLayer.Cardinals.S] != null)
                marginS = 0;
            else
                marginS = mgS;
            if (layers[(int)layerType].links[(int)CellLayer.Cardinals.W] != null)
                marginW = 0;
            else
                marginW = mgW;

            grCxt.MoveTo(x * cellWidth + marginW, y * cellWidth + marginN);
            grCxt.LineTo((x + 1) * cellWidth - marginE, y * cellWidth + marginN);
            grCxt.LineTo((x + 1) * cellWidth - marginE, (y + 1) * cellWidth - marginS);
            grCxt.LineTo(x * cellWidth + marginW, (y + 1) * cellWidth - marginS);
            grCxt.ClosePath();
            grCxt.Color = fillColor;
            grCxt.Fill();
        }
Ejemplo n.º 53
0
		void DrawTab (Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
		{
			// This logic is stupid to have here, should be in the caller!
			if (dragging) {
				tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
				tabBounds.X = Clamp (tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
			}
			int padding = LeftRightPadding;
			padding = (int)(padding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));

			ctx.LineWidth = 1;
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.ClosePath ();
			using (var gr = new LinearGradient (tabBounds.X, TopBarPadding, tabBounds.X, allocation.Bottom)) {
				if (active) {
					gr.AddColorStop (0, Styles.BreadcrumbGradientStartColor.MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, Styles.BreadcrumbBackgroundColor.MultiplyAlpha (tab.Opacity));
				} else {
					gr.AddColorStop (0, CairoExtensions.ParseColor ("f4f4f4").MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, CairoExtensions.ParseColor ("cecece").MultiplyAlpha (tab.Opacity));
				}
				ctx.SetSource (gr);
			}
			ctx.Fill ();

			ctx.SetSourceColor (new Cairo.Color (1, 1, 1, .5).MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 1, active);
			ctx.Stroke ();

			ctx.SetSourceColor (Styles.BreadcrumbBorderColor.MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.StrokePreserve ();

			if (tab.GlowStrength > 0) {
				Gdk.Point mouse = tracker.MousePosition;
				using (var rg = new RadialGradient (mouse.X, tabBounds.Bottom, 0, mouse.X, tabBounds.Bottom, 100)) {
					rg.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.4 * tab.Opacity * tab.GlowStrength));
					rg.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));

					ctx.SetSource (rg);
					ctx.Fill ();
				}
			} else {
				ctx.NewPath ();
			}

			// Render Close Button (do this first so we can tell how much text to render)

			var ch = allocation.Height - TopBarPadding - BottomBarPadding + CloseImageTopOffset;
			var crect = new Gdk.Rectangle (tabBounds.Right - padding - CloseButtonSize + 3,
				            tabBounds.Y + TopBarPadding + (ch - CloseButtonSize) / 2,
				            CloseButtonSize, CloseButtonSize);
			tab.CloseButtonAllocation = crect;
			tab.CloseButtonAllocation.Inflate (2, 2);

			bool closeButtonHovered = tracker.Hovered && tab.CloseButtonAllocation.Contains (tracker.MousePosition) && tab.WidthModifier >= 1.0f;
			bool drawCloseButton = tabBounds.Width > 60 || highlight || closeButtonHovered;
			if (drawCloseButton) {
				DrawCloseButton (ctx, new Gdk.Point (crect.X + crect.Width / 2, crect.Y + crect.Height / 2), closeButtonHovered, tab.Opacity, tab.DirtyStrength);
			}

			// Render Text
			int w = tabBounds.Width - (padding * 2 + CloseButtonSize);
			if (!drawCloseButton)
				w += CloseButtonSize;

			int textStart = tabBounds.X + padding;

			ctx.MoveTo (textStart, tabBounds.Y + TopPadding + TextOffset + VerticalTextSize);
			if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) {
				// This is a work around for a linux specific problem.
				// A bug in the proprietary ATI driver caused TAB text not to draw.
				// If that bug get's fixed remove this HACK asap.
				la.Ellipsize = Pango.EllipsizeMode.End;
				la.Width = (int)(w * Pango.Scale.PangoScale);
				ctx.SetSourceColor (tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor);
				Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
			} else {
				// ellipses are for space wasting ..., we cant afford that
				using (var lg = new LinearGradient (textStart + w - 5, 0, textStart + w + 3, 0)) {
					var color = tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor;
					color = color.MultiplyAlpha (tab.Opacity);
					lg.AddColorStop (0, color);
					color.A = 0;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
				}
			}
			la.Dispose ();
		}
Ejemplo n.º 54
0
        public void draw(Context grCxt, double cellWidth, Colors color)
        {
            PointD p0, p1, p2, p3;

            // efface la case
            p0 = new PointD(this.x * cellWidth, this.y * cellWidth);
            p1 = new PointD((this.x + 1) * cellWidth, this.y * cellWidth);
            p2 = new PointD((this.x + 1) * cellWidth, (this.y + 1) * cellWidth);
            p3 = new PointD(this.x * cellWidth, (this.y + 1) * cellWidth);

            grCxt.MoveTo(p0);
            grCxt.LineTo(p1);
            grCxt.LineTo(p2);
            grCxt.LineTo(p3);
            grCxt.ClosePath();
            grCxt.Color = color.find("background");
            grCxt.Fill();

            p0 = new PointD(this.x * cellWidth + 1, (this.y + 1) * cellWidth);
            p1 = new PointD(this.x * cellWidth + 1, this.y * cellWidth + 1);
            p2 = new PointD((this.x + 1) * cellWidth, this.y * cellWidth + 1);
            grCxt.MoveTo(p0);
            grCxt.LineTo(p1);
            grCxt.LineTo(p2);
            grCxt.Color = color.find("grid");
            grCxt.Stroke();

            // couche SILICON_N
            if (circuit.showLayer[(int)Circuit.showLayerType.S]) {
                if (layers[(int)LayerType.SILICON_N].isSet) {

                    grCxt.MoveTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.SILICON_N].links[(int)CellLayer.Cardinals.N] != null ||
                        layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.N] != null) {

                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.SILICON_N].links[(int)CellLayer.Cardinals.E] != null ||
                        layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.E] != null) {

                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, this.y * cellWidth + mgN));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, (this.y + 1) * cellWidth - mgS));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.SILICON_N].links[(int)CellLayer.Cardinals.S] != null ||
                        layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.S] != null) {

                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth));
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth));
                    }

                    grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.SILICON_N].links[(int)CellLayer.Cardinals.W] != null ||
                        layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.W] != null) {

                        grCxt.LineTo(new PointD(this.x * cellWidth, (this.y + 1) * cellWidth - mgS));
                        grCxt.LineTo(new PointD(this.x * cellWidth, this.y * cellWidth + mgN));
                    }

                    grCxt.ClosePath();
                    grCxt.Color = color.find("snN_fill");
                    grCxt.Fill();
                }
            }

            // couche SILICON_P
            if (circuit.showLayer[(int)Circuit.showLayerType.S]) {
                if (layers[(int)LayerType.SILICON_P].isSet) {

                    grCxt.MoveTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.SILICON_P].links[(int)CellLayer.Cardinals.N] != null ||
                        layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.N] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.SILICON_P].links[(int)CellLayer.Cardinals.E] != null ||
                        layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.E] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, this.y * cellWidth + mgN));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, (this.y + 1) * cellWidth - mgS));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.SILICON_P].links[(int)CellLayer.Cardinals.S] != null ||
                        layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.S] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth));
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth));
                    }

                    grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.SILICON_P].links[(int)CellLayer.Cardinals.W] != null ||
                        layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.W] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth, (this.y + 1) * cellWidth - mgS));
                        grCxt.LineTo(new PointD(this.x * cellWidth, this.y * cellWidth + mgN));
                    }

                    grCxt.ClosePath();
                    grCxt.Color = color.find("snP_fill");
                    grCxt.Fill();
                }
            }

            // PNP / NPN
            if (circuit.showLayer[(int)Circuit.showLayerType.S]) {
                if (layers[(int)LayerType.PNP].isSet) {
                    grCxt.MoveTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.N] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.E] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, this.y * cellWidth + mgN));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, (this.y + 1) * cellWidth - mgS));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.S] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth));
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth));
                    }

                    grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.PNP].links[(int)CellLayer.Cardinals.W] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth, (this.y + 1) * cellWidth - mgS));
                        grCxt.LineTo(new PointD(this.x * cellWidth, this.y * cellWidth + mgN));
                    }

                    grCxt.ClosePath();
                    grCxt.Color = color.find("gate_PNP");
                    grCxt.Fill();
                }

                if (layers[(int)LayerType.NPN].isSet) {
                    grCxt.MoveTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.N] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.E] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, this.y * cellWidth + mgN));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, (this.y + 1) * cellWidth - mgS));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.S] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth));
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth));
                    }

                    grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.NPN].links[(int)CellLayer.Cardinals.W] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth, (this.y + 1) * cellWidth - mgS));
                        grCxt.LineTo(new PointD(this.x * cellWidth, this.y * cellWidth + mgN));
                    }

                    grCxt.ClosePath();
                    grCxt.Color = color.find("gate_NPN");
                    grCxt.Fill();
                }
            }

            // couche METAL
            if (circuit.showLayer[(int)Circuit.showLayerType.M]) {
                if (layers[(int)LayerType.METAL].isSet && !layers[(int)LayerType.IO].isSet) {

                    grCxt.MoveTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.METAL].links[(int)CellLayer.Cardinals.N] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, this.y * cellWidth));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, this.y * cellWidth + mgN));

                    if (layers[(int)LayerType.METAL].links[(int)CellLayer.Cardinals.E] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, this.y * cellWidth + mgN));
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth, (this.y + 1) * cellWidth - mgS));
                    }

                    grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.METAL].links[(int)CellLayer.Cardinals.S] != null) {
                        grCxt.LineTo(new PointD((this.x + 1) * cellWidth - mgE, (this.y + 1) * cellWidth));
                        grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth));
                    }

                    grCxt.LineTo(new PointD(this.x * cellWidth + mgW, (this.y + 1) * cellWidth - mgS));

                    if (layers[(int)LayerType.METAL].links[(int)CellLayer.Cardinals.W] != null) {
                        grCxt.LineTo(new PointD(this.x * cellWidth, (this.y + 1) * cellWidth - mgS));
                        grCxt.LineTo(new PointD(this.x * cellWidth, this.y * cellWidth + mgN));
                    }

                    grCxt.ClosePath();
                    grCxt.Color = color.find("metal_fill");
                    grCxt.Fill();
                }
            }

            // couche I/O
            if (layers[(int)LayerType.IO].isSet) {
                traceLinkedFullSquare(grCxt, cellWidth, color.find("metal_fill"), LayerType.IO);
            }

            // via
            if (circuit.showLayer[(int)Circuit.showLayerType.S]) {
                if (via) {
                    grCxt.MoveTo(new PointD(x * cellWidth + 7d, y * cellWidth + 7d));
                    grCxt.LineTo(new PointD((x + 1) * cellWidth - 6d, y * cellWidth + 7d));
                    grCxt.LineTo(new PointD((x + 1) * cellWidth - 6d, (y + 1) * cellWidth - 6d));
                    grCxt.LineTo(new PointD(x * cellWidth + 7d, (y + 1) * cellWidth - 6d));
                    grCxt.ClosePath();
                    grCxt.Color = color.find("via");
                    grCxt.Stroke();
                }
            }

            // powered
            bool pwr = false;
            foreach (CellLayer l in layers)
                if (l.isPowered)
                    pwr = true;

            if (pwr) {
                grCxt.MoveTo(new PointD(x * cellWidth + mgW, y * cellWidth + mgN));
                grCxt.LineTo(new PointD((x + 1) * cellWidth - mgE, y * cellWidth + mgN));
                grCxt.LineTo(new PointD((x + 1) * cellWidth - mgE, (y + 1) * cellWidth - mgS));
                grCxt.LineTo(new PointD(x * cellWidth + mgW, (y + 1) * cellWidth - mgS));
                grCxt.ClosePath();
                grCxt.Color = color.find("powered");
                grCxt.Fill();
            }
        }
Ejemplo n.º 55
0
        void DrawShape(Context g, int width, int height)
        {
            int inner_x = radius + border + inner;
            int cx = Center.X;
            int cy = Center.Y;

            g.Operator = Operator.Source;
            g.SetSource (new SolidPattern (new Cairo.Color (0,0,0,0)));
            g.Rectangle (0, 0, width, height);
            g.Paint ();

            g.NewPath ();
            g.Translate (cx, cy);
            g.Rotate (angle);

            g.SetSource (new SolidPattern (new Cairo.Color (0.2, 0.2, 0.2, .6)));
            g.Operator = Operator.Over;
            g.Rectangle (0, - (border + inner), inner_x, 2 * (border + inner));
            g.Arc (inner_x, 0, inner + border, 0, 2 * Math.PI);
            g.Arc (0, 0, radius + border, 0, 2 * Math.PI);
            g.Fill ();

            g.SetSource (new SolidPattern (new Cairo.Color (0, 0, 0, 1.0)));
            g.Operator = Operator.DestOut;
            g.Arc (inner_x, 0, inner, 0, 2 * Math.PI);
            #if true
            g.Fill ();
            #else
            g.FillPreserve ();

            g.Operator = Operator.Over;
            RadialGradient rg = new RadialGradient (inner_x - (inner * 0.3), inner * 0.3 , inner * 0.1, inner_x, 0, inner);
            rg.AddColorStop (0, new Cairo.Color (0.0, 0.2, .8, 0.5));
            rg.AddColorStop (0.7, new Cairo.Color (0.0, 0.2, .8, 0.1));
            rg.AddColorStop (1.0, new Cairo.Color (0.0, 0.0, 0.0, 0.0));
            g.Source = rg;
            g.Fill ();
            rg.Destroy ();
            #endif
            g.Operator = Operator.Over;
            g.Matrix = new Matrix ();
            g.Translate (cx, cy);
            if (source != null)
            CairoHelper.SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);

            g.Arc (0, 0, radius, 0, 2 * Math.PI);
            g.Fill ();

            if (overlay != null) {
                CairoHelper.SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
                g.Arc (0, 0, radius, angle, angle + Math.PI);
                g.ClosePath ();
                g.FillPreserve ();
                g.SetSource (new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0)));
                g.Stroke ();
            }
        }
Ejemplo n.º 56
0
		public void xxx_clip_rectangle(Context cr, int width, int height)
		{
			Normalize (cr, width, height);

			cr.NewPath();
			cr.MoveTo(.25, .25);
			cr.LineTo(.25, .75);
			cr.LineTo(.75, .75);
			cr.LineTo(.75, .25);
			cr.LineTo(.25, .25);
			cr.ClosePath();

			cr.Clip();

			cr.MoveTo(0, 0);
			cr.LineTo(1, 1);
			cr.Stroke();
		}
Ejemplo n.º 57
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            base.OnMouseUp (canvas, args, point);

            ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;

            using (Context g = new Context (surf)) {
                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                    path = null;
                }

                g.FillRule = FillRule.EvenOdd;
                g.ClosePath ();

                Path old = PintaCore.Layers.SelectionPath;

                PintaCore.Layers.SelectionPath = g.CopyPath ();
                (old as IDisposable).Dispose ();
            }

            PintaCore.Workspace.Invalidate ();
        }
 private void paintBackground(Context ctx, int w, int h)
 {
     ctx.Color = BlueprintStyle.BluePrint;
     ctx.Rectangle(0.0d, 0.0d, w, h);
     ctx.Fill();
     ctx.Color = BlueprintStyle.SoftWhite;
     ctx.Rectangle(Offset, Offset, w-2*Offset, h-2*Offset);
     ctx.ClosePath();
     ctx.Rectangle(Offset2, Offset2, w-2*Offset2, h-2*Offset2);
     ctx.ClosePath();
     ctx.Fill();
     double W = w-2*Offset2;
     int n = (int)Math.Round((double)W/LineDelta);
     double dx = (double)W/n;
     ctx.LineWidth = 0.5d;
     for(int i = 1; i < n; i++) {
         ctx.MoveTo(dx*i+Offset2, Offset2);
         ctx.RelLineTo(0.0d, h-2*Offset2);
         ctx.Stroke();
     }
     double H = h-2*Offset2;
     n = (int)Math.Round((double)H/LineDelta);
     double dy = (double)H/n;
     for(int i = 1; i < n; i++) {
         ctx.MoveTo(Offset2, dy*i+Offset2);
         ctx.RelLineTo(w-2.0d*Offset2, 0.0d);
         ctx.Stroke();
     }
 }
Ejemplo n.º 59
0
			void RoundRectangle (Context ctx, Rectangle rect, double radius)
			{
				double degrees = Math.PI / 180;
				var x = rect.X;
				var y = rect.Y;
				var height = rect.Height;
				var width = rect.Width;
				
				ctx.NewSubPath ();
				ctx.Arc (x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
				ctx.Arc (x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
				ctx.Arc (x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
				ctx.Arc (x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
				ctx.ClosePath ();
			}
Ejemplo n.º 60
0
 public virtual void Paint(Context ctx)
 {
     PointD size = this.MeasureSize (ctx);
     PaintContour (ctx,size);
     KnownColors.SetFontFacePieceName(ctx);
     TextExtents te = ctx.TextExtents(this.Name), ten;
     double y0 = 0.5d*(size.Y-te.Width);
     ctx.MoveTo(0.5d*Margin,y0);
     ctx.Save();
     ctx.Rotate(0.5d*Math.PI);
     ctx.ShowText(this.Name);
     ctx.Restore();
     double x0 = Margin+te.Height;
     KnownColors.SetFontFaceNormal(ctx);
     te = ctx.TextExtents(OptionalString);
     y0 = 2.0d*Margin;
     int index = 0x00;
     PointD siz;
     foreach(IPuzzlePiece ipp in this.arguments) {
         ctx.Save();
         ctx.Translate(x0,Margin);
         if(ipp == null) {
             siz = new PointD(MinimumWidth,size.Y-4.0d*Margin);
             ctx.Rectangle(Margin,Margin,siz.X,siz.Y);
             ctx.Pattern = KnownColors.ConstructionPattern;
             ctx.FillPreserve();
         }
         else {
             siz = ipp.MeasureSize(ctx);
         }
         ctx.Rectangle(0.0d,0.0d,siz.X+2.0d*Margin,siz.Y+2.0d*Margin);
         ctx.Color = KnownColors.Black;
         ctx.StrokePreserve();
         if(ipp == null) {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Translate(Margin,Margin);
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(MinimumWidth,0.0d);
             ctx.RelLineTo(0.0d,5.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowDownPattern;
             ctx.Fill();
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(0.0d,siz.Y);
             ctx.RelLineTo(5.0d,0.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowRightPattern;
             ctx.Fill();
         }
         else {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Color = KnownColors.Black;
             ctx.Translate(Margin,Margin);
             ipp.Paint(ctx);
         }
         ctx.Restore();
         subpieces[index] = new Rectangle(x0+Margin,2.0d*Margin,siz.X,siz.Y);
         x0 += siz.X+3.0d*Margin;
         if(index >= NumberOfArguments-NumberOfOptionalArguments) {
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+te.Width),siz.Y+3.0d*Margin-2.0d);
             ctx.ShowText(OptionalString);
         }
         if(this.ArgumentNames != null && index < arguments.Length) {
             ten = ctx.TextExtents(this.ArgumentNames[index]);
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+ten.Width),-te.YBearing+Margin+2.0d);
             ctx.ShowText(this.ArgumentNames[index]);
         }
         index++;
     }
 }