예제 #1
0
        void DrawingPanel_Paint(object sender, GUI.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            double scale = m_ScaleSlider.Value;

            e.Graphics.TranslateTransform(scale * m_x, scale * m_y);

            Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y);

            mtx.Scale(scale, scale, MatrixOrder.Append);
            mtx.Rotate(m_RotateSlider.Value, MatrixOrder.Append);
            //mtx.Translate(m_x, m_y, MatrixOrder.Append);

            m_SVGPath.Expand = m_ExpandSlider.Value;

            e.Graphics.Opacity = m_OpacitySlider.Value;
#if GEOMETRY_TRANSFORMATIONS
            m_SVGPath.Render(e.Graphics, mtx);
#else
            e.Graphics.Transform = mtx.ToMatrix();

            m_SVGPath.Render(e.Graphics);
#endif
        }
예제 #2
0
        protected override void OnPaint(GUI.PaintEventArgs e)
        {
            base.OnPaint(e);


            Bitmap bitmap = Bitmap;

            if (bitmap != null)
            {
                if (m_Opacity < 1)
                {
                    m_Opacity += OpacityIncrement;
                    if (m_Opacity > 1)
                    {
                        m_Opacity = 1;
                    }

                    Matrix4 mtx   = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y);
                    double  scale = m_Scale;
                    mtx.Scale(scale, scale, MatrixOrder.Append);
                    mtx.Rotate(m_Rotation, MatrixOrder.Append);
                    mtx.Multiply(Matrix4.CreateSkewing(m_SkewX / 500.0, m_SkewY / 500.0), MatrixOrder.Append);
                    mtx.Translate(m_x, m_y, MatrixOrder.Append);

                    using (Graphics graphics = Graphics.FromImage(bitmap))
                    {
                        graphics.Opacity = m_Opacity;
                        m_SVGPath.Render(graphics, mtx);
                    }
                }

                e.Graphics.DrawImage(bitmap);
            }
        }
예제 #3
0
        void PreviewPanel_Paint(object sender, GUI.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;


            //  Small Filled
            Matrix4 mtx   = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y);
            double  scale = m_SmallScale;

            mtx.Scale(scale, scale, MatrixOrder.Append);
            mtx.Rotate(m_RotateSlider.Value, MatrixOrder.Append);
            mtx.Translate(
                m_ScaleControl.Right + m_SVGPathBounds.Width * scale / 2 + 10,
                m_RotateControl.Bottom + m_SVGPathBounds.Height * scale / 2 + 10, MatrixOrder.Append);

            m_SVGPath.Render(e.Graphics, mtx);
        }
        void DrawingPanel_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;


            Matrix4 mtx = Matrix4.CreateTranslation(-m_SVGPathBounds.Center.X, -m_SVGPathBounds.Center.Y);

            mtx.Scale(m_Scale, m_Scale, MatrixOrder.Append);
            mtx.Translate(m_x, m_y, MatrixOrder.Append);


            ITransform transform = null;

            if (rbBilinear.IsChecked)
            {
                Bilinear tr = new Bilinear(
                    m_SVGPathScaledBounds.Left, m_SVGPathScaledBounds.Top,
                    m_SVGPathScaledBounds.Right, m_SVGPathScaledBounds.Bottom, m_PolygonElement.Polygon);

                if (tr.IsValid)
                {
                    transform = tr;
                }
            }
            else
            {
                Perspective tr = new Perspective(
                    m_SVGPathScaledBounds.Left, m_SVGPathScaledBounds.Top,
                    m_SVGPathScaledBounds.Right, m_SVGPathScaledBounds.Bottom, m_PolygonElement.Polygon);

                if (tr.IsValid() &&
                    Perspective.IsConvex(m_PolygonElement.Polygon))
                {
                    transform = tr;
                }
            }


            //
            GeometryTransformer transformer = null;

            if (transform != null)
            {
                transformer = new GeometryTransformer(transform);
            }


            // Render transformed SVG
            m_SVGPath.Render(e.Graphics, mtx, transformer);


            // Render transformed ellipse
            Point           center        = m_SVGPathScaledBounds.Center;
            EllipseGeometry FilledEllipse = new EllipseGeometry(center.X, center.Y, m_SVGPathScaledBounds.Width / 2, m_SVGPathScaledBounds.Height / 2, 200);

            GeometryStroke EllipseOutline = new GeometryStroke(FilledEllipse);

            EllipseOutline.Width = 3.0;


            Geometry TransformedFilledEllipse  = FilledEllipse;
            Geometry TransformedEllipesOutline = EllipseOutline;

            if (transform != null)
            {
                TransformedFilledEllipse  = new GeometryTransformer(FilledEllipse, transform);
                TransformedEllipesOutline = new GeometryTransformer(EllipseOutline, transform);
            }

            SmoothingMode saveSmoothingMode = e.Graphics.SmoothingMode;

            e.Graphics.SmoothingMode = SmoothingMode.None;
            {
                e.Graphics.FillGeometry(m_EllipseBrush, TransformedFilledEllipse);
            }
            e.Graphics.SmoothingMode = saveSmoothingMode;

            e.Graphics.FillGeometry(m_EllipsePen.Color, TransformedEllipesOutline);
        }