void Line(Tesselate_Tests.Vertex Vertex1, Tesselate_Tests.Vertex Vertex2, double lineWidth, RendererBase renderer, bool ArrowTip)
        {
            PathStorage line = new PathStorage();

            line.move_to(Vertex1.m_X * m_Scale + m_XOffset, Vertex1.m_Y * m_Scale + m_YOffset);
            line.line_to(Vertex2.m_X * m_Scale + m_XOffset, Vertex2.m_Y * m_Scale + m_YOffset);

            // Drawing as an outline
            conv_stroke wideLine = new conv_stroke(line);

            wideLine.width(lineWidth);

            renderer.Render(wideLine, m_LineColor.GetAsRGBA_Bytes());

            if (ArrowTip)
            {
                Ellipse Dot = new Ellipse(
                    (Vertex2.m_X * m_Scale * 9 + Vertex1.m_X * m_Scale) / 10 + m_XOffset,
                    (Vertex2.m_Y * m_Scale * 9 + Vertex1.m_Y * m_Scale) / 10 + m_YOffset, 3, 3);
                GetRenderer().Render(Dot, m_LineColor.GetAsRGBA_Bytes());
            }
        }
        public override void OnDraw()
        {
            GetRenderer().Clear(new RGBA_Doubles(1, 1, 1));

            Tesselator tesselator = new Tesselator();

            tesselator.callBegin   += new Tesselator.CallBeginDelegate(BeginCallBack);
            tesselator.callEnd     += new Tesselator.CallEndDelegate(EndCallBack);
            tesselator.callVertex  += new Tesselator.CallVertexDelegate(VertexCallBack);
            tesselator.callCombine += new Tesselator.CallCombineDelegate(CombineCallBack);

            switch (m_WindingRule.cur_item())
            {
            case 0:
                tesselator.windingRule = Tesselator.WindingRuleType.Odd;
                break;

            case 1:
                tesselator.windingRule = Tesselator.WindingRuleType.NonZero;
                break;

            case 2:
                tesselator.windingRule = Tesselator.WindingRuleType.Positive;
                break;

            case 3:
                tesselator.windingRule = Tesselator.WindingRuleType.Negative;
                break;

            case 4:
                tesselator.windingRule = Tesselator.WindingRuleType.ABS_GEQ_Two;
                break;
            }

            if (m_EdgeFlag.status())
            {
                tesselator.callEdgeFlag += new Tesselator.CallEdgeFlagDelegate(EdgeFlagCallBack);
            }

            if (m_BoundryOnly.status()) // edgesOnly
            {
                tesselator.BoundaryOnly = true;
            }

            m_TesselateTest.ParseStreamForTesselator(tesselator, m_WhichShape.cur_item());

            // now render the outline
            {
                string[] instructionStream            = Tesselate_Tests.m_InsructionStream[m_WhichShape.cur_item()];
                bool     gotFirst                     = false;
                Tesselate_Tests.Vertex firstInContour = new Tesselate_Tests.Vertex(0, 0);
                bool havePrev = false;
                Tesselate_Tests.Vertex   prevVertex = new Tesselate_Tests.Vertex(0, 0);
                PathStorage              line       = new PathStorage();
                conv_stroke              wideLine;
                AGG.VertexSource.Ellipse Dot;

                for (int curInstruction = 0; curInstruction < instructionStream.Length; curInstruction++)
                {
                    switch (instructionStream[curInstruction])
                    {
                    case "BC":
                        break;

                    case "EC":
                        gotFirst = false;
                        havePrev = false;
                        line.remove_all();
                        line.move_to(prevVertex.m_X + 30, prevVertex.m_Y + 100);
                        line.line_to(firstInContour.m_X + 30, firstInContour.m_Y + 100);

                        // Drawing as an outline
                        wideLine = new conv_stroke(line);
                        wideLine.width(1);

                        GetRenderer().Render(wideLine, new RGBA_Bytes(0, 0, 0));

                        Dot = new Ellipse(
                            (firstInContour.m_X * 9 + prevVertex.m_X) / 10 + 30,
                            (firstInContour.m_Y * 9 + prevVertex.m_Y) / 10 + 100, 3, 3);
                        GetRenderer().Render(Dot, new RGBA_Bytes(0, 0, 0));
                        break;

                    case "V":
                        double x = Convert.ToDouble(instructionStream[curInstruction + 1]);
                        double y = Convert.ToDouble(instructionStream[curInstruction + 2]);
                        curInstruction += 2;
                        if (!gotFirst)
                        {
                            gotFirst       = true;
                            firstInContour = new Tesselate_Tests.Vertex(x, y);
                        }
                        if (!havePrev)
                        {
                            prevVertex = new Tesselate_Tests.Vertex(x, y);
                            havePrev   = true;
                        }
                        else
                        {
                            line.remove_all();
                            line.move_to(prevVertex.m_X + 30, prevVertex.m_Y + 100);
                            line.line_to(x + 30, y + 100);

                            // Drawing as an outline
                            wideLine = new conv_stroke(line);
                            wideLine.width(1);

                            GetRenderer().Render(wideLine, new RGBA_Bytes(0, 0, 0));

                            line.remove_all();
                            Dot = new Ellipse(
                                (x * 9 + prevVertex.m_X) / 10 + 30,
                                (y * 9 + prevVertex.m_Y) / 10 + 100, 3, 3);
                            GetRenderer().Render(Dot, new RGBA_Bytes(0, 0, 0));

                            prevVertex = new Tesselate_Tests.Vertex(x, y);
                        }
                        break;
                    }
                }
            }

            base.OnDraw();
        }
