Exemplo n.º 1
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.RenderQuality = RenderQuality.Fast;
            Brush prevBrush = p.CurrentBrush;
            Brush selectedBrush;

            p.Clear(Color.White);

            switch (SelectedBrushKind)
            {
            default: throw new NotSupportedException();

            case BrushKind.SolidBrush:
                selectedBrush = _solidBrush;
                break;

            case BrushKind.LinearGradient:
                selectedBrush = _linearGrBrush;
                break;

            case BrushKind.CircularGradient:
                selectedBrush = _circularGrBrush;
                break;

            case BrushKind.PolygonGradient:
                selectedBrush = _polygonGradientBrush;
                break;
            }

            //
            p.CurrentBrush = selectedBrush;

            //special set for our GLPainter
            bool glPainter2MaskColor = false;

            DrawingGL.GLPainter glPainter = p as DrawingGL.GLPainter;
            if (glPainter != null)
            {
                glPainter2MaskColor        = glPainter.UseTwoColorsMask;
                glPainter.UseTwoColorsMask = EnableGLPainterTwoColorsMask;
            }

            //p.FillRect(0, 100, 500, 500);
            //p.FillRect(0, 200, 200, 50);

            if (UseClipRegion)
            {
                //fill vxs region1
                p.FillRegion(_triangleVxs);
                //fill vxs region2
                if (UseOffset)
                {
                    float prev_ox = p.OriginX;
                    float prev_oy = p.OriginY;
                    p.SetOrigin(100, 120);
                    p.FillRegion(_triangleVxs);
                    p.SetOrigin(prev_ox, prev_oy);//restore
                }
                else
                {
                    p.FillRegion(_triangleVxs2);
                }
            }
            else
            {
                p.Fill(_triangleVxs);
                if (UseOffset)
                {
                    float prev_ox = p.OriginX;
                    float prev_oy = p.OriginY;
                    p.SetOrigin(100, 120);
                    p.Fill(_triangleVxs);
                    p.SetOrigin(prev_ox, prev_oy);//restore
                }
                else
                {
                    p.Fill(_triangleVxs2);
                }
            }


            //-------------

            p.CurrentBrush = prevBrush;

            if (glPainter != null)
            {
                //restore
                glPainter.UseTwoColorsMask = glPainter2MaskColor;
            }
        }