コード例 #1
0
ファイル: CairoBackend.cs プロジェクト: kuggaa/longomatch
        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();
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #4
0
ファイル: CairoBackend.cs プロジェクト: kuggaa/longomatch
 public void TranslateAndScale(Point translation, Point scale)
 {
     if (!disableScalling)
     {
         CContext.Translate(translation.X, translation.Y);
         CContext.Scale(scale.X, scale.Y);
     }
 }
コード例 #5
0
ファイル: CairoBackend.cs プロジェクト: kuggaa/longomatch
        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();
        }
コード例 #6
0
 public void TranslateAndScale(Point translation, Point scale)
 {
     CContext.Translate(translation.X, translation.Y);
     CContext.Scale(scale.X, scale.Y);
 }