Beispiel #3
0
        public override void on_draw()
        {
            pixfmt_alpha_blend_rgb pf       = new pixfmt_alpha_blend_rgb(rbuf_window(), new blender_bgr());
            renderer_base          ren_base = new renderer_base(pf);

            ren_base.clear(new rgba(1.0, 1.0, 0.95));
            renderer_scanline_aa_solid ren = new renderer_scanline_aa_solid(ren_base);

            rasterizer_scanline_aa ras = new rasterizer_scanline_aa();
            scanline_unpacked_8    sl  = new scanline_unpacked_8();

            path_storage path = new path_storage(new vertex_block_storage());

            double x, y;
            double curve_time = 0;

            path.remove_all();
            curve4 curve;

            curve.approximation_method(curve_approximation_method_e(m_curve_type.cur_item()));
            curve.approximation_scale(m_approximation_scale.value());
            curve.angle_tolerance(deg2rad(m_angle_tolerance.value()));
            curve.cusp_limit(deg2rad(m_cusp_limit.value()));
            curve_time = measure_time(curve);
            double max_angle_error_01  = 0;
            double max_angle_error_1   = 0;
            double max_angle_error1    = 0;
            double max_angle_error_10  = 0;
            double max_angle_error_100 = 0;
            double max_error_01        = 0;
            double max_error_1         = 0;
            double max_error1          = 0;
            double max_error_10        = 0;
            double max_error_100       = 0;

            max_error_01  = calc_max_error(curve, 0.01, &max_angle_error_01);
            max_error_1   = calc_max_error(curve, 0.1, &max_angle_error_1);
            max_error1    = calc_max_error(curve, 1, &max_angle_error1);
            max_error_10  = calc_max_error(curve, 10, &max_angle_error_10);
            max_error_100 = calc_max_error(curve, 100, &max_angle_error_100);

            curve.approximation_scale(m_approximation_scale.value());
            curve.angle_tolerance(deg2rad(m_angle_tolerance.value()));
            curve.cusp_limit(deg2rad(m_cusp_limit.value()));
            curve.init(m_curve1.x1(), m_curve1.y1(),
                       m_curve1.x2(), m_curve1.y2(),
                       m_curve1.x3(), m_curve1.y3(),
                       m_curve1.x4(), m_curve1.y4());

            path.concat_path(curve);
//path.move_to(m_curve1.x1(), m_curve1.y1());
//path.line_to(m_curve1.x2(), m_curve1.y2());
//path.line_to(m_curve1.x3(), m_curve1.y3());
//path.line_to(m_curve1.x4(), m_curve1.y4());


            conv_stroke stroke = new conv_stroke(path);

            stroke.width(m_width.value());
            stroke.line_join(line_join_e(m_line_join.cur_item()));
            stroke.line_cap(line_cap_e(m_line_cap.cur_item()));
            stroke.inner_join(inner_join_e(m_inner_join.cur_item()));
            stroke.inner_miter_limit(1.01);

            ras.add_path(stroke);
            ren.color(rgba(0, 0.5, 0, 0.5));
            render_scanlines(ras, sl, ren);

            uint cmd;
            uint num_points1 = 0;

            path.rewind(0);
            while (!is_stop(cmd = path.vertex(&x, &y)))
            {
                if (m_show_points.status())
                {
                    Shape.Ellipse ell = new agg.Shape.Ellipse(x, y, 1.5, 1.5, 8);
                    ras.add_path(ell);
                    ren.color(rgba(0, 0, 0, 0.5));
                    render_scanlines(ras, sl, ren);
                }
                ++num_points1;
            }

            if (m_show_outline.status())
            {
                // Draw a stroke of the stroke to see the internals
                //--------------
                conv_stroke stroke2 = new conv_stroke(stroke);
                ras.add_path(stroke2);
                ren.color(rgba(0, 0, 0, 0.5));
                render_scanlines(ras, sl, ren);
            }

            // Check ellipse and arc for the number of points
            //---------------
            //ellipse a(100, 100, m_width.value(), m_width.value(), 0);
            //ras.add_path(a);
            //ren.color(rgba(0.5,0,0, 0.5));
            //render_scanlines(ras, sl, ren);
            //a.rewind(0);
            //while(!is_stop(cmd = a.vertex(&x, &y)))
            //{
            //    if(is_vertex(cmd))
            //    {
            //        ellipse ell(x, y, 1.5, 1.5, 8);
            //        ras.add_path(ell);
            //        ren.color(rgba(0,0,0,0.5));
            //        render_scanlines(ras, sl, ren);
            //    }
            //}


            // Check a circle with huge radius (10,000,000) and high approximation accuracy
            //---------------
            //double circle_pnt_count = 0;
            //bezier_arc ell(0,0, 10000000, 10000000, 0, 2*pi);
            //conv_curve<bezier_arc, curve3_div, curve4_div3> crv(ell);
            //crv.approximation_scale(10.0);
            //crv.rewind(0);
            //while(crv.vertex(&x, &y)) ++circle_pnt_count;


            string   buf;
            gsv_text t;

            t.size(8.0);

            conv_stroke pt = new conv_stroke(t);

            pt.line_cap(round_cap);
            pt.line_join(round_join);
            pt.width(1.5);

            /*
             * sprintf(buf, "Num Points=%d Time=%.2fmks\n\n"
             *           " Dist Error: x0.01=%.5f x0.1=%.5f x1=%.5f x10=%.5f x100=%.5f\n\n"
             *           "Angle Error: x0.01=%.1f x0.1=%.1f x1=%.1f x10=%.1f x100=%.1f",
             *      num_points1, curve_time,
             *      max_error_01,
             *      max_error_1,
             *      max_error1,
             *      max_error_10,
             *      max_error_100,
             *      max_angle_error_01,
             *      max_angle_error_1,
             *      max_angle_error1,
             *      max_angle_error_10,
             *      max_angle_error_100);
             */

            t.start_point(10.0, 85.0);
            t.text(buf);

            ras.add_path(pt);
            ren.color(rgba(0, 0, 0));
            render_scanlines(ras, sl, ren);

            render_ctrl(ras, sl, ren_base, m_curve1);
            render_ctrl(ras, sl, ren_base, m_angle_tolerance);
            render_ctrl(ras, sl, ren_base, m_approximation_scale);
            render_ctrl(ras, sl, ren_base, m_cusp_limit);
            render_ctrl(ras, sl, ren_base, m_width);
            render_ctrl(ras, sl, ren_base, m_show_points);
            render_ctrl(ras, sl, ren_base, m_show_outline);
            render_ctrl(ras, sl, ren_base, m_curve_type);
            render_ctrl(ras, sl, ren_base, m_case_type);
            render_ctrl(ras, sl, ren_base, m_inner_join);
            render_ctrl(ras, sl, ren_base, m_line_join);
            render_ctrl(ras, sl, ren_base, m_line_cap);
        }
