Exemple #1
0
        public RectanglesModule()
        {
            Get["/examples/w3schools/rectangles/1"] = _ =>
            {
                var svg = new Svg(400, 110);

                svg
                .Rectangle(0, 0, 300, 100)
                .WithFill(0, 0, 255)
                .WithStrokeWidth(3)
                .WithStroke(0, 0, 0);

                return(Response.AsText(svg.ToString(), "image/svg+xml"));
            };

            Get["/examples/w3schools/rectangles/2"] = _ =>
            {
                var svg = new Svg(400, 180);

                svg.Rectangle(50, 20, 150, 150)
                .WithFill("blue")
                .WithStroke("pink")
                .WithStrokeWidth(5)
                .WithFillOpacity(0.1)
                .WithStrokeOpacity(0.9);

                return(Response.AsText(svg.ToString()).WithContentType("image/svg+xml"));
            };

            Get["/examples/w3schools/rectangles/3"] = _ =>
            {
                var svg = new Svg(400, 180);

                svg.Rectangle(50, 20, 150, 150)
                .WithFill("blue")
                .WithStroke("pink")
                .WithStrokeWidth(5)
                .WithOpacity(0.5);

                return(Response.AsText(svg.ToString()).WithContentType("image/svg+xml"));
            };

            Get["/examples/w3schools/rectangles/4"] = _ =>
            {
                var svg = new Svg(400, 180);

                svg.Rectangle(50, 20, 150, 150)
                .WithRoundedCorners(20, 20)
                .WithFill("red")
                .WithStroke("black")
                .WithStrokeWidth(5)
                .WithOpacity(0.5);

                return(Response.AsText(svg.ToString()).WithContentType("image/svg+xml"));
            };
        }
Exemple #2
0
        public RectanglesModule()
        {
            Get["/examples/w3schools/rectangles/1"] = _ =>
            {
                var svg = new Svg(400, 110);

                svg
                    .Rectangle(0, 0, 300, 100)
                    .WithFill(0, 0, 255)
                    .WithStrokeWidth(3)
                    .WithStroke(0, 0, 0);

                return Response.AsText(svg.ToString(), "image/svg+xml");
            };

            Get["/examples/w3schools/rectangles/2"] = _ =>
            {
                var svg = new Svg(400, 180);

                svg.Rectangle(50, 20, 150, 150)
                    .WithFill("blue")
                    .WithStroke("pink")
                    .WithStrokeWidth(5)
                    .WithFillOpacity(0.1)
                    .WithStrokeOpacity(0.9);

                return Response.AsText(svg.ToString()).WithContentType("image/svg+xml");
            };

            Get["/examples/w3schools/rectangles/3"] = _ =>
            {
                var svg = new Svg(400, 180);

                svg.Rectangle(50, 20, 150, 150)
                    .WithFill("blue")
                    .WithStroke("pink")
                    .WithStrokeWidth(5)
                    .WithOpacity(0.5);

                return Response.AsText(svg.ToString()).WithContentType("image/svg+xml");
            };

            Get["/examples/w3schools/rectangles/4"] = _ =>
            {
                var svg = new Svg(400, 180);

                svg.Rectangle(50, 20, 150, 150)
                    .WithRoundedCorners(20, 20)
                    .WithFill("red")
                    .WithStroke("black")
                    .WithStrokeWidth(5)
                    .WithOpacity(0.5);

                return Response.AsText(svg.ToString()).WithContentType("image/svg+xml");
            };
        }
Exemple #3
0
        public BlurEffectsModule()
        {
            Get["/examples/w3schools/blur-effects/1"] = _ =>
            {
                var svg = new Svg(110, 110);

                var f1 = svg.Defs.AddFilter();
                f1.GaussianBlur(15, FilterInput.SourceGraphic);

                svg
                    .Rectangle(0, 0, 90, 90)
                    .WithStroke("green")
                    .WithStrokeWidth(3)
                    .WithFill("yellow")
                    .WithFilter(f1);

                return Response.AsText(svg.ToString(), "image/svg+xml");
            };
        }
