Example #1
0
        protected override void GeneratePattern()
        {
            var square_size = HexVal(0, 1).MapTo(0, 15, 10, 60);

            Svg.Width  = square_size * 6;
            Svg.Height = square_size * 6;

            var i = 0;

            for (var y = 0; y <= 5; y++)
            {
                for (var x = 0; x <= 5; x++)
                {
                    var val     = HexVal(i, 1);
                    var opacity = Opacity(val);
                    var fill    = FillColor(val);

                    Svg.Rect(x * square_size, y * square_size, square_size, square_size, new Dictionary <string, object> {
                        { "fill", fill },
                        { "fill-opacity", opacity },
                        { "stroke", Options["stroke_color"] },
                        { "stroke-opacity", Options["stroke_opacity"] }
                    });

                    i++;
                }
            }
        }
Example #2
0
        protected override void GeneratePattern()
        {
            var block_size  = HexVal(0, 1).MapTo(0, 15, 4, 12);
            var square_size = block_size * 7;

            Svg.Width  = (square_size + block_size) * 6 + block_size * 6;
            Svg.Height = (square_size + block_size) * 6 + block_size * 6;

            var i = 0;

            for (var y = 0; y <= 5; y++)
            {
                for (var x = 0; x <= 5; x++)
                {
                    var val     = HexVal(i, 1);
                    var opacity = Opacity(val);
                    var fill    = FillColor(val);

                    var styles = new Dictionary <string, object> {
                        { "fill", "none" },
                        { "stroke", fill },
                        {
                            "style", new Dictionary <string, object> {
                                { "opacity", opacity },
                                { "stroke-width", block_size + "px" }
                            }
                        }
                    };

                    Svg.Rect(x * square_size + x * block_size * 2 + block_size / 2,
                             y * square_size + y * block_size * 2 + block_size / 2,
                             square_size, square_size, styles);

                    val     = HexVal(39 - i, 1);
                    opacity = Opacity(val);
                    fill    = FillColor(val);

                    styles = new Dictionary <string, object> {
                        { "fill", "none" },
                        { "stroke", fill },
                        {
                            "style", new Dictionary <string, object> {
                                { "opacity", opacity },
                                { "stroke-width", block_size + "px" }
                            }
                        }
                    };

                    Svg.Rect(x * square_size + x * block_size * 2 + block_size / 2 + block_size * 2,
                             y * square_size + y * block_size * 2 + block_size / 2 + block_size * 2,
                             block_size * 3, block_size * 3, styles);

                    i++;
                }
            }
        }
Example #3
0
        protected override void GeneratePattern()
        {
            var height = 0.0;
            var width  = 0.0;

            // horizontal stripes
            var i = 0;

            for (var j = 0; j < 18; j++)
            {
                var space = HexVal(i, 1);
                height += space + 5;

                var val           = HexVal(i + 1, 1);
                var opacity       = Opacity(val);
                var fill          = FillColor(val);
                var stripe_height = val + 5;

                Svg.Rect(0, height, "100%", stripe_height, new Dictionary <string, object> {
                    { "opacity", opacity },
                    { "fill", fill }
                });

                height += stripe_height;
                i      += 2;
            }

            // vertical stripes
            i = 0;
            for (var j = 0; j < 18; j++)
            {
                var space = HexVal(i, 1);
                width += space + 5;

                var val          = HexVal(i + 1, 1);
                var opacity      = Opacity(val);
                var fill         = FillColor(val);
                var stripe_width = val + 5;

                Svg.Rect(width, 0, stripe_width, "100%", new Dictionary <string, object> {
                    { "opacity", opacity },
                    { "fill", fill }
                });

                width += stripe_width;
                i     += 2;
            }

            Svg.Width  = width;
            Svg.Height = height;
        }
