private void draw_inner_mosaic_tile(double x, double y, double triangle_size, int[] vals) { var triangle = build_right_triangle_shape(triangle_size); var opacity = Opacity(vals[0]); var fill = FillColor(vals[0]); var styles = new Dictionary <string, object> { { "stroke", Options["stroke_color"] }, { "stroke-opacity", Options["stroke_opacity"] }, { "fill-opacity", opacity }, { "fill", fill } }; Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(-1, 1)", x + triangle_size, y))); Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(1, -1)", x + triangle_size, y + triangle_size * 2))); opacity = Opacity(vals[1]); fill = FillColor(vals[1]); styles = new Dictionary <string, object> { { "stroke", Options["stroke_color"] }, { "stroke-opacity", Options["stroke_opacity"] }, { "fill-opacity", opacity }, { "fill", fill } }; Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(-1, -1)", x + triangle_size, y + triangle_size * 2))); Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) scale(1, 1)", x + triangle_size, y))); }
protected override void GeneratePattern() { var square_size = HexVal(0, 1).MapTo(0, 15, 10, 60); var tile = BuildOctagonShape(square_size); 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.PolyLine(tile, new Dictionary <string, object> { { "fill", fill }, { "fill-opacity", opacity }, { "stroke", Options["stroke_color"] }, { "stroke-opacity", Options["stroke_opacity"] }, { "transform", string.Format("translate({0}, {1})", x * square_size, y * square_size) } }); i++; } } }
protected override void GeneratePattern() { var scale = HexVal(0, 1); var sideLength = scale.MapTo(0, 15, 8, 60); var hexHeight = sideLength * Math.Sqrt(3); var hexWidth = sideLength * 2; var hex = BuildHexagonShape(sideLength); Svg.Width = (hexWidth * 3) + (sideLength * 3); Svg.Height = hexHeight * 6; var i = 0; for (var y = 0; y <= 5; y++) { for (var x = 0; x <= 5; x++) { var val = HexVal(i, 1); var dy = x % 2 == 0 ? y * hexHeight : y * hexHeight + hexHeight / 2; var opacity = Opacity(val); var fill = FillColor(val); var styles = new Dictionary <string, object> { { "fill", fill }, { "fill-opacity", opacity }, { "stroke", Options["stroke_color"] }, { "stroke-opacity", Options["stroke_opacity"] } }; Svg.PolyLine(hex, styles.Merge(Transform("translate({0}, {1})", x * sideLength * 1.5 - hexWidth / 2, dy - hexHeight / 2))); // Add an extra one at top-right, for tiling. if (x == 0) { Svg.PolyLine(hex, styles.Merge(Transform("translate({0}, {1})", 6 * sideLength * 1.5 - hexWidth / 2, dy - hexHeight / 2))); } // Add an extra row at the end that matches the first row, for tiling. if (y == 0) { dy = x % 2 == 0 ? 6 * hexHeight : 6 * hexHeight + hexHeight / 2; Svg.PolyLine(hex, styles.Merge(Transform("translate({0}, {1})", x * sideLength * 1.5 - hexWidth / 2, dy - hexHeight / 2))); } // Add an extra one at bottom-right, for tiling. if (x == 0 && y == 0) { Svg.PolyLine(hex, styles.Merge(Transform("translate({0}, {1})", 6 * sideLength * 1.5 - hexWidth / 2, 5 * hexHeight + hexHeight / 2))); } i++; } } }
protected override void GeneratePattern() { var scale = HexVal(0, 1); var side_length = scale.MapTo(0, 15, 15, 80); var triangle_width = side_length / 2 * Math.Sqrt(3); var triangle = build_rotated_triangle_shape(side_length, triangle_width); Svg.Width = triangle_width * 6; Svg.Height = side_length * 3; 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", fill }, { "fill-opacity", opacity }, { "stroke", Options["stroke_color"] }, { "stroke-opacity", Options["stroke_opacity"] } }; var rotation = 0; if (y % 2 == 0) { rotation = x % 2 == 0 ? 180 : 0; } else { rotation = x % 2 != 0 ? 180 : 0; } Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) rotate({2}, {3}, {4})", triangle_width * x, y * side_length * 0.5 - side_length / 2, rotation, triangle_width / 2, side_length / 2))); // Add an extra one at top-right, for tiling. if (y == 0) { Svg.PolyLine(triangle, styles.Merge(Transform("translate({0}, {1}) rotate({2}, {3}, {4})", triangle_width * x, 6 * side_length * 0.5 - side_length / 2, rotation, triangle_width / 2, side_length / 2))); } i++; } } }
protected override void GeneratePattern() { var diamond_width = HexVal(0, 1).MapTo(0, 15, 10, 50); var diamond_height = HexVal(1, 1).MapTo(0, 15, 10, 50); var diamond = build_diamond_shape(diamond_width, diamond_height); Svg.Width = diamond_width * 6; Svg.Height = diamond_height * 3; 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", fill }, { "fill-opacity", opacity }, { "stroke", Options["stroke_color"] }, { "stroke-opacity", Options["stroke_opacity"] } }; var dx = (y % 2 == 0) ? 0 : diamond_width / 2; Svg.PolyLine(diamond, styles.Merge(Transform("translate({0}, {1})", x * diamond_width - diamond_width / 2 + dx, diamond_height / 2 * y - diamond_height / 2))); // Add an extra one at top-right, for tiling. if (x == 0) { Svg.PolyLine(diamond, styles.Merge(Transform("translate({0}, {1})", 6 * diamond_width - diamond_width / 2 + dx, diamond_height / 2 * y - diamond_height / 2))); } // Add an extra row at the end that matches the first row, for tiling. if (y == 0) { Svg.PolyLine(diamond, styles.Merge(Transform("translate({0}, {1})", x * diamond_width - diamond_width / 2 + dx, diamond_height / 2 * 6 - diamond_height / 2))); } // Add an extra one at bottom-right, for tiling. if (x == 0 && y == 0) { Svg.PolyLine(diamond, styles.Merge(Transform("translate({0}, {1})", 6 * diamond_width - diamond_width / 2 + dx, diamond_height / 2 * 6 - diamond_height / 2))); } i++; } } }
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; } } }