示例#1
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 virtual void SetupBackground()
        {
            background.Clear();
            Cairo.Context context = background.Create();

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

            double margin = Margin;

            //left curvature:
            context.MoveTo(-hlwidth, -hlwidth);
            context.CurveTo(margin * 0.33, -hlwidth,
                            margin * 0.5, Height * 0.4,
                            margin * 0.5, Height * 0.5);
            context.CurveTo(margin * 0.5, Height * 0.6,
                            margin * 0.66, Height - hlwidth,
                            margin - hlwidth, Height - hlwidth);


            //straight bottom:
            context.LineTo(Width - margin - hlwidth, Height - hlwidth);

            //right curvature:
            context.CurveTo(Width - margin * 0.66, Height - hlwidth,
                            Width - margin * 0.5, Height * 0.6,
                            Width - margin * 0.5, Height * 0.5);
            context.CurveTo(Width - margin * 0.5, Height * 0.4,
                            Width - margin * 0.33, -hlwidth,
                            Width - hlwidth, -hlwidth);

            //straight top:
            context.LineTo(-hlwidth, -hlwidth);
            context.ClosePath();

            context.LineWidth = lwidth;
            context.SetSourceRGBA(1.0, 1.0, 1.0, 1.0);
            context.StrokePreserve();
            context.SetSourceRGBA(1.0, 1.0, 1.0, 0.10);
            context.Fill();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
        public virtual void Update()
        {
            outline.Clear();
            Cairo.Context context = outline.Create();

            context.LineWidth = line_width;
            context.MoveTo(outline.Height * 0.5, 0.5);
            context.Arc(outline.Width - outline.Height * 0.5, outline.Height * 0.5, (outline.Height - line_width) * 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
            context.Arc(outline.Height * 0.5, outline.Height * 0.5, (outline.Height - line_width) * 0.5, 0.5 * Math.PI, 1.5 * Math.PI);
            context.ClosePath();
            context.SetSourceRGBA(1.0, 1.0, 1.0, 0.2);
            context.FillPreserve();
            context.SetSourceRGB(1.0, 1.0, 1.0);
            context.Stroke();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();

            handle.Update();
            handle.RaiseTop();
            arrow_left.Update();
            arrow_right.Update();
        }
示例#4
0
        /// <summary>
        /// Redraws the circle_prototype which is used for all circles as template.
        /// This means a new circle is drawn with cairo and stored in a texture.
        /// </summary>
        static private void UpdatePrototype (CairoTexture actor, double r, double g, double b, double a,
                                                   double arc, double a_r, double a_g, double a_b)
        {
            double size = (double)circle_size;

            actor.Clear();
            Cairo.Context context = actor.Create();


            Cairo.Gradient pattern = new Cairo.RadialGradient(size/2.0,size/2.0,size/3.0,
                                                            size/2.0,size/2.0,size/2.0);

            pattern.AddColorStop(0,new Cairo.Color (r,g,b,a));
            pattern.AddColorStop(1.0,new Cairo.Color (r,g,b,0.1));

            context.LineWidth = (double)size/5.0;
            context.Arc (size/2.0, size/2.0,
                         size/2.0-context.LineWidth/2.0,0,2*Math.PI);

            context.Save();

            context.Pattern = pattern;
            context.Fill();

            if (arc != 0) {

                context.LineWidth = (double)size/10.0;
                context.Arc (size/2.0, size/2.0,
                         size/2.0-context.LineWidth/2.0,-Math.PI/2.0,2*Math.PI*arc/100.0-Math.PI/2.0);

                Hyena.Log.Debug ("Arc prototype "+ arc);
                context.Color = new Cairo.Color (a_r,a_g,a_b,0.5);
                context.Stroke ();
            }
            ((IDisposable) context.Target).Dispose ();
            ((IDisposable) context).Dispose ();
        }