Beispiel #4
0
    public override void on_draw()
    {
        pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(rbuf_window(), new blender_bgr());
        renderer_base ren_base = new renderer_base(pf);
        ren_base.clear(new rgba(1.0, 1.0, 0.95));
        renderer_scanline_aa_solid ren = new renderer_scanline_aa_solid(ren_base);

        rasterizer_scanline_aa ras = new rasterizer_scanline_aa();
        scanline_unpacked_8 sl = new scanline_unpacked_8();

        path_storage path = new path_storage(new vertex_block_storage());

        double x, y;
        double curve_time = 0;

        path.remove_all();
        curve4 curve;
        curve.approximation_method(curve_approximation_method_e(m_curve_type.cur_item()));
        curve.approximation_scale(m_approximation_scale.value());
        curve.angle_tolerance(deg2rad(m_angle_tolerance.value()));
        curve.cusp_limit(deg2rad(m_cusp_limit.value()));
        curve_time = measure_time(curve);
        double max_angle_error_01 = 0;
        double max_angle_error_1 = 0;
        double max_angle_error1 = 0;
        double max_angle_error_10 = 0;
        double max_angle_error_100 = 0;
        double max_error_01 = 0;
        double max_error_1 = 0;
        double max_error1 = 0;
        double max_error_10 = 0;
        double max_error_100 = 0;

        max_error_01   = calc_max_error(curve, 0.01, &max_angle_error_01);
        max_error_1    = calc_max_error(curve, 0.1,  &max_angle_error_1);
        max_error1     = calc_max_error(curve, 1,    &max_angle_error1);
        max_error_10   = calc_max_error(curve, 10,   &max_angle_error_10);
        max_error_100  = calc_max_error(curve, 100,  &max_angle_error_100);

        curve.approximation_scale(m_approximation_scale.value());
        curve.angle_tolerance(deg2rad(m_angle_tolerance.value()));
        curve.cusp_limit(deg2rad(m_cusp_limit.value()));
        curve.init(m_curve1.x1(), m_curve1.y1(),
                   m_curve1.x2(), m_curve1.y2(),
                   m_curve1.x3(), m_curve1.y3(),
                   m_curve1.x4(), m_curve1.y4());

        path.concat_path(curve);
//path.move_to(m_curve1.x1(), m_curve1.y1());
//path.line_to(m_curve1.x2(), m_curve1.y2());
//path.line_to(m_curve1.x3(), m_curve1.y3());
//path.line_to(m_curve1.x4(), m_curve1.y4());


        conv_stroke stroke = new conv_stroke(path);
        stroke.width(m_width.value());
        stroke.line_join(line_join_e(m_line_join.cur_item()));
        stroke.line_cap(line_cap_e(m_line_cap.cur_item()));
        stroke.inner_join(inner_join_e(m_inner_join.cur_item()));
        stroke.inner_miter_limit(1.01);

        ras.add_path(stroke);
        ren.color(rgba(0, 0.5, 0, 0.5));
        render_scanlines(ras, sl, ren);

        uint cmd;
        uint num_points1 = 0;
        path.rewind(0);
        while(!is_stop(cmd = path.vertex(&x, &y)))
        {
            if(m_show_points.status())
            {
                Shape.Ellipse ell = new agg.Shape.Ellipse(x, y, 1.5, 1.5, 8);
                ras.add_path(ell);
                ren.color(rgba(0,0,0, 0.5));
                render_scanlines(ras, sl, ren);
            }
            ++num_points1;
        }

        if(m_show_outline.status())
        {
            // Draw a stroke of the stroke to see the internals
            //--------------
            conv_stroke stroke2 = new conv_stroke(stroke);
            ras.add_path(stroke2);
            ren.color(rgba(0,0,0, 0.5));
            render_scanlines(ras, sl, ren);
        }

        // Check ellipse and arc for the number of points
        //---------------
        //ellipse a(100, 100, m_width.value(), m_width.value(), 0);
        //ras.add_path(a);
        //ren.color(rgba(0.5,0,0, 0.5));
        //render_scanlines(ras, sl, ren);
        //a.rewind(0);
        //while(!is_stop(cmd = a.vertex(&x, &y)))
        //{
        //    if(is_vertex(cmd))
        //    {
        //        ellipse ell(x, y, 1.5, 1.5, 8);
        //        ras.add_path(ell);
        //        ren.color(rgba(0,0,0,0.5));
        //        render_scanlines(ras, sl, ren);
        //    }
        //}


        // Check a circle with huge radius (10,000,000) and high approximation accuracy
        //---------------
        //double circle_pnt_count = 0;
        //bezier_arc ell(0,0, 10000000, 10000000, 0, 2*pi);
        //conv_curve<bezier_arc, curve3_div, curve4_div3> crv(ell);
        //crv.approximation_scale(10.0);
        //crv.rewind(0);
        //while(crv.vertex(&x, &y)) ++circle_pnt_count;


        string buf;
        gsv_text t;
        t.size(8.0);

        conv_stroke pt = new conv_stroke(t);
        pt.line_cap(round_cap);
        pt.line_join(round_join);
        pt.width(1.5);

        /*
        sprintf(buf, "Num Points=%d Time=%.2fmks\n\n"
                     " Dist Error: x0.01=%.5f x0.1=%.5f x1=%.5f x10=%.5f x100=%.5f\n\n"
                     "Angle Error: x0.01=%.1f x0.1=%.1f x1=%.1f x10=%.1f x100=%.1f", 
                num_points1, curve_time, 
                max_error_01,  
                max_error_1,   
                max_error1,   
                max_error_10,  
                max_error_100,
                max_angle_error_01,
                max_angle_error_1,
                max_angle_error1,
                max_angle_error_10,
                max_angle_error_100);
         */

        t.start_point(10.0, 85.0);
        t.text(buf);

        ras.add_path(pt);
        ren.color(rgba(0,0,0));
        render_scanlines(ras, sl, ren);

        render_ctrl(ras, sl, ren_base, m_curve1);
        render_ctrl(ras, sl, ren_base, m_angle_tolerance);
        render_ctrl(ras, sl, ren_base, m_approximation_scale);
        render_ctrl(ras, sl, ren_base, m_cusp_limit);
        render_ctrl(ras, sl, ren_base, m_width);
        render_ctrl(ras, sl, ren_base, m_show_points);
        render_ctrl(ras, sl, ren_base, m_show_outline);
        render_ctrl(ras, sl, ren_base, m_curve_type);
        render_ctrl(ras, sl, ren_base, m_case_type);
        render_ctrl(ras, sl, ren_base, m_inner_join);
        render_ctrl(ras, sl, ren_base, m_line_join);
        render_ctrl(ras, sl, ren_base, m_line_cap);
    }
