Exemple #1
0
        public void DrawImage(Point start, double width, double height, Image image, bool scale, bool masked = false)
        {
            double scaleX, scaleY;
            Point  offset;

            if (scale)
            {
                image.ScaleFactor((int)width, (int)height, out scaleX, out scaleY, out offset);
            }
            else
            {
                offset = new Point(0, 0);
                scaleX = width / image.Width;
                scaleY = height / image.Height;
            }
            CContext.Save();
            CContext.Translate(start.X + offset.X, start.Y + offset.Y);
            CContext.Scale(scaleX, scaleY);
            if (masked)
            {
                CContext.PushGroup();
                Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0);
                CContext.Paint();
                var src = CContext.PopGroup();
                SetColor(FillColor);
                CContext.Mask(src);
                src.Dispose();
            }
            else
            {
                Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0);
                CContext.Paint();
            }
            CContext.Restore();
        }
Exemple #2
0
        public void DrawSurface(Point start, double width, double height, ISurface surface, ScaleMode mode, bool masked = false)
        {
            //FIXME: This still needs support for masked surfaces
            double scaleX, scaleY;
            Point  offset;

            BaseImage <Pixbuf> .ScaleFactor((int)(surface.Width *surface.DeviceScaleFactor),
                                            (int)(surface.Height *surface.DeviceScaleFactor),
                                            (int)width, (int)height, mode, out scaleX, out scaleY, out offset);

            CContext.Save();
            CContext.Translate(offset.X + start.X, offset.Y + start.Y);
            CContext.Scale(scaleX, scaleY);
            if (masked)
            {
                CContext.PushGroup();
            }
            ImageSurface image = surface.Value as ImageSurface;

            CContext.SetSourceSurface(image, 0, 0);
            CContext.Rectangle(0, 0, image.Width, image.Height);
            CContext.Fill();
            if (masked)
            {
                var src = CContext.PopGroup();
                SetColor(FillColor);
                CContext.Mask(src);
                src.Dispose();
            }
            CContext.Restore();
        }
Exemple #3
0
        public void DrawImage(Point start, double width, double height, Image image, ScaleMode mode,
                              bool masked = false, float alpha = 1)
        {
            double scaleX, scaleY;
            Point  offset;

            BaseImage <Pixbuf> .ScaleFactor((int)(image.Width *image.DeviceScaleFactor),
                                            (int)(image.Height *image.DeviceScaleFactor),
                                            (int)width, (int)height, mode, out scaleX, out scaleY, out offset);

            CContext.Save();
            CContext.Translate(start.X + offset.X, start.Y + offset.Y);
            CContext.Scale(scaleX, scaleY);
            if (masked)
            {
                CContext.PushGroup();
                Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0);
                CContext.PaintWithAlpha(alpha);
                var src = CContext.PopGroup();
                SetColor(FillColor);
                CContext.Mask(src);
                src.Dispose();
            }
            else
            {
                Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0);
                CContext.PaintWithAlpha(alpha);
            }
            CContext.Restore();
        }
Exemple #4
0
 public void DrawCircleImage(Point center, double radius, Image image)
 {
     DrawCircle(center, radius);
     CContext.Save();
     CContext.Arc(center.X, center.Y, radius, 0, 2 * Math.PI);
     CContext.Clip();
     DrawImage(new Point(center.X - radius, center.Y - radius), radius * 2, radius * 2, image,
               ScaleMode.AspectFill, false);
     CContext.Restore();
 }
Exemple #5
0
        public void DrawEllipse(Point center, double axisX, double axisY)
        {
            double max = Math.Max(axisX, axisY);

            CContext.Save();
            CContext.Translate(center.X, center.Y);
            CContext.Scale(axisX / max, axisY / max);
            CContext.Arc(0, 0, max, 0, 2 * Math.PI);
            StrokeAndFill();
            CContext.Restore();
        }
Exemple #6
0
 public void End()
 {
     CContext.Restore();
     ClearOperation = savedClear;
     StrokeColor    = savedStrokeColor;
     FillColor      = savedFillColor;
     fSlant         = savedFSlant;
     fWeight        = savedFWeight;
     fAlignment     = savedAlignment;
     LineWidth      = savedLineWidth;
     FontSize       = savedFontSize;
     FontFamily     = savedFontFamily;
     LineStyle      = savedLineStyle;
 }
Exemple #7
0
        public void End()
        {
            CContext.Restore();
            ContextStatus cstatus = contextStatus.Pop();

            ClearOperation = cstatus.Clear;
            StrokeColor    = cstatus.StrokeColor;
            FillColor      = cstatus.FillColor;
            fSlant         = cstatus.FSlant;
            fWeight        = cstatus.FWeight;
            fAlignment     = cstatus.Alignment;
            LineWidth      = cstatus.LineWidth;
            FontSize       = cstatus.FontSize;
            FontFamily     = cstatus.FontFamily;
            LineStyle      = cstatus.LineStyle;
        }