Exemple #1
0
        public void Paint(Painter p, Bilinear tx)
        {
            //in this version, I can't apply bilinear tx to current tx matrix

            using (VgPaintArgsPool.Borrow(p, out var paintArgs))
            {
                paintArgs.PaintVisitHandler = (vxs, painterA) =>
                {
                    //use external painter handler
                    //draw only outline with its fill-color.
                    Drawing.Painter m_painter     = painterA.P;
                    Drawing.Color   prevFillColor = m_painter.FillColor;

                    m_painter.FillColor = m_painter.FillColor;

                    using (VxsTemp.Borrow(out var v1))
                    {
                        tx.TransformToVxs(vxs, v1);
                        m_painter.Fill(v1);
                    }
                    m_painter.FillColor = prevFillColor;
                };
                _vgVisElem.Paint(paintArgs);
            }
        }
Exemple #2
0
        public override void Draw(CanvasPainter p)
        {
            CanvasPainter painter = p;

            if (!didInit)
            {
                didInit = true;
                OnInitialize();
            }


            //-----------------------------------
            painter.Clear(ColorRGBA.White);
            //IImageReaderWriter backBuffer = ImageHelper.CreateChildImage(gx.DestImage, gx.GetClippingRect());
            //ChildImage image;
            //if (backBuffer.BitDepth == 32)
            //{
            //    image = new ChildImage(backBuffer, new PixelBlenderBGRA());
            //}
            //else
            //{
            //    if (backBuffer.BitDepth != 24)
            //    {
            //        throw new System.NotSupportedException();
            //    }
            //    image = new ChildImage(backBuffer, new PixelBlenderBGR());
            //}
            //ClipProxyImage dest = new ClipProxyImage(image);
            //gx.Clear(ColorRGBA.White);
            //gx.SetClippingRect(new RectInt(0, 0, Width, Height));
            //ScanlineRasToDestBitmapRenderer sclineRasToBmp = gx.ScanlineRasToDestBitmap;

            if (this.PerspectiveTransformType == Sample_Perspective.PerspectiveTransformType.Bilinear)
            {
                var      bound      = lionShape.Bounds;
                Bilinear txBilinear = Bilinear.RectToQuad(bound.Left,
                                                          bound.Bottom,
                                                          bound.Right,
                                                          bound.Top,
                                                          quadPolygonControl.GetInnerCoords());
                if (txBilinear.IsValid)
                {
                    painter.PaintSeries(txBilinear.TransformToVxs(lionShape.Path.Vxs),
                                        lionShape.Colors,
                                        lionShape.PathIndexList,
                                        lionShape.NumPaths);
                    RectD   lionBound = lionShape.Bounds;
                    Ellipse ell       = new Ellipse((lionBound.Left + lionBound.Right) * 0.5,
                                                    (lionBound.Bottom + lionBound.Top) * 0.5,
                                                    (lionBound.Right - lionBound.Left) * 0.5,
                                                    (lionBound.Top - lionBound.Bottom) * 0.5,
                                                    200);
                    VertexStore trans_ell = txBilinear.TransformToVxs(ell.MakeVxs());
                    painter.FillColor = ColorRGBA.Make(0.5f, 0.3f, 0.0f, 0.3f);
                    painter.Fill(trans_ell);
                    //-------------------------------------------------------------
                    //outline
                    double prevStrokeWidth = painter.StrokeWidth;
                    painter.StrokeWidth = 3;
                    painter.StrokeColor = ColorRGBA.Make(0.0f, 0.3f, 0.2f, 1.0f);
                    painter.Draw(trans_ell);
                    painter.StrokeWidth = prevStrokeWidth;
                }
            }
            else
            {
                var txPerspective = new Perspective(
                    lionShape.Bounds,
                    quadPolygonControl.GetInnerCoords());
                if (txPerspective.IsValid)
                {
                    painter.PaintSeries(txPerspective.TransformToVxs(lionShape.Path.Vxs),
                                        lionShape.Colors,
                                        lionShape.PathIndexList,
                                        lionShape.NumPaths);
                    //--------------------------------------------------------------------------------------
                    //filled Ellipse
                    //1. create original fill ellipse
                    RectD lionBound     = lionShape.Bounds;
                    var   filledEllipse = new Ellipse((lionBound.Left + lionBound.Right) * 0.5,
                                                      (lionBound.Bottom + lionBound.Top) * 0.5,
                                                      (lionBound.Right - lionBound.Left) * 0.5,
                                                      (lionBound.Top - lionBound.Bottom) * 0.5,
                                                      200);
                    VertexStore transformedEll = txPerspective.TransformToVxs(filledEllipse.MakeVxs());
                    painter.FillColor = ColorRGBA.Make(0.5f, 0.3f, 0.0f, 0.3f);
                    painter.Fill(transformedEll);
                    //--------------------------------------------------------
                    var prevStrokeW = painter.StrokeWidth;
                    painter.StrokeWidth = 3;
                    painter.StrokeColor = ColorRGBA.Make(0.0f, 0.3f, 0.2f, 1.0f);
                    painter.Draw(transformedEll);
                    painter.StrokeWidth = prevStrokeW;
                }
            }

            //--------------------------
            // Render the "quad" tool and controls
            painter.FillColor = ColorRGBA.Make(0f, 0.3f, 0.5f, 0.6f);
            painter.Fill(quadPolygonControl.MakeVxs());
        }