Beispiel #5
0
        void Line(Tesselate_Tests.Vertex Vertex1, Tesselate_Tests.Vertex Vertex2, double lineWidth, RendererBase renderer, bool ArrowTip)
        {
            PathStorage line = new PathStorage();
            line.move_to(Vertex1.m_X * m_Scale + m_XOffset, Vertex1.m_Y * m_Scale + m_YOffset);
            line.line_to(Vertex2.m_X * m_Scale + m_XOffset, Vertex2.m_Y * m_Scale + m_YOffset);

            // Drawing as an outline
            conv_stroke wideLine = new conv_stroke(line);
            wideLine.width(lineWidth);

            renderer.Render(wideLine, m_LineColor.GetAsRGBA_Bytes());

            if(ArrowTip)
            {
                Ellipse Dot = new Ellipse(
                    (Vertex2.m_X * m_Scale * 9 + Vertex1.m_X * m_Scale) / 10 + m_XOffset,
                    (Vertex2.m_Y * m_Scale * 9 + Vertex1.m_Y * m_Scale) / 10 + m_YOffset, 3, 3);
                GetRenderer().Render(Dot, m_LineColor.GetAsRGBA_Bytes());
            }
        }
Beispiel #6
0
        public override void OnDraw()
        {
            GetRenderer().Clear(new RGBA_Doubles(1, 1, 1));

            Tesselator tesselator = new Tesselator();
            tesselator.callBegin += new Tesselator.CallBeginDelegate(BeginCallBack);
            tesselator.callEnd += new Tesselator.CallEndDelegate(EndCallBack);
            tesselator.callVertex += new Tesselator.CallVertexDelegate(VertexCallBack);
            tesselator.callCombine += new Tesselator.CallCombineDelegate(CombineCallBack);

            switch (m_WindingRule.cur_item())
            {
                case 0:
                    tesselator.windingRule = Tesselator.WindingRuleType.Odd;
                    break;

                case 1:
                    tesselator.windingRule = Tesselator.WindingRuleType.NonZero;
                    break;

                case 2:
                    tesselator.windingRule = Tesselator.WindingRuleType.Positive;
                    break;

                case 3:
                    tesselator.windingRule = Tesselator.WindingRuleType.Negative;
                    break;

                case 4:
                    tesselator.windingRule = Tesselator.WindingRuleType.ABS_GEQ_Two;
                    break;

            }

            if (m_EdgeFlag.status())
            {
                tesselator.callEdgeFlag += new Tesselator.CallEdgeFlagDelegate(EdgeFlagCallBack);
            }

            if (m_BoundryOnly.status()) // edgesOnly
            {
                tesselator.BoundaryOnly = true;
            }

            m_TesselateTest.ParseStreamForTesselator(tesselator, m_WhichShape.cur_item());

            // now render the outline
            {
                string[] instructionStream = Tesselate_Tests.m_InsructionStream[m_WhichShape.cur_item()];
                bool gotFirst = false;
                Tesselate_Tests.Vertex firstInContour = new Tesselate_Tests.Vertex(0, 0);
                bool havePrev = false;
                Tesselate_Tests.Vertex prevVertex = new Tesselate_Tests.Vertex(0,0);
                PathStorage line = new PathStorage();
                conv_stroke wideLine;
                AGG.VertexSource.Ellipse Dot;

                for (int curInstruction = 0; curInstruction < instructionStream.Length; curInstruction++)
                {
                    switch (instructionStream[curInstruction])
                    {
                        case "BC":
                            break;
                        
                        case "EC":
                            gotFirst = false;
                            havePrev = false;
                            line.remove_all();
                            line.move_to(prevVertex.m_X + 30, prevVertex.m_Y + 100);
                            line.line_to(firstInContour.m_X + 30, firstInContour.m_Y + 100);

                            // Drawing as an outline
                            wideLine = new conv_stroke(line);
                            wideLine.width(1);

                            GetRenderer().Render(wideLine, new RGBA_Bytes(0, 0, 0));

                            Dot = new Ellipse(
                                (firstInContour.m_X * 9 + prevVertex.m_X)/10 + 30,
                                (firstInContour.m_Y * 9 + prevVertex.m_Y)/10 +100, 3, 3);
                            GetRenderer().Render(Dot, new RGBA_Bytes(0, 0, 0));
                            break;
                        
                        case "V":
                            double x = Convert.ToDouble(instructionStream[curInstruction + 1]);
                            double y = Convert.ToDouble(instructionStream[curInstruction + 2]);
                            curInstruction += 2;
                            if (!gotFirst)
                            {
                                gotFirst = true;
                                firstInContour = new Tesselate_Tests.Vertex(x, y);
                            }
                            if (!havePrev)
                            {
                                prevVertex = new Tesselate_Tests.Vertex(x, y);
                                havePrev = true;
                            }
                            else
                            {
                                line.remove_all();
                                line.move_to(prevVertex.m_X + 30, prevVertex.m_Y + 100);
                                line.line_to(x + 30, y + 100);

                                // Drawing as an outline
                                wideLine = new conv_stroke(line);
                                wideLine.width(1);

                                GetRenderer().Render(wideLine, new RGBA_Bytes(0, 0, 0));

                                line.remove_all();
                                Dot = new Ellipse(
                                    (x * 9 + prevVertex.m_X) / 10 + 30,
                                    (y * 9 + prevVertex.m_Y) / 10 + 100, 3, 3);
                                GetRenderer().Render(Dot, new RGBA_Bytes(0, 0, 0));

                                prevVertex = new Tesselate_Tests.Vertex(x, y);
                            }
                            break;
                    }
                }
            }

            base.OnDraw();
        }