Exemple #4
0
        public BlurEffectsModule()
        {
            Get["/examples/w3schools/blur-effects/1"] = _ =>
            {
                var svg = new Svg(110, 110);

                var f1 = svg.Defs.AddFilter();
                f1.GaussianBlur(15, FilterInput.SourceGraphic);

                svg
                .Rectangle(0, 0, 90, 90)
                .WithStroke("green")
                .WithStrokeWidth(3)
                .WithFill("yellow")
                .WithFilter(f1);

                return(Response.AsText(svg.ToString(), "image/svg+xml"));
            };
        }
Exemple #5
0
        public ExamplesModule()
        {
            Get["/examples/w3schools/examples/1"] = _ =>
            {
                var svg = new Svg(120, 120);

                var filter = svg.Defs.AddFilter();
                filter.GaussianBlur(5);
                filter.Offset(5, 5);

                svg.Rectangle(0, 0, 90, 90).WithFill("grey").WithFilter(filter);
                svg.Rectangle(0, 0, 90, 90).WithFill("yellow").WithStroke("black");

                return Response.AsSvg(svg);
            };

            var decalSvg = new Svg(400, 200);
            decalSvg.Rectangle(1, 1, 198, 118).WithFill("#cccccc");
            var svgDecal = decalSvg.Group();
            svgDecal.Path("M50,90 C0,90 0,30 50,30 L150,30 C200,30 200,90 150,90 z")
                .WithFill("none")
                .WithStroke("#D90000")
                .WithStrokeWidth(10);
            svgDecal.Text(52, 76, "SVG")
                .WithFill("#FFFFFF")
                .WithStroke("black")
                .WithFontSize(45)
                .WithFontFamily("Verdana");

            Get["/examples/w3schools/examples/2"] = _ =>
            {
                var myFilter = decalSvg.Defs.AddFilter(0, 0, 200, 120)
                    .WithFilterUnits(FilterUnits.UserSpaceOnUse);
                myFilter.GaussianBlur(4, FilterInput.SourceAlpha, "blur");
                myFilter.Offset(4, 4, "blur", "offsetBlur");

                svgDecal.WithFilter(myFilter);

                return Response.AsSvg(decalSvg);
            };

            Get["/examples/w3schools/examples/3"] = _ =>
            {
                var myFilter = decalSvg.Defs.AddFilter(0, 0, 200, 120)
                    .WithFilterUnits(FilterUnits.UserSpaceOnUse);
                myFilter.GaussianBlur(4, FilterInput.SourceAlpha, "blur");
                myFilter.Offset(4, 4, "blur", "offsetBlur");
                myFilter.SpecularLighting(5, .75, 20, "#bbbbbb", "blur", "specOut")
                    .AddPointLight(-5000, -10000, 20000);

                svgDecal.WithFilter(myFilter);

                return Response.AsSvg(decalSvg);
            };

            Get["/examples/w3schools/examples/4"] = _ =>
            {
                var myFilter = decalSvg.Defs.AddFilter(0, 0, 200, 120)
                    .WithFilterUnits(FilterUnits.UserSpaceOnUse);
                myFilter.GaussianBlur(4, FilterInput.SourceAlpha, "blur");
                myFilter.Offset(4, 4, "blur", "offsetBlur");
                myFilter.SpecularLighting(5, .75, 20, "#bbbbbb", "blur", "specOut")
                    .AddPointLight(-5000, -10000, 20000);
                myFilter.Composite("specOut", FilterInput.SourceAlpha, CompositeOperator.In, "specOut");

                svgDecal.WithFilter(myFilter);

                return Response.AsSvg(decalSvg);
            };
        }
