Example #1
0
        public PathsModule()
        {
            Get["/examples/w3schools/paths/1"] = _ =>
            {
                var svg = new Svg(400, 210);

                svg.Path()
                    .MoveTo(150, 0)
                    .LineTo(75, 200)
                    .LineTo(225, 200)
                    .ClosePath();

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

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

                svg.Path()
                    .MoveTo(100, 350)
                    .LineToRelative(150, -300)
                    .ClosePath()
                    .WithStroke("red")
                    .WithStrokeWidth(3)
                    .WithFill("none");
                svg.Path()
                    .MoveTo(250, 50)
                    .LineToRelative(150, 300)
                    .ClosePath()
                    .WithStroke("red")
                    .WithStrokeWidth(3)
                    .WithFill("none");
                svg.Path()
                    .MoveTo(175, 200)
                    .LineToRelative(150, 0)
                    .ClosePath()
                    .WithStroke("green")
                    .WithStrokeWidth(3)
                    .WithFill("none");

                svg.Path()
                    .MoveTo(100, 350)
                    .QuadraticBezierRelative(150, -300, 300, 000)
                    .WithStroke("blue")
                    .WithStrokeWidth(5)
                    .WithFill("none");

                // Mark relevant points
                var relevantPoints = svg.Group()
                    .WithStrokeWidth(3)
                    .WithFill("black");
                relevantPoints.Circle(100, 350, 3);
                relevantPoints.Circle(250, 50, 3);
                relevantPoints.Circle(400, 350, 3);

                // Label the points
                var labels = svg.Group()
                    .WithFontSize(30)
                    .WithFontFamily("sans-serif")
                    .WithFill("black")
                    .WithStroke("none")
                    .WithTextAnchor(TextAnchor.Middle);
                labels.Text(100, 350, "A").WithDx(-30);
                labels.Text(250, 50, "B").WithDy(-10);
                labels.Text(400, 350, "C").WithDx(30);

                return Response.AsText(svg.ToString(), "image/svg+xml");
            };
        }
Example #2
0
        public PathsModule()
        {
            Get["/examples/w3schools/paths/1"] = _ =>
            {
                var svg = new Svg(400, 210);

                svg.Path()
                .MoveTo(150, 0)
                .LineTo(75, 200)
                .LineTo(225, 200)
                .ClosePath();

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

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

                svg.Path()
                .MoveTo(100, 350)
                .LineToRelative(150, -300)
                .ClosePath()
                .WithStroke("red")
                .WithStrokeWidth(3)
                .WithFill("none");
                svg.Path()
                .MoveTo(250, 50)
                .LineToRelative(150, 300)
                .ClosePath()
                .WithStroke("red")
                .WithStrokeWidth(3)
                .WithFill("none");
                svg.Path()
                .MoveTo(175, 200)
                .LineToRelative(150, 0)
                .ClosePath()
                .WithStroke("green")
                .WithStrokeWidth(3)
                .WithFill("none");

                svg.Path()
                .MoveTo(100, 350)
                .QuadraticBezierRelative(150, -300, 300, 000)
                .WithStroke("blue")
                .WithStrokeWidth(5)
                .WithFill("none");

                // Mark relevant points
                var relevantPoints = svg.Group()
                                     .WithStrokeWidth(3)
                                     .WithFill("black");
                relevantPoints.Circle(100, 350, 3);
                relevantPoints.Circle(250, 50, 3);
                relevantPoints.Circle(400, 350, 3);

                // Label the points
                var labels = svg.Group()
                             .WithFontSize(30)
                             .WithFontFamily("sans-serif")
                             .WithFill("black")
                             .WithStroke("none")
                             .WithTextAnchor(TextAnchor.Middle);
                labels.Text(100, 350, "A").WithDx(-30);
                labels.Text(250, 50, "B").WithDy(-10);
                labels.Text(400, 350, "C").WithDx(30);

                return(Response.AsText(svg.ToString(), "image/svg+xml"));
            };
        }