Beispiel #7
0
        public override void OnDraw(RendererBase renderer)
        {
            GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.value());
            IBlender NormalBlender = new BlenderBGRA();
            IBlender GammaBlender = new BlenderGammaBGRA(gamma);
            ImageBuffer rasterNormal = new ImageBuffer(NewRenderer().DestImage, NormalBlender);
            ImageBuffer rasterGamma = new ImageBuffer(NewRenderer().DestImage, GammaBlender);
            ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal);
            ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma);

            clippingProxyNormal.clear(new RGBA_Doubles(0,0,0));

            rasterizer_scanline_aa ras = new rasterizer_scanline_aa();
            scanline_packed_8 sl = new scanline_packed_8();

            VertexSource.Ellipse e = new VertexSource.Ellipse();

            // TODO: If you drag the control circles below the bottom of the window we get an exception.  This does not happen in AGG.
            // It needs to be debugged.  Turning on clipping fixes it.  But standard agg works without clipping.  Could be a bigger problem than this.
            //ras.clip_box(0, 0, width(), height());

            // Render two "control" circles
            e.init(m_x[0], m_y[0], 3, 3, 16);
            ras.add_path(e);
            Renderer.RenderSolid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
            e.init(m_x[1], m_y[1], 3, 3, 16);
            ras.add_path(e);
            Renderer.RenderSolid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));

            // Creating a rounded rectangle
            VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0], m_y[0], m_x[1], m_y[1], 10);
            r.normalize_radius();

            // Drawing as an outline
                conv_stroke p = new conv_stroke(r);
                p.width(1.0);
                ras.add_path(p);

                //Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(0, 0, 0));
            Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(255, 1, 1));








            /*            
                    int i;

                    // radial line test
                    //-------------------------
                    dashed_line<rasterizer_type, 
                                renderer_scanline_type, 
                                scanline_type> dash(ras, ren_sl, sl);

                    double cx = width() / 2.0;
                    double cy = height() / 2.0;

                    ren_sl.color(agg::rgba(1.0, 1.0, 1.0, 0.2));
                    for(i = 180; i > 0; i--) 
                    {
                        double n = 2.0 * agg::pi * i / 180.0;
                        dash.draw(cx + min(cx, cy) * sin(n), cy + min(cx, cy) * cos(n),
                                  cx, cy, 
                                  1.0, (i < 90) ? i : 0.0);
                    }


                    typedef agg::gradient_x gradient_func_type;
                    typedef agg::span_interpolator_linear<> interpolator_type;
                    typedef agg::span_allocator<color_type> span_allocator_type;
                    typedef agg::pod_auto_array<color_type, 256> color_array_type;
                    typedef agg::span_gradient<color_type, 
                                               interpolator_type, 
                                               gradient_func_type, 
                                               color_array_type> span_gradient_type;

                    typedef agg::renderer_scanline_aa<renderer_base_type, 
                                                      span_allocator_type,
                                                      span_gradient_type> renderer_gradient_type;

                    gradient_func_type  gradient_func;                   // The gradient function
                    agg::trans_affine   gradient_mtx;                    // Affine transformer
                    interpolator_type   span_interpolator(gradient_mtx); // Span interpolator
                    span_allocator_type span_allocator;                  // Span Allocator
                    color_array_type    gradient_colors;                 // The gradient colors
                    span_gradient_type  span_gradient(span_interpolator, 
                                                      gradient_func, 
                                                      gradient_colors, 
                                                      0, 100);

                    renderer_gradient_type ren_gradient(ren_base, span_allocator, span_gradient);

                    dashed_line<rasterizer_type, 
                                renderer_gradient_type, 
                                scanline_type> dash_gradient(ras, ren_gradient, sl);

                    double x1, y1, x2, y2;

                    for(i = 1; i <= 20; i++)
                    {
                        ren_sl.color(agg::rgba(1,1,1));

                        // integral point sizes 1..20
                        //----------------
                        agg::ellipse ell;
            
                        ell.init(20 + i * (i + 1) + 0.5, 
                                 20.5, 
                                 i / 2.0, 
                                 i / 2.0, 
                                 8 + i);
                        ras.reset();
                        ras.add_path(ell);
                        agg::render_scanlines(ras, sl, ren_sl);
            

                        // fractional point sizes 0..2
                        //----------------
                        ell.init(18 + i * 4 + 0.5, 33 + 0.5, 
                                 i/20.0, i/20.0, 
                                 8);
                        ras.reset();
                        ras.add_path(ell);
                        agg::render_scanlines(ras, sl, ren_sl);


                        // fractional point positioning
                        //---------------
                        ell.init(18 + i * 4 + (i-1) / 10.0 + 0.5, 
                                 27 + (i - 1) / 10.0 + 0.5, 
                                 0.5, 0.5, 8);
                        ras.reset();
                        ras.add_path(ell);
                        agg::render_scanlines(ras, sl, ren_sl);


                        // integral line widths 1..20
                        //----------------
                        fill_color_array(gradient_colors, 
                                         agg::rgba(1,1,1), 
                                         agg::rgba(i % 2, (i % 3) * 0.5, (i % 5) * 0.25));

                        x1 = 20 + i* (i + 1);
                        y1 = 40.5;
                        x2 = 20 + i * (i + 1) + (i - 1) * 4;
                        y2 = 100.5;
                        calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
                        dash_gradient.draw(x1, y1, x2, y2, i, 0);


                        fill_color_array(gradient_colors, 
                                         agg::rgba(1,0,0), 
                                         agg::rgba(0,0,1));

                        // fractional line lengths H (red/blue)
                        //----------------
                        x1 = 17.5 + i * 4;
                        y1 = 107;
                        x2 = 17.5 + i * 4 + i/6.66666667;
                        y2 = 107;
                        calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
                        dash_gradient.draw(x1, y1, x2, y2, 1.0, 0);


                        // fractional line lengths V (red/blue)
                        //---------------
                        x1 = 18 + i * 4;
                        y1 = 112.5;
                        x2 = 18 + i * 4;
                        y2 = 112.5 + i / 6.66666667;
                        calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
                        dash_gradient.draw(x1, y1, x2, y2, 1.0, 0);

                        // fractional line positioning (red)
                        //---------------
                        fill_color_array(gradient_colors, 
                                         agg::rgba(1,0,0), 
                                         agg::rgba(1,1,1));
                        x1 = 21.5;
                        y1 = 120 + (i - 1) * 3.1;
                        x2 = 52.5;
                        y2 = 120 + (i - 1) * 3.1;
                        calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
                        dash_gradient.draw(x1, y1, x2, y2, 1.0, 0);


                        // fractional line width 2..0 (green)
                        fill_color_array(gradient_colors, 
                                         agg::rgba(0,1,0), 
                                         agg::rgba(1,1,1));
                        x1 = 52.5;
                        y1 = 118 + i * 3;
                        x2 = 83.5;
                        y2 = 118 + i * 3;
                        calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
                        dash_gradient.draw(x1, y1, x2, y2, 2.0 - (i - 1) / 10.0, 0);

                        // stippled fractional width 2..0 (blue)
                        fill_color_array(gradient_colors, 
                                         agg::rgba(0,0,1), 
                                         agg::rgba(1,1,1));
                        x1 = 83.5;
                        y1 = 119 + i * 3;
                        x2 = 114.5;
                        y2 = 119 + i * 3;
                        calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx);
                        dash_gradient.draw(x1, y1, x2, y2, 2.0 - (i - 1) / 10.0, 3.0);


                        ren_sl.color(agg::rgba(1,1,1));
                        if(i <= 10)
                        {
                            // integral line width, horz aligned (mipmap test)
                            //-------------------
                            dash.draw(125.5, 119.5 + (i + 2) * (i / 2.0),
                                      135.5, 119.5 + (i + 2) * (i / 2.0),
                                      i, 0.0);
                        }

                        // fractional line width 0..2, 1 px H
                        //-----------------
                        dash.draw(17.5 + i * 4, 192, 18.5 + i * 4, 192, i / 10.0, 0);

                        // fractional line positioning, 1 px H
                        //-----------------
                        dash.draw(17.5 + i * 4 + (i - 1) / 10.0, 186, 
                                  18.5 + i * 4 + (i - 1) / 10.0, 186,
                                  1.0, 0);
                    }


                    // Triangles
                    //---------------
                    for (int i = 1; i <= 13; i++) 
                    {
                        fill_color_array(gradient_colors, 
                                         agg::rgba(1,1,1), 
                                         agg::rgba(i % 2, (i % 3) * 0.5, (i % 5) * 0.25));
                        calc_linear_gradient_transform(width()  - 150, 
                                                       height() - 20 - i * (i + 1.5),
                                                       width()  - 20,  
                                                       height() - 20 - i * (i + 1),
                                                       gradient_mtx);
                        ras.reset();
                        ras.move_to_d(width() - 150, height() - 20 - i * (i + 1.5));
                        ras.line_to_d(width() - 20,  height() - 20 - i * (i + 1));
                        ras.line_to_d(width() - 20,  height() - 20 - i * (i + 2));
                        agg::render_scanlines(ras, sl, ren_gradient);
                    }
             */










            base.OnDraw(renderer);
        }