Exemple #6
0
        public ExamplesModule()
        {
            Get["/examples/w3schools/examples/1"] = _ =>
            {
                var svg = new Svg(120, 120);

                var filter = svg.Defs.AddFilter();
                filter.GaussianBlur(5);
                filter.Offset(5, 5);

                svg.Rectangle(0, 0, 90, 90).WithFill("grey").WithFilter(filter);
                svg.Rectangle(0, 0, 90, 90).WithFill("yellow").WithStroke("black");

                return(Response.AsSvg(svg));
            };

            var decalSvg = new Svg(400, 200);

            decalSvg.Rectangle(1, 1, 198, 118).WithFill("#cccccc");
            var svgDecal = decalSvg.Group();

            svgDecal.Path("M50,90 C0,90 0,30 50,30 L150,30 C200,30 200,90 150,90 z")
            .WithFill("none")
            .WithStroke("#D90000")
            .WithStrokeWidth(10);
            svgDecal.Text(52, 76, "SVG")
            .WithFill("#FFFFFF")
            .WithStroke("black")
            .WithFontSize(45)
            .WithFontFamily("Verdana");

            Get["/examples/w3schools/examples/2"] = _ =>
            {
                var myFilter = decalSvg.Defs.AddFilter(0, 0, 200, 120)
                               .WithFilterUnits(FilterUnits.UserSpaceOnUse);
                myFilter.GaussianBlur(4, FilterInput.SourceAlpha, "blur");
                myFilter.Offset(4, 4, "blur", "offsetBlur");

                svgDecal.WithFilter(myFilter);

                return(Response.AsSvg(decalSvg));
            };

            Get["/examples/w3schools/examples/3"] = _ =>
            {
                var myFilter = decalSvg.Defs.AddFilter(0, 0, 200, 120)
                               .WithFilterUnits(FilterUnits.UserSpaceOnUse);
                myFilter.GaussianBlur(4, FilterInput.SourceAlpha, "blur");
                myFilter.Offset(4, 4, "blur", "offsetBlur");
                myFilter.SpecularLighting(5, .75, 20, "#bbbbbb", "blur", "specOut")
                .AddPointLight(-5000, -10000, 20000);

                svgDecal.WithFilter(myFilter);

                return(Response.AsSvg(decalSvg));
            };

            Get["/examples/w3schools/examples/4"] = _ =>
            {
                var myFilter = decalSvg.Defs.AddFilter(0, 0, 200, 120)
                               .WithFilterUnits(FilterUnits.UserSpaceOnUse);
                myFilter.GaussianBlur(4, FilterInput.SourceAlpha, "blur");
                myFilter.Offset(4, 4, "blur", "offsetBlur");
                myFilter.SpecularLighting(5, .75, 20, "#bbbbbb", "blur", "specOut")
                .AddPointLight(-5000, -10000, 20000);
                myFilter.Composite("specOut", FilterInput.SourceAlpha, CompositeOperator.In, "specOut");

                svgDecal.WithFilter(myFilter);

                return(Response.AsSvg(decalSvg));
            };
        }