Example #3
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);
            };
        }
Example #4
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));
            };
        }
Example #5
0
        public StrokingModule()
        {
            Get["/examples/w3schools/stroking/1"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                    .Group()
                    .WithFill("none");
                group
                    .Path()
                    .WithStroke("red")
                    .MoveTo(5, 20)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStroke("blue")
                    .MoveTo(5, 40)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStroke("black")
                    .MoveTo(5, 60)
                    .LineToRelative(215, 0);

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

            Get["/examples/w3schools/stroking/2"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                    .Group()
                    .WithFill("none")
                    .WithStroke("black");
                group
                    .Path()
                    .WithStrokeWidth(2)
                    .MoveTo(5, 20)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStrokeWidth(4)
                    .MoveTo(5, 40)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStrokeWidth(6)
                    .MoveTo(5, 60)
                    .LineToRelative(215, 0);

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

            Get["/examples/w3schools/stroking/3"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                    .Group()
                    .WithFill("none")
                    .WithStroke("black")
                    .WithStrokeWidth(6);
                group
                    .Path()
                    .WithStrokeLinecap(StrokeLinecap.Butt)
                    .MoveTo(5, 20)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStrokeLinecap(StrokeLinecap.Round)
                    .MoveTo(5, 40)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStrokeLinecap(StrokeLinecap.Square)
                    .MoveTo(5, 60)
                    .LineToRelative(215, 0);

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

            Get["/examples/w3schools/stroking/4"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                    .Group()
                    .WithFill("none")
                    .WithStroke("black")
                    .WithStrokeWidth(4);
                group
                    .Path()
                    .WithStrokeDasharray(5, 5)
                    .MoveTo(5, 20)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStrokeDasharray(10,10)
                    .MoveTo(5, 40)
                    .LineToRelative(215, 0);
                group
                    .Path()
                    .WithStrokeDasharray(20,10,5,5,5,10)
                    .MoveTo(5, 60)
                    .LineToRelative(215, 0);

                return Response.AsText(svg.ToString(), "image/svg+xml");
            };
        }
Example #6
0
        public StrokingModule()
        {
            Get["/examples/w3schools/stroking/1"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                            .Group()
                            .WithFill("none");
                group
                .Path()
                .WithStroke("red")
                .MoveTo(5, 20)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStroke("blue")
                .MoveTo(5, 40)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStroke("black")
                .MoveTo(5, 60)
                .LineToRelative(215, 0);

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

            Get["/examples/w3schools/stroking/2"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                            .Group()
                            .WithFill("none")
                            .WithStroke("black");
                group
                .Path()
                .WithStrokeWidth(2)
                .MoveTo(5, 20)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStrokeWidth(4)
                .MoveTo(5, 40)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStrokeWidth(6)
                .MoveTo(5, 60)
                .LineToRelative(215, 0);

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

            Get["/examples/w3schools/stroking/3"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                            .Group()
                            .WithFill("none")
                            .WithStroke("black")
                            .WithStrokeWidth(6);
                group
                .Path()
                .WithStrokeLinecap(StrokeLinecap.Butt)
                .MoveTo(5, 20)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStrokeLinecap(StrokeLinecap.Round)
                .MoveTo(5, 40)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStrokeLinecap(StrokeLinecap.Square)
                .MoveTo(5, 60)
                .LineToRelative(215, 0);

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

            Get["/examples/w3schools/stroking/4"] = _ =>
            {
                var svg = new Svg(300, 80);

                var group = svg
                            .Group()
                            .WithFill("none")
                            .WithStroke("black")
                            .WithStrokeWidth(4);
                group
                .Path()
                .WithStrokeDasharray(5, 5)
                .MoveTo(5, 20)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStrokeDasharray(10, 10)
                .MoveTo(5, 40)
                .LineToRelative(215, 0);
                group
                .Path()
                .WithStrokeDasharray(20, 10, 5, 5, 5, 10)
                .MoveTo(5, 60)
                .LineToRelative(215, 0);

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