Exemple #1
0
        /// <summary>
        /// Draws the content of the control filling in all color values with the provided Luminance or Brightness value.
        /// </summary>
        private void Draw_Style_Luminance(Gdk.Window win)
        {
            //hack: use CAIRO instead of Systme.Drawing bug
            Cairo.Context context = Gdk.CairoHelper.Create(win);


            GraphUtil.HSL hsl_start = new GraphUtil.HSL();
            GraphUtil.HSL hsl_end   = new GraphUtil.HSL();
            hsl_start.L = m_hsl.L;
            hsl_end.L   = m_hsl.L;
            hsl_start.S = 1.0;
            hsl_end.S   = 0.0;

            for (int i = 0; i < this.Allocation.Width - 4; i++)                         //	For each vertical line in the control:
            {
                hsl_start.H = (double)i / (this.Allocation.Width - 4);                  //	Calculate Hue at this line (Saturation and Luminance are constant)
                hsl_end.H   = hsl_start.H;

                Cairo.LinearGradient gradient = new Cairo.LinearGradient(2, 2, 1, this.Allocation.Height - 4);
                gradient.AddColorStop(0, CairoUtil.ColorFromRgb(GraphUtil.HSL_to_RGB(hsl_start)));
                gradient.AddColorStop(1, CairoUtil.ColorFromRgb(GraphUtil.HSL_to_RGB(hsl_end)));

                context.Rectangle(i + 2, 2, 1, this.Allocation.Height - 4);
                context.Pattern = gradient;

                context.Fill();
            }

            context.Stroke();
            ((IDisposable)context).Dispose();
        }
Exemple #2
0
 private void DrawCenterFilledCircle(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, CairoUtil.ColorFromRgb(240, 235, 229, 0.3));
     pat.AddColorStop(1, CairoUtil.ColorFromRgb(0, 0, 0, 0.2));
     e.LineWidth = 0.1;
     e.Pattern   = pat;
     e.FillPreserve();
     e.Stroke();
 }