Example #4
0
        protected void GenerateBackground()
        {
            var hueOffset = HexVal(14, 3).MapTo(0, 4095, 0, 1);
            var satOffset = HexVal(17, 1);
            var baseColor = new HSLColor(ColorTranslator.FromHtml((string)Options["base_color"]));

            baseColor.Hue        -= hueOffset;
            baseColor.Saturation += satOffset % 2 == 0 ? satOffset : -satOffset;
            Color rgb = baseColor;

            Svg.Rect(0, 0, "100%", "100%", new Dictionary <string, object>
            {
                { "fill", string.Format("rgb({0}, {1}, {2})", rgb.R, rgb.G, rgb.B) }
            });
        }
        protected override void GeneratePattern()
        {
            // 3.4.6.4 semi-regular tessellation
            var side_length     = HexVal(0, 1).MapTo(0, 15, 5, 40);
            var hex_height      = side_length * Math.Sqrt(3);
            var hex_width       = side_length * 2;
            var triangle_height = side_length / 2 * Math.Sqrt(3);
            var triangle        = build_rotated_triangle_shape(side_length, triangle_height);
            var tile_width      = side_length * 3 + triangle_height * 2;
            var tile_height     = (hex_height * 2) + (side_length * 2);

            Svg.Width  = tile_width;
            Svg.Height = tile_height;

            for (var i = 0; i <= 19; i++)
            {
                var val     = HexVal(i, 1);
                var opacity = Opacity(val);
                var fill    = FillColor(val);

                var styles = new Dictionary <string, object> {
                    { "stroke", Options["stroke_color"] },
                    { "stroke-opacity", Options["stroke_opacity"] },
                    { "fill", fill },
                    { "fill-opacity", opacity },
                    { "stroke-width", 1 }
                };

                switch (i)
                {
                case 0:     // all 4 corners
                    Svg.Rect(-side_length / 2, -side_length / 2, side_length, side_length, styles);
                    Svg.Rect(tile_width - side_length / 2, -side_length / 2, side_length, side_length, styles);
                    Svg.Rect(-side_length / 2, tile_height - side_length / 2, side_length, side_length, styles);
                    Svg.Rect(tile_width - side_length / 2, tile_height - side_length / 2, side_length, side_length, styles);
                    break;

                case 1:     // center / top square
                    Svg.Rect(hex_width / 2 + triangle_height, hex_height / 2, side_length, side_length, styles);
                    break;

                case 2:     // side squares
                    Svg.Rect(-side_length / 2, tile_height / 2 - side_length / 2, side_length, side_length, styles);
                    Svg.Rect(tile_width - side_length / 2, tile_height / 2 - side_length / 2, side_length, side_length, styles);
                    break;

                case 3:     // center / bottom square
                    Svg.Rect(hex_width / 2 + triangle_height, hex_height * 1.5 + side_length, side_length, side_length, styles);
                    break;

                case 4:                                                                                                                                                                                            // left top / bottom triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) rotate(0, {2}, {3})", side_length / 2, -side_length / 2, side_length / 2, triangle_height / 2)));
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) rotate(0, {2}, {3}) scale(1, -1)", side_length / 2, tile_height + side_length / 2, side_length / 2, triangle_height / 2))); // arg {1} was --, now +
                    break;

                case 5:     // right top / bottom triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) rotate(0, {2}, {3}) scale(-1, 1)", tile_width - side_length / 2, -side_length / 2, side_length / 2, triangle_height / 2)));
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) rotate(0, {2}, {3}) scale(-1, -1)", tile_width - side_length / 2, tile_height + side_length / 2, side_length / 2, triangle_height / 2)));
                    break;

                case 6:     // center / top / right triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1})", tile_width / 2 + side_length / 2, hex_height / 2)));
                    break;

                case 7:     // center / top / left triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(-1, 1)", tile_width - tile_width / 2 - side_length / 2, hex_height / 2)));
                    break;

                case 8:     // center / bottom / right triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(1, -1)", tile_width / 2 + side_length / 2, tile_height - hex_height / 2)));
                    break;

                case 9:     // center / bottom / left triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(-1, -1)", tile_width - tile_width / 2 - side_length / 2, tile_height - hex_height / 2)));
                    break;

                case 10:     // left / middle triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1})", side_length / 2, tile_height / 2 - side_length / 2)));
                    break;

                case 11:     // right / middle triangle
                    Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(-1, 1)", tile_width - side_length / 2, tile_height / 2 - side_length / 2)));
                    break;

                case 12:     // left / top square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("translate({0}, {1}) rotate(-30, 0, 0)", side_length / 2, side_length / 2)));
                    break;

                case 13:     // right / top square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("scale(-1, 1) translate({0}, {1}) rotate(-30, 0, 0)", -tile_width + side_length / 2, side_length / 2)));
                    break;

                case 14:     // left / center-top square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("translate({0}, {1}) rotate(30, 0, {2})", side_length / 2, tile_height / 2 - side_length / 2 - side_length, side_length)));
                    break;

                case 15:     // right / center-top square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("scale(-1, 1) translate({0}, {1}) rotate(30, 0, {2})", -tile_width + side_length / 2, tile_height / 2 - side_length / 2 - side_length, side_length)));
                    break;

                case 16:     // left / center-top square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("scale(1, -1) translate({0}, {1}) rotate(30, 0, {2})", side_length / 2, -tile_height + tile_height / 2 - side_length / 2 - side_length, side_length)));
                    break;

                case 17:     // right / center-bottom square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("scale(-1, -1) translate({0}, {1}) rotate(30, 0, {2})", -tile_width + side_length / 2, -tile_height + tile_height / 2 - side_length / 2 - side_length, side_length)));
                    break;

                case 18:     // left / bottom square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("scale(1, -1) translate({0}, {1}) rotate(-30, 0, 0)", side_length / 2, -tile_height + side_length / 2)));
                    break;

                case 19:     // right / bottom square
                    Svg.Rect(0, 0, side_length, side_length, styles.Merge(Transform("scale(-1, -1) translate({0}, {1}) rotate(-30, 0, 0)", -tile_width + side_length / 2, -tile_height + side_length / 2)));
                    break;
                }
            }
        }