Exemple #7
0
        public DropShadowsModule()
        {
            Get["/examples/w3schools/drop-shadows/1"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                    .WithWidth("200%")
                    .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceGraphic, "offOut");
                f1.Blend("offOut", FilterInput.SourceGraphic, BlendMode.Normal);

                svg
                    .Rectangle(0, 0, 90, 90)
                    .WithStroke("green")
                    .WithStrokeWidth(3)
                    .WithFill("yellow")
                    .WithFilter(f1);

                return Response.AsSvg(svg);
            };

            Get["/examples/w3schools/drop-shadows/2"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                    .WithWidth("200%")
                    .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceGraphic, "offOut");
                f1.GaussianBlur(10, "offOut", "blurOut");
                f1.Blend(FilterInput.SourceGraphic, "blurOut", BlendMode.Normal);

                svg
                    .Rectangle(0, 0, 90, 90)
                    .WithStroke("green")
                    .WithStrokeWidth(3)
                    .WithFill("yellow")
                    .WithFilter(f1);

                return Response.AsSvg(svg);
            };

            Get["/examples/w3schools/drop-shadows/3"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                    .WithWidth("200%")
                    .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceAlpha, "offOut");
                f1.GaussianBlur(10, "offOut", "blurOut");
                f1.Blend(FilterInput.SourceGraphic, "blurOut", BlendMode.Normal);

                svg
                    .Rectangle(0, 0, 90, 90)
                    .WithStroke("green")
                    .WithStrokeWidth(3)
                    .WithFill("yellow")
                    .WithFilter(f1);

                return Response.AsSvg(svg);
            };

            Get["/examples/w3schools/drop-shadows/4"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                    .WithWidth("200%")
                    .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceGraphic, "offOut");
                f1.ColorMatrix(resultName: "matrixOut", filterInput: "offOut", matrix: @"
            0.2,    0,      0,      0,  0,
            0,      0.2,    0,      0,  0,
            0,      0,      0.2,    0,  0,
            0,      0,      0,      1,  0
            ");
                f1.GaussianBlur(resultName: "blurOut", filterInput: "matrixOut", standardDeviation: 10);
                f1.Blend(FilterInput.SourceGraphic, "blurOut", BlendMode.Normal);

                svg
                    .Rectangle(0, 0, 90, 90)
                    .WithStroke("green")
                    .WithStrokeWidth(3)
                    .WithFill("yellow")
                    .WithFilter(f1);

                return Response.AsSvg(svg);
            };
        }
Exemple #8
0
        public DropShadowsModule()
        {
            Get["/examples/w3schools/drop-shadows/1"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                         .WithWidth("200%")
                         .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceGraphic, "offOut");
                f1.Blend("offOut", FilterInput.SourceGraphic, BlendMode.Normal);

                svg
                .Rectangle(0, 0, 90, 90)
                .WithStroke("green")
                .WithStrokeWidth(3)
                .WithFill("yellow")
                .WithFilter(f1);

                return(Response.AsSvg(svg));
            };

            Get["/examples/w3schools/drop-shadows/2"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                         .WithWidth("200%")
                         .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceGraphic, "offOut");
                f1.GaussianBlur(10, "offOut", "blurOut");
                f1.Blend(FilterInput.SourceGraphic, "blurOut", BlendMode.Normal);

                svg
                .Rectangle(0, 0, 90, 90)
                .WithStroke("green")
                .WithStrokeWidth(3)
                .WithFill("yellow")
                .WithFilter(f1);

                return(Response.AsSvg(svg));
            };

            Get["/examples/w3schools/drop-shadows/3"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                         .WithWidth("200%")
                         .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceAlpha, "offOut");
                f1.GaussianBlur(10, "offOut", "blurOut");
                f1.Blend(FilterInput.SourceGraphic, "blurOut", BlendMode.Normal);

                svg
                .Rectangle(0, 0, 90, 90)
                .WithStroke("green")
                .WithStrokeWidth(3)
                .WithFill("yellow")
                .WithFilter(f1);

                return(Response.AsSvg(svg));
            };

            Get["/examples/w3schools/drop-shadows/4"] = _ =>
            {
                var svg = new Svg(140, 140);

                var f1 = svg.Defs.AddFilter()
                         .WithWidth("200%")
                         .WithHeight("200%");
                f1.Offset(20, 20, FilterInput.SourceGraphic, "offOut");
                f1.ColorMatrix(resultName: "matrixOut", filterInput: "offOut", matrix: @"
0.2,    0,      0,      0,  0,
0,      0.2,    0,      0,  0,
0,      0,      0.2,    0,  0,
0,      0,      0,      1,  0
");
                f1.GaussianBlur(resultName: "blurOut", filterInput: "matrixOut", standardDeviation: 10);
                f1.Blend(FilterInput.SourceGraphic, "blurOut", BlendMode.Normal);

                svg
                .Rectangle(0, 0, 90, 90)
                .WithStroke("green")
                .WithStrokeWidth(3)
                .WithFill("yellow")
                .WithFilter(f1);

                return(Response.AsSvg(svg));
            };
        }